Post "Subliminal" in Matlab

I am trying to sum two signals at the same frequency, one recorded from a microphone and the other, which is its default Matlab sound file, what I intend to do is make them sound at the same time, while I can record and play a wav file. which apparently is not able to add them at the same frequency, for a beginner Im trying to put both signals at the same frequency and the same number or lines

However, my current problem Im having is that I cannot use decimal numbers in the downsample function, so I cannot actually put them at the same frequency using it

So far I already have a transposed matrix of both Y and grabacion , but I really don't understand how to place them at the same frequency and number of lines, so I can add them and then play them as one sound

enter image description here

load handel.mat

filename = 'handel.wav';
audiowrite(filename,y,Fs);
clear y Fs 
   [Y,fs] = audioread('handel.wav');       
sound(Y);
%%
X = X = audiorecorder(8000,8,1);
disp('Inicio de grabacion (5s)')
recordblocking(X, 5);
disp('Fin de Grabacion.');
play(X);
grabacion = getaudiodata(X);     
plot(grabacion,'r-');

%%
Columna_Izquierda = Y(:,1);       
C_I_T  = Columna_Izquierda.'; 

Columna_Derecha = grabacion(:,1);
C_D_T = Columna_Derecha.'; 

      

+3


source to share


1 answer


I think you have confusion about frequency. Fs is the "sampling rate", which is how many sound samples are recorded each second. It does not affect the frequency of the main signal (ignoring dithering).

If you just want to add two sounds together; the first thing you need to do is ensure they are the same length. The handle.mat file is 73113/8192 = 8.92 seconds.

You record for 5 seconds, so you must trim the pre-recorded sample to 5 seconds.

Columna_Izquierda = Y(1:8192*5,1); 

      

If your microphone cannot handle this, change the recording speed to match this frequency. If you are limited to 8000Hz (which I doubt) you can always use interp1 .

X = audiorecorder(8192,8,1);

      



or

grabacion_interp = interp1(1:8000*5, grabacion, 1:8192*5,'spline');

      

You might end up with some overlap using a spline. I haven't looked at sound filtering in a while.

Then the dimensions must match in order for them to be added.

Some corrected codes

load handel.mat

filename = 'handel.wav';
audiowrite(filename,y,Fs);
clear y Fs 
[Y,fs] = audioread('handel.wav');       
sound(Y);

X = audiorecorder(8192,8,1); % Changed sampling rate
disp('Inicio de grabacion (5s)')
recordblocking(X, 5);
disp('Fin de Grabacion.');
play(X);
grabacion = getaudiodata(X);     
plot(grabacion,'r-');

% Truncate handel recording
Y = Y(1:8192*5);

Columna_Izquierda = Y(:,1);       
C_I_T  = Columna_Izquierda.'; 

Columna_Derecha = grabacion(:,1);
C_D_T = Columna_Derecha.'; 

      

0


source







All Articles