Playing a sound and then stopping it
1 回表示 (過去 30 日間)
古いコメントを表示
Hello everybody ! I am new to Matlab, but i tried some things out and it is really nice. But now to my question. I am generating a sine by playing it through the function sound. While i am generating a sine, the ampltidue is increasing. This means, we perceive the sound louder over time. The duration is about 20 seconds. Now i want to play the sound and then , for example, stop it at 5 seconds. Is it possible ? I (Btw english is not my mother language, sry about that...)
fs=44100; %Sample Frequency
samples=1/fs;
d=20; %Duration
t=0:samples:(d-samples); % time
amp=linspace(0.0001,2,882000); %Increasing the amplitude
input('Please press enter to go on ')
a = true;
while a
disp('')
Enter = input('Chose 1 and press enter to play sound: ');
switch Enter
case 1 %Generating sound with a frequency of 125 Hz
f = 125;
s1 = sin(2*pi*f*t);
y= amp.*s1;
sound(y,fs);
end
end
0 件のコメント
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Audio and Video Data についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!