Create a time delayed cosine function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a signal that I'm trying to output as sound that looks like this
ts=0.0001; %sampling rate
n=[0:1057]; %number of samples
t7=4.26:ts:5; %time in seconds to play
c4=261.626; %note frequencey
ynote7=cos(2*pi*c4*t7); %cosine function
sound(ynote4,1/ts,16) %plays the sound from 4.26 sec to 5 sec
but the note plays immediately with no time delay, and I have no clue what I'm doing wrong with this
0 commentaires
Réponses (1)
Kai Domhardt
le 8 Fév 2018
Modifié(e) : Kai Domhardt
le 8 Fév 2018
Your signal starts with the cosine wave, you will need to define the signal for 0 sec to 4.26 sec.
ts=0.0001;
freq = 261.626;
amp = 0.1; %in case somebody tries this without checking their speakers.
empty_signal = zeros(1,5/ts)
sound_signal = cos( linspace( 0, 2*pi*freq, (5-4.26)/ts ));
delayed_signal( end-length(signal)+1 : end ) = sound_signal;
sound(delayed_signal * amp, 1/ts)
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!