Error when selecting single audio frame using audioDeviceReader() and saving to buffer
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Morio Nishigaki
am 27 Jul. 2022
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 Kommentare
Siehe auch
Kategorien
Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!