How can I write a large audio file without having to store the whole thing in memory at once?

5 visualizaciones (últimos 30 días)
I am writing a program to process audio, and it runs into OUT OF MEMORY problems when the files are too large. Is there a way to write an audio file piecemeal so that you don't have to store the entire thing in memory at the same time, for instance, by appending to an existing audio file? I looked in the documentation for audiowrite and it did not look promising (by default it overwrites, and there was no clear "append" option that I could see). It is simple enough to read in and process the audio in a buffer-like way, but I cannot figure out how to write the audio using a similar method. I have the signal processing toolbox, if that helps.

Respuestas (1)

Ahmet Cecen
Ahmet Cecen el 9 de Mayo de 2016
Editada: Ahmet Cecen el 9 de Mayo de 2016
I don't believe a piece-wise write exists yet for audio files. Until a better answer shows up, I would suggest:
  1. If your memory issues are caused by whatever processing step you are performing on the audio (such as audio is 300 MB but processing/transform requires 4 GB); then you can simply save the processed audio piece-wise into a -v7.3 matfile, then load it back after to write as audio. Since you are doing the processing piece-wise, this circumvents the memory issue.
  2. If otherwise your files are simply way too large, then for now I would save multiple files, then use a lightweight third party audio merging software.

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!

Translated by