Using audioread to read a sequence of files and then combine
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am am trying to read all wav files within a folder and then combine those files. I understannd audioread and audiowrite. I am stuggling to automate the processing of a sequence of files within a folder so that I only have to change the dirin name and can move to the next folder. The code here obviously doesn't work but trying to demonstrate what I want to do.
DirIn = 'C:\Users\24hr sound analysis\17';
eval(['filelist=dir(''' DirIn '/*.wav'')'])
for i = 1:length(filelist);
[f(i),fs] = audioread(strcat(DirIn,'/',filelist(i).name)); % read in wav file
end
combined = [f1;f(i)];
audiowrite('combined.wav',combined, fs)
0 comentarios
Respuestas (1)
Stephen23
el 28 de Jun. de 2021
Editada: Stephen23
el 28 de Jun. de 2021
Do NOT use EVAL for trivial code like this.
Use FULLFILE instead of concatenating text together.
P = 'C:\Users\24hr sound analysis\17';
S = dir(fullfile(P,'*.wav'));
for k = 1:numel(S)
F = fullfile(P,S(k).name);
[S(k).data,fs] = audioread(F);
end
M = vertcat(S.data); % comma-separated list
audiowrite('combined.wav', M, fs)
1 comentario
Ver también
Categorías
Más información sobre Audio and Video Data 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!