Jestem nowy w Matlab. Chcę grać sinus przez funkcję dźwięku. Teraz chcę zatrzymać dźwięk, naciskając przycisk na klawiaturze. Czy to możliwe? Myślałem o użyciu „czystego odtwarzania”. Ale nie jestem pewien.
fs=44100; %Sample Frequency
samples=1/fs;
d=10; %Duration
t=0:samples:(d-samples); % time
amp=linspace(0.0001,2,441000); %Increasing the amplitude
input("Please press enter ")
%Definition der Variable "Weiterlaufen" als true für die while schleife
a = true;
while a
disp(" ")
switch input("Chose 1 and press enter to play sound: ");
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
Odpowiedzi:
0 dla odpowiedzi № 1Może być późno; ale clear sound
jest rozwiązaniem tego.