Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

Potamus audio player

Message
Author
User avatar
colin_b
Forum Regular
Forum Regular
Posts: 339
Joined: Sun Mar 19, 2017 7:21 pm

Potamus audio player

#1 Post by colin_b » Sat Jun 09, 2018 6:01 pm

I can see you slapping your head saying "not another one," but there is a reason for my suggesting Potamus.

Here's what interests me:
http://offog.org/code/potamus/

Potamus is a lightweight GTK-based audio player with a simple interface and an emphasis on high audio quality.

...

For MPEG audio playback (including MP3), it uses libmad's high-quality decoder to produce dithered 24-bit output.
More on libmad:
http://libzplay.sourceforge.net/LIBMAD.html

Because MAD provides full 24-bit PCM output, applications using MAD are able to produce high quality audio. Even when the output device supports only 16-bit PCM, applications can use the extra resolution to increase the audible dynamic range through the use of dithering or noise shaping.
I've got a good set of speakers on my system and I am curious as to whether it really does improve mp3 playback quality.

Can Potamus be added to a repo?

User avatar
colin_b
Forum Regular
Forum Regular
Posts: 339
Joined: Sun Mar 19, 2017 7:21 pm

Re: Potamus audio player

#2 Post by colin_b » Thu Jun 14, 2018 7:38 pm

Many thanks for adding this to the test repo.

My PC has an Asus Xonar soundcard and it outputs through JBL 305 speakers. I have given Potamus a good trial as I was skeptical about the claimed benefits of extra audio resolution, but it is now clear to me that it makes a huge difference. When I played through a directory of mixed bitrate mp3 files the sound was tighter and more detailed than I had ever previously heard. I would go as far as to say my ghast was flabbered :happy:

If you want to hear great sounding mp3 files I highly recommend you give Potamus a try. What it lacks in features is more than offset by its audio quality.

It is also incredibly light on resources, it uses <40MB RAM when playing.

User avatar
robert1
Forum Regular
Forum Regular
Posts: 203
Joined: Thu Jul 12, 2007 11:19 pm

Re: Potamus audio player

#3 Post by robert1 » Sat Jun 16, 2018 4:57 pm

I run across this thread the other day, i decided to try Potamus out. It is as good as it say's. I have my sound card outputed to a Bell 3030 tube amp, driving a pair of Polk Audio Monitor-4 speakers. the sound was amazing. i did a comparison with Audacious. the sound quality from audacious was not even close as it was with Potamus. i was using various High Bitrate .mp3 & .ogg vorbis files.

sunrat
Forum Regular
Forum Regular
Posts: 220
Joined: Mon Mar 28, 2016 9:54 pm

Re: Potamus audio player

#4 Post by sunrat » Sat Jun 16, 2018 9:04 pm

I did a little research on this recently. Pulse resamples by default although you can use a better quality resampler.
https://r3dux.org/2013/12/how-to-enable ... -in-linux/
https://forum.manjaro.org/t/solved-terr ... ndows/8203

However, the setup I ended up with was to use a player with direct ALSA output to bypass Pulse. I use DeadBeef with ALSA output and resampler removed. GMusicBrowser works well too.
https://www.head-fi.org/threads/bit-per ... ux.561961/

Ultimately I consider it to be a bit academic as I've always had good audio using M-Audio Audiophile 2496 card and Adam A5X speakers. ;)

User avatar
colin_b
Forum Regular
Forum Regular
Posts: 339
Joined: Sun Mar 19, 2017 7:21 pm

Re: Potamus audio player

#5 Post by colin_b » Sun Jul 29, 2018 9:28 pm

I feel I've got to put a quick review of Potamus together because it is superb.

Potamus uses libmad to play mp3s. Here's a quick explanation of what this does:
http://libzplay.sourceforge.net/LIBMAD.html

Because MAD provides full 24-bit PCM output, applications using MAD are able to produce high quality audio. Even when the output device supports only 16-bit PCM, applications can use the extra resolution to increase the audible dynamic range through the use of dithering or noise shaping.
When I first read this I immediately thought of snake oil. Converting 16 bit audio to 24 bit to make things sound better - I sincerely doubted this would be of benefit. Anyway, I read the following:
https://winampheritage.com/plugin/in-mad/88993

This is a great plugin not because it increases bitdepth, but because it DECODES in a higher bitdepth. In other words, the MP3s are decoded with a higher level of precision. So, even if you have to use 16-bit output (or even a mere 8-bit) then it should come out in better quality.
I felt there was only one way to try this out, so I took some albums which I have only ever heard on CD, converted them to 320Kbps VBR mp3s, and I then listened to see if I could hear any differences.

Logic says the lossless audio from a CD should sound better than a lossy mp3 file.

The first album I tried was ABC's "Lexicon of Love." I bought it many years ago and I still play it on a regular basis. Methinks I'm getting old :bawling:

Anyway, I listened to the album and it was a revelation. The album has lots of orchestra in it, and the mp3 playback revealed numerous instruments which I had never previously heard when playing the CD. I was impressed.

I then played Depeche Mode's "Violator." This is pure synth with a bit of guitar thrown in for good measure, and the detail that emerged from the mp3s was unbelievable. It sounded like a tarpaulin had been removed from the speakers and I could finally hear clear audio. The top end was crystal clear, the midrange was highly detailed, and the bass was defined and punchy. I can not believe how much of this album I've missed even though the CD has been played to death.

I finally gave my all time #1 favorite album a try - The Enemy's "It's Automatic." If you've never heard this album (and I suspect you haven't as it's an indie release) I can't recommend it highly enough - don't let the name of the group put you off, the album is not political, it's just absolutely brilliant.

Unfortunately there is an almighty flaw with this album, namely it was mastered by muppets who have wholehearted subscribed to the loudness wars. If you've never heard of this watch this brief video https://www.youtube.com/watch?v=7UjQc0dM4H4. Excessive volume effectively trashes the audio, and this drives me nuts. What is going on in their heads?

Anyway, here's what one person said of libmad:
https://winampheritage.com/plugin/in-mad/88993

YOU NEED THIS - this plugin is great it makes all audio files sound cleaner. and best of all it adjust the wave output on the fly reducing clipping from poorly recorded music
So did it make any difference to the playback of "It's Automatic"? You bet it did. I always found the CD hard to listen to, I guess my brain was being fried trying to work out what instruments were what because of the excessive audio levels. When I listened to the mp3s on Potamus the album was easy to listen to, and the detail that jumped out was amazing. The drums even had some punch.

If you're looking for good sound Potamus delivers in spades. It is advertised as a high quality audio player and it ain't kidding - it's the dogs doofers when it comes to mp3 playback. Please give it a try, especially if you've got a good pair of speakers.

I won't be listening to a CD again.

User avatar
oops
Forum Regular
Forum Regular
Posts: 357
Joined: Tue Apr 10, 2018 5:07 pm

Re: Potamus audio player

#6 Post by oops » Mon Jul 30, 2018 7:14 am

sunrat wrote:
Sat Jun 16, 2018 9:04 pm
I did a little research on this recently. Pulse resamples by default although you can use a better quality resampler.
https://r3dux.org/2013/12/how-to-enable ... -in-linux/
Thanks, right the sound is also better than this way, but .
... by default pulseaudio and alsa are configured for 44.1KHz 16-bit audio. At the 44.1/16-bit settings everything sounds great, but I figure if the quality can go higher and I’m not fussy about a bit of extra CPU usage then I may as well bump the quality settings up a bit to take full advantage...

Code: Select all

nano /etc/pulse/daemon.conf
resample-method = src-sinc-medium-quality
default-sample-format = s24le
default-sample-rate = 96000

# to test:
pacmd list-sinks | grep sample
$ inxi -S : System: Host:XEON Kernel: 4.16.0-xeon-01.efi x86_64 bits: 64 Desktop: Xfce 4.12.3 - Distro: MX-17.1_x64 Horizon


nathan2423
Forum Regular
Forum Regular
Posts: 272
Joined: Tue Dec 22, 2015 8:33 am

Re: Potamus audio player

#7 Post by nathan2423 » Mon Jul 30, 2018 9:26 am

Thank you for suggesting Potamus. I have been looking for a replacement for my favorite directory player / small fast windows music player - 1by1 - and this looks like a good option, in addition to the decoding quality.

Potamus doesn't have the file browser, doesn't show a picture of the album art, and doesn't have any way to construct even the single playlist that 1by1 directory browser has, but otherwise it is very workable replacement in the very small, very fast, category. As stated, use a file manager to find the directory, then open with Potamus, and you've got a high quality very quick way to play songs in a directory.

And I agree, the sound quality is very good!

sunrat
Forum Regular
Forum Regular
Posts: 220
Joined: Mon Mar 28, 2016 9:54 pm

Re: Potamus audio player

#8 Post by sunrat » Mon Jul 30, 2018 11:07 am

I'm trying out Potamus now. Honestly I can't hear any difference from DeadBeef (with inbuilt resampler removed) or mpv with whatever it uses. Admittedly I usually play FLAC files and have a fairly well tweaked PA config already with sox-vhq resampler and 32 bit float processing. Even tried some 24/96 files.
I can hear a possible improvement in higher frequency clarity and "airiness" with 320kb/s mp3 files so if you usually listen to mp3 there may be a small advantage. libmad is a MPEG decoder library so I imagine it may be the reason mp3s sound better, but it would not be used for any other format so would have no effect. Lossless files still sound better than mp3 if you listen closely.
I'll keep Potamus installed but won't be switching from DeadBeef for everyday use.

User avatar
colin_b
Forum Regular
Forum Regular
Posts: 339
Joined: Sun Mar 19, 2017 7:21 pm

Re: Potamus audio player

#9 Post by colin_b » Mon Jul 30, 2018 10:41 pm

sunrat wrote:
Mon Jul 30, 2018 11:07 am
Admittedly I usually play FLAC files and have a fairly well tweaked PA config already with sox-vhq resampler and 32 bit float processing.
My PA has no tweaks, so I'm used to the default audio output.
sunrat wrote:
Mon Jul 30, 2018 11:07 am
I can hear a possible improvement in higher frequency clarity and "airiness" with 320kb/s mp3 files so if you usually listen to mp3 there may be a small advantage. libmad is a MPEG decoder library so I imagine it may be the reason mp3s sound better...
On my untweaked setup Potamus' mp3 output quality is significantly better than CD audio or FLAC. It strikes me that a tweaked PA would give better lossless audio quality, thus the mp3 output quality would seem less marked.
sunrat wrote:
Mon Jul 30, 2018 11:07 am
libmad is a MPEG decoder library so I imagine it may be the reason mp3s sound better...
You are correct, Potamus will play numerous types of files, but only mp3s benefit from libmad.

From the Poramus website:
https://offog.org/code/potamus/

It can decode FLAC, Ogg Vorbis, Opus, MPEG audio, and any format supported by the ModPlug, audiofile or FFmpeg libraries (including WAV, Shorten, and various module formats). For MPEG audio playback (including MP3), it uses libmad's high-quality decoder to produce dithered 24-bit output.
I see Potamus as being ideal for anyone who listens to mp3s and doesn't want to tinker with system settings to get excellent audio quality. It is also excels at playing audio that has been trashed by overly loud mastering.

User avatar
colin_b
Forum Regular
Forum Regular
Posts: 339
Joined: Sun Mar 19, 2017 7:21 pm

Re: Potamus audio player

#10 Post by colin_b » Tue Jul 31, 2018 8:14 pm

This may be a dumb question, but I've got to ask it.

I was just Googling libmad when I came across the following:
Implementing MP3 player in C
https://lauri.võsandi.com/2013/12/imple ... er.en.html

In case of Linux based machines one could directly use alsa-lib feed the samples to kernel, which in turn transfers them to the audio chip. Modern distributions intercept ALSA output and hook those applications to the PulseAudio audioserver. PulseAudio allows on-the-fly switching of audio output between headphones, HDMI output or Bluetooth headset and other fancy stuff that you would expect from modern operating system. In that case one might use PulseAudio libraries to feed the PCM samples directly to PulseAudio server. There are of course libraries like libao which build yet another abstraction layer on top of ALSA, PulseAudio and others, but at the moment of writing it seems to be not so well maintained in Ubuntu package management.

So, here goes a sample using libmad and libpulse:

Code: Select all

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <mad.h>
#include <pulse/simple.h>
#include <pulse/error.h>

pa_simple *device = NULL;
int ret = 1;
int error;
struct mad_stream mad_stream;
struct mad_frame mad_frame;
struct mad_synth mad_synth;

void output(struct mad_header const *header, struct mad_pcm *pcm);

int main(int argc, char **argv) {
    // Parse command-line arguments
    if (argc != 2) {
        fprintf(stderr, "Usage: %s [filename.mp3]", argv[0]);
        return 255;
    }

    // Set up PulseAudio 16-bit 44.1kHz stereo output
    static const pa_sample_spec ss = { .format = PA_SAMPLE_S16LE, .rate = 44100, .channels = 2 };
    if (!(device = pa_simple_new(NULL, "MP3 player", PA_STREAM_PLAYBACK, NULL, "playback", &ss, NULL, NULL, &error))) {
        printf("pa_simple_new() failed\n");
        return 255;
    }

    // Initialize MAD library
    mad_stream_init(&mad_stream);
    mad_synth_init(&mad_synth);
    mad_frame_init(&mad_frame);

    // Filename pointer
    char *filename = argv[1];

    // File pointer
    FILE *fp = fopen(filename, "r");
    int fd = fileno(fp);

    // Fetch file size, etc
    struct stat metadata;
    if (fstat(fd, &metadata) >= 0) {
        printf("File size %d bytes\n", (int)metadata.st_size);
    } else {
        printf("Failed to stat %s\n", filename);
        fclose(fp);
        return 254;
    }

    // Let kernel do all the dirty job of buffering etc, map file contents to memory
    char *input_stream = mmap(0, metadata.st_size, PROT_READ, MAP_SHARED, fd, 0);

    // Copy pointer and length to mad_stream struct
    mad_stream_buffer(&mad_stream, input_stream, metadata.st_size);

    // Decode frame and synthesize loop
    while (1) {

        // Decode frame from the stream
        if (mad_frame_decode(&mad_frame, &mad_stream)) {
            if (MAD_RECOVERABLE(mad_stream.error)) {
                continue;
            } else if (mad_stream.error == MAD_ERROR_BUFLEN) {
                continue;
            } else {
                break;
            }
        }
        // Synthesize PCM data of frame
        mad_synth_frame(&mad_synth, &mad_frame);
        output(&mad_frame.header, &mad_synth.pcm);
    }

    // Close
    fclose(fp);

    // Free MAD structs
    mad_synth_finish(&mad_synth);
    mad_frame_finish(&mad_frame);
    mad_stream_finish(&mad_stream);

    // Close PulseAudio output
    if (device)
        pa_simple_free(device);

    return EXIT_SUCCESS;
}

// Some helper functions, to be cleaned up in the future
int scale(mad_fixed_t sample) {
     /* round */
     sample += (1L << (MAD_F_FRACBITS - 16));
     /* clip */
     if (sample >= MAD_F_ONE)
         sample = MAD_F_ONE - 1;
     else if (sample < -MAD_F_ONE)
         sample = -MAD_F_ONE;
     /* quantize */
     return sample >> (MAD_F_FRACBITS + 1 - 16);
}
void output(struct mad_header const *header, struct mad_pcm *pcm) {
    register int nsamples = pcm->length;
    mad_fixed_t const *left_ch = pcm->samples[0], *right_ch = pcm->samples[1];
    static char stream[1152*4];
    if (pcm->channels == 2) {
        while (nsamples--) {
            signed int sample;
            sample = scale(*left_ch++);
            stream[(pcm->length-nsamples)*4 ] = ((sample >> 0) & 0xff);
            stream[(pcm->length-nsamples)*4 +1] = ((sample >> 8) & 0xff);
            sample = scale(*right_ch++);
            stream[(pcm->length-nsamples)*4+2 ] = ((sample >> 0) & 0xff);
            stream[(pcm->length-nsamples)*4 +3] = ((sample >> 8) & 0xff);
        }
        if (pa_simple_write(device, stream, (size_t)1152*4, &error) < 0) {
            fprintf(stderr, "pa_simple_write() failed: %s\n", pa_strerror(error));
            return;
        }
    } else {
        printf("Mono not supported!");
    }
}
You may compile this snippet by linking against the appropriate libraries:

Code: Select all

gcc -o player player.c -lpulse -lpulse-simple -lmad -g
On Ubuntu you of course have to first install the dependencies:

Code: Select all

sudo apt-get install libpulse-dev libmad0-dev libpulse0 libmad
The audio quality of mp3s output via libmad is way better the standard output method.

Here's where I might sound dumb.

Is the above a method of allowing all software to utilize libmad for output?

If so could it be implemented on MX to enhance mp3 playback quality? It would sound superb.

If it isn't a method of allowing software to utilize libmad then thee's only one thing I can do.

:bagoverhead:

Post Reply

Return to “Package Requests/Status - MX 17”