sound file - out of memory

1 Ansicht (letzte 30 Tage)
Alon
Alon am 15 Apr. 2014
Kommentiert: Walter Roberson am 15 Apr. 2014
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

Antworten (1)

Walter Roberson
Walter Roberson am 15 Apr. 2014
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 Kommentare
Alon
Alon am 15 Apr. 2014
what do you mean portions of file? do I need to read using a loop?
Walter Roberson
Walter Roberson am 15 Apr. 2014
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by