- why you say that we take 5 samples while y and z are vectors of 4 samples
- I suppose it's a typo but I guess y3= [x3 x2 x4 x5] is wrong and should be y3= [x3 x4 x5 x6]
- the resulting vector is about 4 times longer than the input vector but that's normal as each x vaues get's replicated multiple times in the output (z)
Audio signal reading and manipulation
10 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Lane Smith
el 18 de Nov. de 2021
Comentada: Mathieu NOE
el 19 de Nov. de 2021
I have an audio file that i read.
I then want to take the first 5 samples and store them as a seperate array.
eample
[x,f] = audioread('speech.wav');
y1 = [x1 x2 x3 x4]
y2 =[x2 x3 x4 x5]
y3= [x3 x2 x4 x5]
yn = [ ect ]
this showing that array y1 has sample 1,2,3,4
array y2 has sample 2,3,4,5
ect.
i then want to make a loop that will effect all arrays
take array y1 and make it change the sample
array z1 = [x3 x2 x4 x1]
array z2 = [x4 x3 x5 x2]
ect
then comple all of the z1 arrays into a new audio file and play is
NS = [z1 z2 z3 z4 z5 z6 z7 ect...]
then play it
sound(NS,f)
ANY IDEAS ON HOW TO MAKE IT
0 comentarios
Respuesta aceptada
Mathieu NOE
el 19 de Nov. de 2021
hello
this is my code but there are a few open questions
clc
clearvars
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load signal
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% data
[signal,Fs] = audioread('test_voice_mono.wav');
[samples,channels] = size(signal);
dt = 1/Fs;
time = (0:samples-1)*dt;
% extract four samples buffers with one sample shift
shift = 1; % nb of samples shift between successive buffers
buffer = 4; % nb of samples in one buffer
N = fix((samples-buffer)/shift +1);
z_all = [];
for ci=1:N
start_index = 1+(ci-1)*shift;
stop_index = min(start_index+ buffer-1,samples);
y =signal(start_index:stop_index,:); % 4 contiguous samples (y1 = [x1 x2 x3 x4])
% flip values so that it becomes : z1 = [x3 x2 x4 x1]
ind = [3;2;4;1];
z = y(ind);
% concatenate all z vectors
z_all = [z_all; z];
end
% audiowrite('out.wav',z_all,Fs);
sound(z_all,Fs)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Digital Input and Output 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!