Generating pure tone and noise
47 views (last 30 days)
Show older comments
Hi, I want to generate 200 ms 950- 1050 Hz noise with rise/ fall time of 10 ms and a 1000 Hz , 25 ms pure tone with 10 ms rise/ fall time with 10 dB SNR and ISI of 20 ms
and fs= 44100
can any one help me please
0 Comments
Accepted Answer
Shae Morgan
on 7 Aug 2020
Edited: Shae Morgan
on 7 Aug 2020
See here for an excellent solution to generating your noise from one of your previous questions:
You can use the code from the previous answer I gave you to add a rise-fall time for 10 ms and the other stimulus.
the 10 dB SNR should also be the same. Example below.
%set-up parameters
fs=44100; %CD quality - also conveniently divisible by 30 and 25
stim_dur=.025; %duration of puretone in seconds
noise_dur=.200; %duration of noise in seconds
ISI_dur=.020; %ISI duration in seconds
ramp_dur=.010; %ramp duration in seconds
t=0:1/fs:stim_dur-1/fs;
f=1000;
%create noise
nsamples = floor(noise_dur*fs);
noise_all_Hz = randn(nsamples,1);
noise = bandpass(noise_all_Hz,[950 1050],fs);
noise=noise';
%create 1000 Hz tone
xt=sin(2*pi*f*t);
%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];
w_on_noise = [w1 ones(1,length(noise)-length(w1))];
w_off_noise = [ones(1,length(noise)-length(w2)) w2];
%ramp stimuli
noise_ramped = noise.*w_on_noise.*w_off_noise;
xt_ramped = xt.*w_on_xt.*w_off_xt;
% scale
rms_xt_ramped=rms(xt_ramped); %check the average intensity of the ramped 500 Hz signal
amp_10dB=10^(-10/20)*rms_xt_ramped; %find the new amplitude that is 10 dB lower
%normalize the xt2_ramped stimulus and then scale to -10 dB
noise_ramped_norm=noise_ramped./rms(noise_ramped);
noise_ramped_10dB=noise_ramped_norm.*amp_10dB;
%check
rms_noise_ramped=rms(noise_ramped_10dB);
20*log10(rms_xt_ramped/rms_noise_ramped)
%generate ISI
ISI=zeros(ISI_dur*fs,1);
%final stimulus
out=[noise_ramped_10dB';ISI;xt_ramped'];
plot(out)
sound(out,fs)
11 Comments
More Answers (0)
See Also
Categories
Find more on DTMF in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!