sound file - out of memory

1 次查看(过去 30 天)
Alon
Alon 2014-4-15
Hello, I wrote a code loading several sound files and viewing their frequency/time domains. The code works well with a sound files less than 15/20 seconds. A problem occures when I try to load a sound file that is (for example) 3 minutes. Only loading the samples to a vector makes my 4GB memory to catch up 3.9GB. What can I do to optimize the problem? Thanks

回答(1 个)

Walter Roberson
Walter Roberson 2014-4-15
Increase your RAM (and use a 64 bit operating system).
Or read portions of the data instead of the whole file. For example if you do not care about frequencies below 10 Hz (because they are not audible to humans) then you only need to handle 1/5 of a second of data at a time. 15 seconds of 44 kHz audio is sufficient to resolve down to 3 microhertz.
  2 个评论
Alon
Alon 2014-4-15
what do you mean portions of file? do I need to read using a loop?
Walter Roberson
Walter Roberson 2014-4-15
Yes, you can read using a loop. Have a look at http://www.mathworks.com/help/signal/ref/spectrogram.html and see the parameters it has. Notice the default overlap is half of a window. This suggests that for a window of even width N, you can:
curpos = 1;
start loop
thiswindow = read samples curpos : curpos + N - 1;
process the data in thiswindow
curpos = curpos + N/2;
end loop
as an outline. You can make it more efficient than that, though.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by