question about generate a toneburst ( sound) in every ear
4 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2021-8-12
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.
.
更多回答(1 个)
Dave B
2021-8-12
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)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!