Matlab shuts down during loop using audiowrite

4 vues (au cours des 30 derniers jours)
Catherine
Catherine le 26 Fév 2024
Commenté : Catherine le 27 Fév 2024
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

Réponses (1)

Walter Roberson
Walter Roberson le 26 Fév 2024
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 commentaires
Catherine
Catherine le 26 Fév 2024
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 le 27 Fév 2024
Updated to 2023b and same issue persists. If anyone has other ideas of getting audiowrite to close the files, please let me know.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Startup and Shutdown dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by