minimp3 source code

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

minimp3 source code

#1 Post by technosaurus »

I got a little mp3 player from:
http://keyj.s2000.ws/ (there is also nanojpeg and some other tiny nifty utils)

it compiled and worked fine but it pulled in libm,

so I tried to compile it without libm and found it needed some trig functions - so I added the -ffast-math compiler flag and all it needed was "pow" both the gnu and uclibc were too big to include so I included pow from the libm in dietlibc and eureka. It now uses less than 2mb of ram and 0% cpu load and still weighs in at only 31k.

Edit - I compiled it with static dietlibc and it is even smaller only 30k and uses only 400kb of ram and 0% CPU (-ffast-math yields bad results with dietlibc so I removed it) ... both tarballs include source, build script and a public domain mp3 of a dog bark for testing
Attachments
minimp3-0.2.tar.gz
dietlibc static version
(64.06 KiB) Downloaded 1555 times
minimp3-0.1.tar.gz
gnulibc shared version
(64.39 KiB) Downloaded 1455 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

minimp3

#2 Post by vovchik »

Dear technosaurus,

Nice, and thanks. Both versions work in Puppy 3.01 and 4.x. I also compiled nanojpeg, and it weighs in at 14k stripped (19k unstripped). I have yet to try it.

With kind regards,
vovchik

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#3 Post by MinHundHettePerro »

Hello :)!
Tested on musical .mp3s in ttuuxxx' 214XRC5:

Version 1 plays nicely :).

Version 2 plays like the singer had inhaled helium (that goes for the instruments as well), although the playback speed seems correct :? - like a very highly set high-pass-filter :?.

Thanks for this player, from this minimalist at heart :)/
MHHP
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#4 Post by technosaurus »

MinHundHettePerro wrote:Version 2 plays like the singer had inhaled helium (that goes for the instruments as well), although the playback speed seems correct :? - like a very highly set high-pass-filter :?.
You should have heard it before I removed -ffast-math... oooo maybe I should check the package - I have had it happen before where a tarball gets an old (deleted) version that was in the same location due to weird unionfs voodoo magic...
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#5 Post by technosaurus »

I'm adding v3 which includes a build script that will allow 3 different compile types (just edit the script for the alternate builds)

gnu libc and libm
gnu libc and no libm by using -ffast-math and pow() from dietlibc
static dietlibc binary
(binaries for each type are included in the tarbal)

turns out my last dietlibc compile probably sounded bad because it used my newer dietlibc include headers but linked against Barry's older libs (I forgot dietlibc was in the devx and ended up with version mismatching)
Attachments
minimp3-0.3.tar.gz
(81.42 KiB) Downloaded 1411 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#6 Post by goingnuts »

Tested all 3 in 431: The two gnuc-versions sounds equal (good....)
The dietstatic build has some (not unpleasant...) distortion...
I really like this tiny but basic and useful application!

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#7 Post by jpeps »

gnu libc and libm worked well in Lupu. Compared with gnome-mplayer, using mini saved 58M RAM when playing an mp3 track.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#8 Post by disciple »

(not unpleasant...) distortion...
:shock: :!: :?:
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#9 Post by technosaurus »

since I am targeting this at lower end PCs, I thought it would be nice to be able to play a list of files or *.mp3 .... yes this could easily be done with a script

for x in `ls ./*.mp3`; do minimp3 $x; done

but that keeps the shell open the entire time which uses 4x the RAM as the static dietlibc version

so I added a for loop to main (it probably needs to be fixed up to pull unnecessary stuff out of the loop and such)

so now you can do this instead
minimp3 `ls ./*.mp3` &

or even drag a bunch of selected files to it (it sits nicely on my desktop now)
Attachments
minimp3-0.4.tar.gz
(80.37 KiB) Downloaded 1498 times
Last edited by technosaurus on Thu 02 Sep 2010, 08:44, edited 1 time in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#10 Post by goingnuts »

disciple wrote:
(not unpleasant...) distortion...
:shock: :!: :?:
Yah - like being in a tube with a psychedelic rock band...
Some audio-players have that as a feature (like "bathroom-effect")... :)

tempestuous
Posts: 5464
Joined: Fri 10 Jun 2005, 05:12
Location: Australia

#11 Post by tempestuous »

Guys, I find this thread very interesting.
But just to add some context here: forum member pakt has been using mpg123 with the minimalist gui "xhippo" on his eBox-2300 with a paltry 200MHz processor and modest onboard graphics chip. That results in an acceptable 21% CPU usage:
http://www.murga-linux.com/puppy/viewto ... 960#306960
What are you intending to run this on? A Linux-powered wrist-watch!

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#12 Post by disciple »

Has anyone actually compared this with mpg123? (for both ram and cpu usage)

If I was running either a 200MHz machine or a wristwatch I'd take anything extra I could get... sometimes I even get the urge to use an ultra-tiny mp3 player on this 1200MHz/512MB machine :)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#13 Post by jpeps »

disciple wrote:Has anyone actually compared this with mpg123? (for both ram and cpu usage)
Yes, in lucid. minimp3 worked out of the box.

Code: Select all

[module.c:126] error: Failed to open module alsa: file not found
[module.c:126] error: Failed to open module oss: file not found
[audio.c:179] error: Unable to find a working output module in this list: alsa,oss
[audio.c:533] error: Failed to open audio output module
[mpg123.c:773] error: Failed to initialize output, goodbye.
~ # 

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#14 Post by technosaurus »

initially I only wanted it as a quick, reliable way to test audio functionality on systems independent of the library versions , but it is so out of the way that I kept it around to play tunes in the background (that's why I added the multiple file capability)... also because it is <64kb and runs less than 512kb it can stay mostly in cache on a lot of systems

There are a few binaries in Puppy that could immensely benefit from a static dietlibc build - mostly the always on items that run in the background like tray apps and the automounting daemon. The most obvious is sleep because it is using the inbuilt busybox sleep, so it takes up something like 2.5MB, but if compiled against dietlibc the bin is only 2kb and takes up 20kb in RAM... since Puppy mostly runs in RAM, this would be a net savings of over 2MB at no significant cost (btw does anyone know which program is actually running "sleep 2") ... others are init, udevd (has anyone experimented with replacing it with busybox's mdev?), dhcpcd, ash, and maybe even cups.

For comparison purposes, the static uclibc busybox build from http://impactlinux.com/aboriginal (formerly firmware linux) has double the number of applets that puppy's has and takes less ram to run because gnu libc and libm bring in over 1mb on their own. Using Rob Landley's builds we could double our applets and nearly half the RAM usage, but it may even be worth it to build a second (even smaller) busybox just for the daemonized applets. Some busybox alternatives are embutils(Felix von Leitner-dietlibc), asmutils(assembly-alinux), toybox(Rob Landley-aboriginal linux), toolbox(Google's replacement for busybox)... probably others?
Last edited by technosaurus on Fri 03 Sep 2010, 00:00, edited 1 time in total.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
MinHundHettePerro
Posts: 852
Joined: Thu 05 Feb 2009, 22:22
Location: SE

#15 Post by MinHundHettePerro »

Hello :D!

Testing your newer versions in 214XRC5:

Ver. 3&4;
the gnu-versions work immaculately :),
the statics sound like Donald Duck on acid killed the singer, took over the mic, ripped the drums, and wrapped the rest of the band in duct tape :shock:.

Comparison of resources of minimp3 and mpg321, tested on a 2.8GHz,1Mb, 214XRC5 machine:
CPU
idling at 0.7-1.3%
minimp3 1.3-2.0%
mpg321 2.0-4.0%
Memory
Impact not discernible with htop (in cache?)

hth :)/
MHHP
[color=green]Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285[/color]
Slackos & 214X, ... and Q6xx
[color=darkred]Nämen, vaf....[/color] [color=green]ln -s /dev/null MHHP[/color]

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#16 Post by disciple »

Impact not discernible with htop (in cache?)
That's why I didn't try to compare it myself ;)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

jpeps
Posts: 3179
Joined: Sat 31 May 2008, 19:00

#17 Post by jpeps »

disciple wrote:
Impact not discernible with htop (in cache?)
That's why I didn't try to compare it myself ;)
Hey.. there's a difference; this is for the high quality mini using gnu libc and libm.

mpg321: 55M 6% CPU
minimp3: 48M 2% CPU

goingnuts
Posts: 932
Joined: Sun 07 Dec 2008, 13:33
Contact:

#18 Post by goingnuts »

Any chance to include support for .au and .wav-play? Think both can just be send to /dev/audio or /dev/dsp via cat but might not play all files correct though...

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#19 Post by technosaurus »

goingnuts wrote:Any chance to include support for .au and .wav-play? Think both can just be send to /dev/audio or /dev/dsp via cat but might not play all files correct though...
I can't code it but if you can point me to a small standalone example(s), I may be able to hack it in there. I'd also need a C example to parse the file extension.
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

User avatar
technosaurus
Posts: 4853
Joined: Mon 19 May 2008, 01:24
Location: Blue Springs, MO
Contact:

#20 Post by technosaurus »

I found wavplay, but it needs a lot of hacking down - still contains quite some bloat, but I compiled it statically against dietlibc if anyone wants it.

http://sourceforge.net/projects/wavplay/files/

edit: bplay is a little better size wise and plays other formats too
Attachments
bplay.tar.gz
(30.22 KiB) Downloaded 662 times
wavplay.tar.gz
(18.86 KiB) Downloaded 674 times
Check out my [url=https://github.com/technosaurus]github repositories[/url]. I may eventually get around to updating my [url=http://bashismal.blogspot.com]blogspot[/url].

Post Reply