% cricket call example for ECE4760 figure(1); clf; clear all; Fs = 44100 ; t = 0:1/Fs:5 ; t_samp = fix(t*Fs) ; song = zeros(size(t)); envelope = zeros(size(t)); chirp_rep = 0.20 ; % chirp repeat interval syl_dur = 0.01 ; % sylable duration syl_rep = 0.02 ; % sylable repeat interval syl_num = 3 ; % sylable count burst_freq = 3000 ; % carrier frequency chirp_rep = fix(0.20*Fs) ; % chirp repeat interval in sample units syl_dur = fix(0.01*Fs) ; % sylable duration in sample units syl_rep = fix(0.02*Fs) ; % sylable repeat interval in sample units % build the on-off waveform chirp_start = mod(t_samp, chirp_rep)==0 ; chirp_start_index = find(chirp_start == 1); for i = chirp_start_index for j = 0:syl_num-1 envelope(i+j*syl_rep:i+j*syl_rep+syl_dur) = 1; end end % make the linear rise and fall of each sylable conv_mask = ones(1,fix(0.004*Fs)); envelope = conv(envelope, conv_mask); % modulate with the envelope song = envelope(1:length(song)) .* sin(2*pi*burst_freq*t) ; plot(t, song, 'r') ; soundsc(song, 44100)