필터 지우기
필터 지우기

sound file - out of memory

조회 수: 1 (최근 30일)
Alon
Alon 2014년 4월 15일
댓글: Walter Roberson 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