필터 지우기
필터 지우기

Create musical notes with pauses in between

조회 수: 7 (최근 30일)
Mengjia Lyu
Mengjia Lyu 2021년 1월 5일
편집: Cris LaPierre 2021년 1월 5일
Dear community,
I am interested in creating a simple alarm tone using MATLAB and would like to know how to put various lengths of pauses in between notes.
Currently i have the following. How can i add pauses between the notes 'C' 'd' 'g' 'C' 'd'?
notes={'C' 'c' 'd' 'e' 'f' 'g'}
freq=[523.251 261 294 330.00 349.00 392]
song={'C' 'd' 'g' 'C' 'd' }
dur=[0.125 0.125 0.125 0.06 0.5]

답변 (1개)

Cris LaPierre
Cris LaPierre 2021년 1월 5일
  댓글 수: 10
Mengjia Lyu
Mengjia Lyu 2021년 1월 5일
One more question though: is there a function that can determine the duration of a? If not I would try hardcode it
Cris LaPierre
Cris LaPierre 2021년 1월 5일
편집: Cris LaPierre 2021년 1월 5일
Duration is dependent on the sample frequency, which could be anything. You could try setting the sample frequency rather than defining it as the min of freq.
Try this.
Fs = 8000;
...
for k = 1 : numel(song)
index = ismember(notes, song{k});
t = 0:1/Fs:dur(k);
a=[sin(2 * pi * freq(index) * t)]; % sinusoidal
sound(a,Fs)
pause(dur(k))
end

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Time-Frequency Analysis에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by