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

3 ビュー (過去 30 日間)
Brandon  Madsen
Brandon Madsen 2016 年 5 月 9 日
編集済み: Ahmet Cecen 2016 年 5 月 9 日
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.

回答 (1 件)

Ahmet Cecen
Ahmet Cecen 2016 年 5 月 9 日
編集済み: Ahmet Cecen 2016 年 5 月 9 日
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.

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by