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
i get the same problem as Onno reported with mac 10.6.8 and Version R2011a, although permissions are correct.
I am thinking: Maybe there is an issue with the options of the system command which are passed with the cmd argument at line 371 of the mp3read.m, because they are not permitted to be run from other than internal programs?
If anybody has an idea, please share! I am gonna try it under windows us well to see if the same comes up...
Regarding the error with mysystem(cmd):
The cmd variable defines how the mp3info/mpg123 is called on your machine. I got the mp3read working by changing the corresponding lines (somewhere around line 180 and 312 in the code) to:
I'm using this on a 65-bit Ubuntu (10.04.4 LTS) and I keep on getting the following error when I run the demo file:
??? Error using ==> mp3write>mysystem at 168
unable to execute
--quiet -h "/tmp/tmp632.wav" "piano.mp3"
No such file or directory
Error in ==> mp3write at 156
Error in ==> demo_mp3readwrite at 45
I'm certain that this is because I'm missing the lame.glnxa64 file for 64 bit version.
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?
01 Aug 2008
I can recommend this program! IT worked very good. Thanks
16 Apr 2008
This is a good tools
14 Apr 2008
I tried it and it worked great right away. Nice program!
21 Feb 2008
15 Jan 2008
It doesn't seem to work with mp3's downloaded from itunes. Does the AAC encoding have anything to do with this?
18 Aug 2007
great i am very thankful to you
31 Jul 2007
23 Jul 2007
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.
19 Feb 2007
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.
19 Feb 2007
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.
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
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: