Code covered by the BSD License  

Highlights from
mp3read and mp3write

4.58333

4.6 | 13 ratings Rate this file 205 Downloads (last 30 days) File Size: 2.13 MB File ID: #13852
image thumbnail

mp3read and mp3write

by Dan Ellis

 

04 Feb 2007 (Updated 21 Apr 2010)

Improved reading and writing of mp3 files

| Watch this File

File Information
Description

These versions of mp3read and mp3write are direct drop-in replacements for wavread and wavwrite to access MPEG audio mp3 files. Features include:
 - aims to duplicate complete syntax of wavread and wavwrite
 - also supports on-the-fly downsampling and channel merging of mpg123
 - optimized for very long mp3 files - only decodes the needed portion
 - uses popen for encoding to avoid a large temporary file (when available - see my popenw mex)
 - attempts to preserve time alignment of files through read/write loop by removing "warm up" samples
 - package includes helper binaries for Linux, Windows, Mac-PPC, Mac-Intel, and Mac-Intel-64bit

Acknowledgements

The author wishes to acknowledge the following in the creation of this submission:
MP3WRITE and MP3READ

MATLAB release MATLAB 7.10 (2010a)
Other requirements Relies on external binaries mpg123, mp3info, and lame. Package includes binaries that should work, but YMMV. Documentation includes links to the sources of these programs.
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (21)
19 Feb 2007 Daryush Mehta

Works great! Commenting in the code helps the reader well. I am running Windows XP SP2 and Matlab 7.3.0 (R2006b).

As Dan Ellis notes on his website <http://labrosa.ee.columbia.edu/matlab/popenrw.html>;, two functions are available to prevent Lame from having to access a large temporary file; instead, a "pipeline" is open to the lame codec. I was able to compile Dan Ellis' popenw.c and popenr.c files ('mex popenw.c' and 'mex popenr.c' at Matlab command prompt) to give platform-specific mex files. But, when I ran the mp3write code, no error was given and no mp3 file was created. If anyone can get this functionality working, please share it!

Also, definitely read the mp3write help file to note that you can specify the bit rate by changing the last integer in
mp3write(x,fs,'filename','--quiet -h -b 128');'

Should prove to be very useful. Thanks for writing them.

19 Feb 2007 Daryush Mehta

Forgot to mention that in my setup (WinXP SP2, Matlab 2006b), the default bit rate for mp3write turns out to be 64 kbps, not 128 kbps that's mentioned in the help file.

23 Jul 2007 Mahocan Ganemur

Hi,

Thanks for building such a useful tool. I just tried the command "SIZ = MP3READ(FILE,'size')" on MATLAB. The resulting "total number of audio samples" value given by the command is not correct. For example in the file that I test, there are 237 931 198 total audio samples, while the command has given the result as 193 625 280. I tried on another mp3 file that is relatiely small. The correct size of this file is 41 133 311, while the command has given as 40 912 128. I cannot get the correct value of the total number of audio samples in the mp3 file with this command. Any suggestions on this issue? Thanks in advance.

31 Jul 2007 Mahocan Ganemur

Good job!

18 Aug 2007 hrushikesh kulkarni

great i am very thankful to you

15 Jan 2008 Jose Uy

It doesn't seem to work with mp3's downloaded from itunes. Does the AAC encoding have anything to do with this?

21 Feb 2008 suraj prakash

its cool.

14 Apr 2008 Aaron Clarke

I tried it and it worked great right away. Nice program!

16 Apr 2008 loch zeng

This is a good tools

01 Aug 2008 JG NT

I can recommend this program! IT worked very good. Thanks

01 Dec 2008 Jorge Moragues

As Mahocan said, the corresponding 'SIZ' command does not work properly and it returns a wrong number of samples of the file.

Has anybody solved this problem?

Thanks

30 Mar 2010 T myself

Great tool! Works nice. Thank you.

31 Mar 2010 Gökhan Vural

It works very nice overally. However, it gives ".mp3 is corrupt or is not a standard MP3 file." error for some songs. Indeed, files're not corrupt.
Does anybody know the reason of it ?

06 May 2010 brigitte audrey

very good stuff. thanks for sharing

20 Jul 2010 David

and I got this error with mp3read

>> mp3read([mp3_list(i).name])
??? Error using ==> mp3read>mysystem at 373
unable to execute "C:\Documents and Settings\mfiles\mp3readwrite\mpg123.exe" -q -w "\tmp\tmp127.wav"
"DJ.mp3" ()

Error in ==> mp3read at 330
  mysystem(cmd);

01 Aug 2010 Manikandan

I got 'Out of Memory' error. Please advice me. Thanks.

08 Aug 2011 Ilaria Milesi  
19 Sep 2011 Mr Smart  
11 Oct 2011 Jesse van Muijden

works fine with Matlab 7.10.0 (R2010a) on Windows XP Pro SP3. Thank you!

22 Nov 2011 Han

Thank you

28 Nov 2011 bei liu

It's good,bur I dont know hwo to use it.

Please login to add a comment or rating.
Updates
27 Jul 2007

- fix to writing stereo files on Windows
 - mp3read(...,'size') now more accurate (but not perfect owing to limitations in mp3info)
 - various cleanups to reduce mlint errors

30 Jul 2007

- updated interaction of sample limits and predelay compensation in mp3read to make it more consistent
 - increased buffer to provide more tolerance of bad blocks in stream

15 Mar 2009

This version enables the ability of mpg123 to read mp3 files from URLs.

09 Apr 2010

Updated to use and include more recent versions of mpg123 and lame. I've done my best to fix inconsistencies with the 'size' return, but for some MP3s this relies on header info I can't probe.

21 Apr 2010

 - updated binaries for maci64 (static link) and windows (http works)
 - expands '~' in file names
 - returns correct SR when reading over http:

Tag Activity for this File
Tag Applied By Date/Time
sound Dan Ellis 22 Oct 2008 08:59:26
audio file Dan Ellis 22 Oct 2008 08:59:26
mpeg audio Dan Ellis 22 Oct 2008 08:59:26
mp3 Dan Ellis 22 Oct 2008 08:59:26
mp3 chetan 23 Oct 2009 01:00:41
mp3read brigitte audrey 06 May 2010 00:38:43
mp3read Hsuan-Lung 01 Jul 2010 22:33:25
audio file Weston Arnold 17 Oct 2010 21:11:57
mp3 Oscar Muñoz 19 May 2011 19:45:17
mp3 Ilaria Milesi 08 Aug 2011 07:37:26
audio file santos666 30 Sep 2011 10:18:52
audio file kanty sri 29 Nov 2011 07:24:29
audio file Dimas Natajiwa 15 Dec 2011 02:45:30
audio file bedadipta 21 Dec 2011 08:18:22
mp3 bedadipta 21 Dec 2011 08:18:29

Contact us at files@mathworks.com