I'm trying to go into a file full of .m4a audio files, retrieve each one and use the audioread() for each audiofile and output the result of each one in an array
3 views (last 30 days)
Like the Title says, I'm a new user that is trying to read through each file,modify it, and to write it out to an array.
Currently I have 51 audiofiles in a folder where I want to read the audiofile with
[xc5,Fs] = audioread('C4.m4a');
and then process the audiofile with
xc5_feat = processing(xc5,Fs);
So this would take a while for each file, is there a way to do this to every audiofile in my mainfile and put the result in an array?
Currently I have it saving to another folder but could I make this an array?
Heres the code I currently have but I keep getting an error message that I'll put below.
I have an audioread() but I would also like to add in my function 'processing' into it as well.
Thank you all!
outputFolder = 'C:Desktop\University\School\Fall 2021\Machine Learning\Project\C_sound_files'
for k= 1:51
% OPTION 1: Create a mat filename, and load it into a structure called matData.
matFileName = sprintf('C%d.m4a', k);
matData = audioread(matFileName);
outputFilename = sprintf('C%d.m4a', outputFolder, k);
fprintf('File %s does not exist.\n', matFileName);
%%%%%% THE ERROR MESSAGE %%%%%%%%
Error using save
Unable to write file
Error in Full_audio_read (line 17)
Kiran Felix Robert on 9 Dec 2021
The error message is due to the file name you have created in outputFilename.
Change the line as follows to get a working loop.
outputFilename = sprintf('C%d.m4a',k);