Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 26 Nov 2014, 17:37
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
minimp3 source code
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
Page 1 of 3 Posts_count   Goto page: 1, 2, 3 Next
Author Message
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Tue 31 Aug 2010, 21:54    Post_subject:  minimp3 source code  

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
minimp3-0.2.tar.gz
Description  dietlibc static version
gz

 Download 
Filename  minimp3-0.2.tar.gz 
Filesize  64.06 KB 
Downloaded  759 Time(s) 
minimp3-0.1.tar.gz
Description  gnulibc shared version
gz

 Download 
Filename  minimp3-0.1.tar.gz 
Filesize  64.39 KB 
Downloaded  720 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Wed 01 Sep 2010, 13:24    Post_subject: minimp3  

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
Back to top
View user's profile Send_private_message 
MinHundHettePerro


Joined: 05 Feb 2009
Posts: 855
Location: SE

PostPosted: Wed 01 Sep 2010, 16:48    Post_subject:  

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

Version 1 plays nicely Smile.

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

Thanks for this player, from this minimalist at heart Smile/
MHHP

_________________
Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285

Slackos & 214X, ... and Q6xx
Nämen, vaf.... ln -s /dev/null MHHP
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Wed 01 Sep 2010, 17:35    Post_subject:  

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


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...

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Wed 01 Sep 2010, 21:25    Post_subject:  

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)
minimp3-0.3.tar.gz
Description 
gz

 Download 
Filename  minimp3-0.3.tar.gz 
Filesize  81.42 KB 
Downloaded  671 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 783

PostPosted: Thu 02 Sep 2010, 00:03    Post_subject:  

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!
Back to top
View user's profile Send_private_message Visit_website 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Thu 02 Sep 2010, 01:24    Post_subject:  

gnu libc and libm worked well in Lupu. Compared with gnome-mplayer, using mini saved 58M RAM when playing an mp3 track.
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6458
Location: Auckland, New Zealand

PostPosted: Thu 02 Sep 2010, 02:43    Post_subject:  

Quote:
(not unpleasant...) distortion...

Shocked Exclamation Question

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Thu 02 Sep 2010, 04:22    Post_subject:  

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)
minimp3-0.4.tar.gz
Description 
gz

 Download 
Filename  minimp3-0.4.tar.gz 
Filesize  80.37 KB 
Downloaded  775 Time(s) 

_________________
Web Programming - Pet Packaging 100 & 101

Edited_time_total
Back to top
View user's profile Send_private_message 
goingnuts

Joined: 07 Dec 2008
Posts: 783

PostPosted: Thu 02 Sep 2010, 04:29    Post_subject:  

disciple wrote:
Quote:
(not unpleasant...) distortion...

Shocked Exclamation Question

Yah - like being in a tube with a psychedelic rock band...
Some audio-players have that as a feature (like "bathroom-effect")... Smile
Back to top
View user's profile Send_private_message Visit_website 
tempestuous

Joined: 10 Jun 2005
Posts: 5285
Location: Australia

PostPosted: Thu 02 Sep 2010, 05:26    Post_subject:  

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/viewtopic.php?p=306960#306960
What are you intending to run this on? A Linux-powered wrist-watch!
Back to top
View user's profile Send_private_message 
disciple

Joined: 20 May 2006
Posts: 6458
Location: Auckland, New Zealand

PostPosted: Thu 02 Sep 2010, 06:25    Post_subject:  

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 Smile

_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send_private_message 
jpeps

Joined: 31 May 2008
Posts: 3220

PostPosted: Thu 02 Sep 2010, 11:28    Post_subject:  

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:

[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.
~ #
Back to top
View user's profile Send_private_message 
technosaurus


Joined: 18 May 2008
Posts: 4379

PostPosted: Thu 02 Sep 2010, 16:51    Post_subject:  

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?

_________________
Web Programming - Pet Packaging 100 & 101

Edited_time_total
Back to top
View user's profile Send_private_message 
MinHundHettePerro


Joined: 05 Feb 2009
Posts: 855
Location: SE

PostPosted: Thu 02 Sep 2010, 17:38    Post_subject:  

Hello Very Happy!

Testing your newer versions in 214XRC5:

Ver. 3&4;
the gnu-versions work immaculately Smile,
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 Shocked.

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 Smile/
MHHP

_________________
Celeron 2.8 GHz, 1 GB, i82845, many ptns, modes 12, 13
Dual Xeon 3.2 GHz, 1 GB, nvidia quadro nvs 285

Slackos & 214X, ... and Q6xx
Nämen, vaf.... ln -s /dev/null MHHP
Back to top
View user's profile Send_private_message 
Display_posts:   Sort by:   
Page 1 of 3 Posts_count   Goto page: 1, 2, 3 Next
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » Off-Topic Area » Programming
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0882s ][ Queries: 13 (0.0056s) ][ GZIP on ]