Create a time delayed cosine function
조회 수: 5 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Kai Domhardt
2018년 2월 8일
편집: Kai Domhardt
2018년 2월 8일
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)
참고 항목
카테고리
Help Center 및 File 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!