Playing a sound and then stopping it
    조회 수: 4 (최근 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 I/O and Waveform Generation에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!