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 tried mp3read() and wavwrite() to process(wavwrite() can set the sampling rate), and I also tried the resample() function. However, if the sampling rate of an audio is smaller than 44.1kHz, after this processing the length of the audio will been shortened, vice versa. For example, a 44kHz 4 minutes audio resampled to 22kHz, it will become 8 minutes. How can I fixed the length of the audio and reample it?
Here is 4 lines of code which:- loads in a wav file. - Gets its sampling frequency (FsOld)- Resamples it to the desired sampling frequency (FsNew)- Saves it as a new wav file at the new sampling frequency.
7fc3f7cf58