PortAudio Error: Unanticipated host error.

14 views (last 30 days)
Chris Chow
Chris Chow on 28 Oct 2016
Answered: Shuvodip Majumdar on 18 Mar 2023
I'm trying to use a digiducer accelerometer on an Ubuntu 16.04 system running Matlab R2012a.
I used H = dsp.AudioRecorder(.....) function and get no errors. But when I subsequently use AUDIO = step(H), I get 'PortAudio Error: Unanticipated host error.' What causes this?
device = '333D01 10595173209464075160919: USB Audio (hw:1,0)';
fs = 22050; % fs = Hz
FrameSize = 1024;
H = dsp.AudioRecorder('DeviceName', device, ...
'SampleRate', fs, ...
'NumChannels', 2, ...
'DeviceDataType', '16-bit integer', ...
'BufferSizeSource', 'Property', ...
'BufferSize', 4096, ...
'QueueDuration', 1, ...
'SamplesPerFrame', FrameSize, ...
'OutputDataType', 'double');
AUDIO = step(H);
On calling this step(H) function, I get the following errors in my Linux terminal:
Expression 'alsa_snd_pcm_hw_params_set_buffer_size_near( self->pcm, hwParams, &bufSz )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1996
Expression 'PaAlsaStreamComponent_FinishConfigure( &self->capture, hwParamsCapture, inParams, self->primeBuffers, realSr, inputLatency )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2646
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2758

Answers (2)

Walter Roberson
Walter Roberson on 28 Oct 2016

Shuvodip Majumdar
Shuvodip Majumdar on 18 Mar 2023
For me this error occured because the audio writer was expecting a sample rate of 45600 Hz, but I was using 48000 Hz. Once I changed the output sample rate to 45600 Hz, the error disappeared.

Categories

Find more on Simulation, Tuning, and Visualization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!