필터 지우기
필터 지우기

Matlab shuts down during loop using audiowrite

조회 수: 1 (최근 30일)
Catherine
Catherine 2024년 2월 26일
댓글: Catherine 2024년 2월 27일
I'm running a loop going through a series of wave files in a folder. The loop calls my audiochange function (a very basic version, still causing the issue, is shown below).
When it gets somewhere between 450-500 files in (depending on the folder I am running this on) - Matlab shuts down with no error messages/logs showing up anywhere. I'm assuming this means I'm swamping the memory.
However, I have monitored task manager, and I also embedded some lines that gave me a 'log' file of the outputs from the function 'memory' - there are no increasing memory use or spikes in either place. I have 16 GB of system memory, with 9 GB available; approximately 3GB are being used by Matlab when it is running this code using R2023a.
My input files are 96kHz, 10 minutes long, 16 bit. It crashes when I try to write out 10 minute files; however when I read/write out 1 minute files - Matlab still shuts down at the exact same input file. When I restart Matlab and start at the input file that crashed - it runs fine for another 450-500 files. There is still around 1TB of space on the drive that I am writing to.
When I comment out the audiowrite line it runs through the whole folder without crashing. Seems like if the issue is loading the variable newWave multiple times with audioread, it should crash, but it doesn't.
I will put in a request with my IT department to update to the latest version of Matlab tomorrow; but curious if there is any other solution if that gives the same result.
recordLength = 10; % this is original wave file duration
fileLength = 10; % this is my output file duration, I have also tried fileLength = 1.
for n = 1:num_files_in_folder % varies per folder
for m = 1:recordLength/fileLength
ssamp = 1+filelength*(m-1);
esamp = min(filelength*m,recordlength);
filename_read = ['<myreadpath\myreadfilename>'];
filename_write = ['<mywritepath\mywritefilename>'];
audiochange(filename_read,filename_write,ssamp, esamp)
end
end
function audiochange(filename_read,filename_write,ssamp, esamp)
[newWave,fs] = audioread(filename_read,[ssamp esamp]);
audiowrite(filename_write,newWave,fs);
end

답변 (1개)

Walter Roberson
Walter Roberson 2024년 2월 26일
I suspect that you are running into a limit on open files -- I suspect that audiowrite() is not closing files.
You could experiment with using
fclose('all')
every 100 files or so. Might work, might not
  댓글 수: 3
Catherine
Catherine 2024년 2월 26일
It got me through another 75 files. I also tried it every 50 files, and every file, but neither of those improved things anymore than the every 100 files did. Thank you for improving things a little.
Catherine
Catherine 2024년 2월 27일
Updated to 2023b and same issue persists. If anyone has other ideas of getting audiowrite to close the files, please let me know.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by