Answers for "sine sweep generator"

0

sine sweep generator

% The following is a matlab script
% Playing the resulting audio will give a click at the start and end because
% the chirp function in matlab does not start and end at 0 so speakers do not start
% from resting position causing a click sound.
% You can declick the audio using an audio editor.

function t = generateSweep(filename, time, f_start, f_end, Fs )
    %Example use: generateSweep('sweep_200-20000.wav', 10, 200, 20000, 48000)
    
    Ts = 1/Fs;
    t = (0 : Ts : time);
    y = chirp(t, f_start, t(end), f_end, 'linear');
    
    figure;
    plot(t,y);
    
    figure;
    pspectrum(y, Fs,'spectrogram', 'TimeResolution',0.5);
    
    audiowrite(filename,y,Fs);
end
Posted by: Guest on September-04-2021

Browse Popular Code Answers by Language