Generating a click stimuli

4 次查看(过去 30 天)
mohadeseh zamani
mohadeseh zamani 2021-11-22
Hello everybody
I want to generate a sound (a 5 dB sound) with a specefic charictristics ( frequency=250, I=3.1*10^(-12), duration=1) when I run this program no sound generate, but this amplitude can generate 5 dB sound and 5 dB is one of the hearing thresholds of people therefore people can hear it. ( if I increase its amplitude (For example I=1) after that I can hear the sound (it is a click),but I want to generate a click stimuli with this amplitude that it can generate a 5 db sound). In your opinion it is related to the click stimuli and we can not hear a click stimuli like a pure tone??
anyone can help me?? I totally stuck it.
Here is the formula of the dB:
I0=10^(-12) %% reference sound intensity
dB=10*log10(I/I0);
I=3.1*10^(-12);
dB=10*log10((3.1*10^(-12))/10^(-12) )= 4.9136 dB (=~ 5 dB)
clc
clear
close all;
f=250;
P=1;
I=3.1*10^(-12); %% If I increase its amplitude (for example I=1), I can hear but I do not want
%I=1; %% I=1 can generate a audible sound
n=100;
SamplingRate_Hz=44100;
t = 0 :(1/SamplingRate_Hz) : (P/f);
y=I*sin(2*pi*f*t);
xt_ramped = toneburst(SamplingRate_Hz,y);
sound(xt_ramped,SamplingRate_Hz);
figure; plot(t,xt_ramped)
%% Here is the function that is use in this program.
function xt_ramped = toneburst(SamplingRate_Hz,y)
xt =y;
fs=SamplingRate_Hz;
ramp_dur=0.0025; %ramp duration in seconds
%% Check out this ramp
%setup ramp
rampSamps = floor(fs*ramp_dur);
window=hanning(2*rampSamps)'; %hanning window is cosine^2 this will change depending on the kind of ramp you want
w1=window(1:ceil((length(window))/2)); %use the first half of hanning function for onramp
w2=window(ceil((length(window))/2)+1:end); %use second half of hanning function of off ramp
w_on_xt = [w1 ones(1,length(xt)-length(w1))];
w_off_xt = [ones(1,length(xt)-length(w2)) w2];
xt_ramped = xt.*w_on_xt.*w_off_xt;
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by