sound file - out of memory
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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
0 comentarios
Respuestas (1)
Walter Roberson
el 15 de Abr. de 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 comentarios
Walter Roberson
el 15 de Abr. de 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.
Ver también
Categorías
Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!