Error when selecting single audio frame using audioDeviceReader() and saving to buffer
4 ビュー (過去 30 日間)
古いコメントを表示
fs = 16000; % Define Sampling Frequency
AudioIn = audioDeviceReader(fs);
audioBuffer = dsp.AsyncBuffer(fs);
while true
x = AudioIn(); % Select Single Audio Frame
audioBuffer(1:end-numel(x)) = audioBuffer(nemel(x)+1:end); % Progress Audio Buffer
audioBuffer(end-nemel(x)+1:end) = x; % Add audio Frame to buffer
end
Hi, I am having issues implementing the above section of code.
As I understand it, calling the function audioDeviceReader returns a system object that reads audio samples using an audio input device in real time. One frame of this real time audio signal can be returned in matrix form using the first line within the while loop.
However, this returns the following error message:
Error using audioDeviceReader/setup
PortAudio Error: Unanticipated host error
Error in audioDeviceReader/setupImpl
Does this mean an audio input has not been detected?
Any help with this issue would be greatly appreciated.
0 件のコメント
回答 (1 件)
Morio Nishigaki
2022 年 7 月 27 日
Hello,
I think it's wrong usage of 'dsp.AsyncBuffer'.
Help Center of MathWorks says "AsyncBuffer FIFO Input & Output should be used write/read".
AsyncBuffer FIFO is a special variable, not an array.
For example,
clear;
asyncBuff = dsp.AsyncBuffer;
a=-99:0;
write(asyncBuff,a');% input a to FIFO
b=2:2:200;
write(asyncBuff,b');% add b to FIFO
readOut = read(asyncBuff,200);
figure(1);
plot(readOut);
OK?
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!