4.28571

4.3 | 8 ratings Rate this file 248 downloads (last 30 days) File Size: 1.61 MB File ID: #13852

mp3read and mp3write

by Dan Ellis

 

04 Feb 2007 (Updated 30 Jul 2007)

Code covered by BSD License  

Improved reading and writing of mp3 files

Download Now | 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 and Mac-Intel

Acknowledgements

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

MATLAB release MATLAB 7.3 (R2006b)
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.
Zip File Content  
Published M Files MP3 reading and writing
Other Files
mp3readwrite/.DS_Store,
__MACOSX/mp3readwrite/._.DS_Store,
mp3readwrite/demo_mp3readwrite.m,
mp3readwrite/piano.wav,
mp3readwrite/html/demo_mp3readwrite.png,
mp3readwrite/html/demo_mp3readwrite_01.png,
mp3readwrite/lame.exe,
mp3readwrite/lame.glnx86,
mp3readwrite/lame.mac,
mp3readwrite/lame.maci,
mp3readwrite/mpg123.maci,
mp3readwrite/mp3info.glnx86,
mp3readwrite/mp3info.mac,
mp3readwrite/mp3info.maci,
mp3readwrite/mp3read.m,
mp3readwrite/mp3write.m,
mp3readwrite/mpg123.exe,
mp3readwrite/mpg123.glnx86,
mp3readwrite/mpg123.mac,
mp3readwrite/mp3info.exe
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (11)
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&gt;, 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

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.

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
mp3 Dan Ellis 22 Oct 2008 08:59:26
mpeg audio Dan Ellis 22 Oct 2008 08:59:26
mp3 chetan 23 Oct 2009 01:00:41
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com