How to stop an audioDeviceReader recording

2 ビュー (過去 30 日間)
Alessandra Liberti
Alessandra Liberti 2020 年 5 月 27 日
回答済み: jibrahim 2020 年 5 月 28 日
Hyi everyone!
I would like to know if there is a way for stopping an "audioDeviceReader" recording, created using Audio Toolbox.
My code is:
%% Audio
hold on
n=2^11;
subplot(2,1,1)
myMic = audioDeviceReader(44100, n);
myVoice = myMic();
a = plot(2*myVoice);
xlim([0 n])
%% FFT
hold on
dt=1/myMic.SampleRate;
freqs=(abs(fft(myVoice)));
index = 0:n-1;
nu=index/(n*dt);
subplot(2,1,2)
b=plot(nu(1:n/2),abs(freqs(1:n/2)));
ylim([-3 3])
%% CYCLE
try
while 1
myVoice = myMic();
volume = max(abs(myVoice));
a.YData = myVoice;
subplot(2,1,2)
mags = (abs(fft(myVoice)));%*dt/sqrt(2*pi));
b=plot(nu(1:n/2),abs(mags(1:n/2)));
axis([0 10000 0 2])
drawnow
end
catch
disp('a presto')
end
Thanks

採用された回答

jibrahim
jibrahim 2020 年 5 月 28 日
You can release the object to stop it.
release(myMic)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by