问题
I am currently working on watermarking audio files in Matlab for a mathematics research project. So far I have been able to read wav files using wavread in Matlab. However, because wav files are very large, the resulting data is also large. Therefore, in order to simplify this I would like to know how I would be able to read an mp3 file in Matlab. So far I have only tried to read an mp3 by using dsp.AudioFileReader. However, the resulting data only contains 0's and a few other numbers, which is clearly not the correct data. Would someone please be able to help me? Thank you so much!
回答1:
you can use this code:
hfr = dsp.AudioFileReader('yourfile.mp3');
hplay = dsp.AudioPlayer('SampleRate',sample_rate_here);
while ~isDone(hfr)
audio = step(hfr);
step(hplay, audio);
end
来源:https://stackoverflow.com/questions/17266087/how-to-read-mp3-in-matlab