How to read multiple .wav files and plot them as separate signals?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I would like to read from 10 files which they contain 10 wav files in each, so approximately 100wav files in total. I am trying to read them one by one and then apply some filttering and store the result in a new location but it should have the same name files and wav names as it was in the begging.
so practically take the voices apply some filterring and store them in a different location but in the same way same file names and wav.names audio signal but filltered. I do not care about the filltering I am only affter the read and write.
for example:
file 1:
has inside 10 wav files audio signal, eg1.wav, kle.wav.....lp.wav ( they do not have the same name or similar)
file 2:
has inside 10 wav files audio signal, kx1.wav, kle.wav.....lp.wav ( they do not have the same name or similar)
.
.
file 10
has inside 10 wav files audio signal, eg1.wav, kle.wav.....lp.wav ( they do not have the same name or similar)
I am trying to use the below code:
names = {'Voice1.wav', 'Voice2.wav', 'Voice3.wav', 'Voice4.wav'};
wave = cell(size(names));
fs = cell(size(names));
subplot_cols = 3;
subplot_rows = ceil(numel(names)/subplot_cols);
for i=1:numel(names)
[wave{i},fs{i}]=audioread('sample.wav');
t = linspace(0, (numel(wave{i})-1)/fs{i}, numel(wave{i}));
subplot(subplot_rows,subplot_cols,i)
plot(t, wave);
title(['File: ' names{i}]);
end
but it shows me an error
Error in Assigment (line 60)
plot(t,wave);
Many thanks in advance.
https://uk.mathworks.com/matlabcentral/answers/516853-how-can-i-read-multiple-wav-files-and-plot-them-as-separate-signals#comment_1034872
0 comentarios
Respuestas (2)
Ameer Hamza
el 3 de Oct. de 2020
Editada: Ameer Hamza
el 3 de Oct. de 2020
Check this code
files = dir('file*');
f = figure();
destination_folder = ''; % put location of destimation folder
for i = 1:numel(files)
sub_files = dir([files(i).name '/*.wav']);
mkdir(destination_folder, files(i).name);
for j = 1:numel(sub_files)
nexttile();
[y, Fs] = audioread(sub_files(j).name);
Ts = 1/Fs;
n = numel(y);
t = (0:1:n-1)*Ts;
plot(t, y);
title(sprintf('%s %s', files(i).name, sub_files(j).name));
% process the signal
new_filename = fullfile(destination_folder, files(i).name, sub_files(j).name);
audiowrite(new_filename, y, Fs);
end
end
7 comentarios
Ver también
Categorías
Más información sobre Code Generation and Deployment 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!