question about generate a toneburst ( sound) in every ear
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
mohadeseh zamani
el 12 de Ag. de 2021
Comentada: mohadeseh zamani
el 2 de Sept. de 2021
Hello everybody, I am trying to generate a toneburst in either left and right ear for example if f=250 Hz and duration of time that sound is produced in the ear is 1 seconds and the distance between the two sounds is 4 second ( first sound in the left ear and the right sound in the right ear) my problem is that generating sound in left and right ear if you know it please help me I really neeed this part.
0 comentarios
Respuesta aceptada
Star Strider
el 12 de Ag. de 2021
Try this:
Fs = 44100; % Sampling Frequency
Fc = 250; % Tone Frequency
durn = 1; % Duration (Sec)
t = linspace(0, durn*Fs-1, durn*Fs)/Fs; % Time VEctor
s = sin(2*pi*Fc*t); % Generate Signal
Fn = Fs/2;
L = numel(t);
N = 2^nextpow2(L);
FTs = fft(s,N)/L;
Fv = linspace(0, 1, N/2+1)*Fn;
Iv = 1:numel(Fv);
figure
plot(Fv, abs(FTs(Iv))*2) % Check Frequency
grid
xlim([0 500])
for k = 1:2
sm = zeros(L,2);
sm(:,k) = s;
sm(1:5,:)
sound(sm,Fs) % Left Ear First, Right Ear Second
pause(5) % 5-Second Pause
end
Experiment to get different results.
.
Más respuestas (1)
Dave B
el 12 de Ag. de 2021
The sound function accepts a two column matrix for y, the first column corresponds to the left channel, and the second column corresponds to the right channel.
Here's a demo with a 1 second 400Hz sound on the left followed by a 1 second 600Hz sound on the right:
t=linspace(0,1,44100);
f=400;
yleft=sin(t*2*pi*f);
f=600;
yright=sin(t*2*pi*f);
y=zeros(44100*2,2);
y(1:length(yleft),1)=yleft;
y(length(yleft)+(1:length(yright)),2)=yright;
% For visualization
stackedplot(y,"DisplayLabels",["Left" "Right"])
sound(y,44100)
Ver también
Categorías
Más información sobre Audio Processing Algorithm Design 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!