1 (edited by greg 2011-09-20 00:09:51)

Topic: Audio Capture using PortAudio on Chumby8

Hello,

I'm porting a piece of software to chumby. It uses PortAudio as an abstraction layer to playback/capture audio.
I have compiled PortAudio on Chumby 8 (fw version 1.8.2) and compiled my software with the installed gcc toolchain.
Playing back audio works fine.
However, it can't capture audio samples, i.e. portaudio callback is never invoked. I'm capturing audio samples as 16 bits / 1 channel / 44100 Hz.
I'm using portaudio V19 (latest stable svn rev 1647) and the ALSA implementation that goes with fw 1.8.2 (i.e. didn't recompile it).
I did extract the ALSA header files from 1.8.1 from http://files.chumby.com/source/ using alsa-lib_1.0.23.tar.gz so portaudio could compile on chumby (ALSA header files were missing).
Portaudio even compiled with debug output doesn't complain or report issues: it just sits there and callback is not called.
The same code on any other linux distrib (like ubuntu) or embedded flavor (e.g. freescale eval boards) works just fine.

Do you know if something specific needs to be done to enable audio capture/record?

I have noted that when the control panel is NOT stopped, the callback is invoked, however the sample values don't look right: you get a bunch of samples with the same value (e.g. ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180, ffffc180).

Thanks!
Greg

--
additional information, here is the settings of amixer:

numid=2,iface=MIXER,name='Headphone Left Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=105
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=3,iface=MIXER,name='Headphone Right Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=105
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=9,iface=MIXER,name='Headphone Secondary Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=7,step=0
  : values=7,7
  | dBscale-min=-7.00dB,step=1.00dB,mute=0
numid=10,iface=MIXER,name='Headphone ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Headphone Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=105,105
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=11,iface=MIXER,name='Mic Bias'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=17,iface=MIXER,name='ADC High Pass Filter Mode'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Hi-fi'
  ; Item #1 'Voice 1'
  ; Item #2 'Voice 2'
  ; Item #3 'Voice 3'
  : values=0
numid=16,iface=MIXER,name='ADC High Pass Filter Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=18,iface=MIXER,name='Capture Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=2,2
  | dBrange-
0x00000001,0x00000008,0x00000000,0x00000000,0x00000001,0x00000008,0x0000000d,0x00000000,0x00000001,0x00000008,0x00000014,0x00000000,0x00000001,0x00000008,0x0000001d,0x00000000,0xbf0534d0,0xbf0534d5,0xbf0534db,0xbf0534e3,0xbf0534e9,0xbf0534ef,0xbf0534f7,0xbf0534ff,
numid=21,iface=MIXER,name='Capture PGA Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=19,iface=MIXER,name='Capture PGA Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=62,step=0
  : values=50,50
  | dBscale-min=-23.25dB,step=0.75dB,mute=0
numid=20,iface=MIXER,name='Capture PGA ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=8,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=96,96
  | dBscale-min=-72.00dB,step=0.75dB,mute=1
numid=15,iface=MIXER,name='DAC Deemphasis'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'None'
  ; Item #1 '32kHz'
  ; Item #2 '44.1kHz'
  ; Item #3 '48kHz'
  : values=0
numid=14,iface=MIXER,name='DAC x128 OSR Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=13,iface=MIXER,name='Speaker AC Gain'
  ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0
  : values=7
numid=6,iface=MIXER,name='Speaker Left Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=114
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=7,iface=MIXER,name='Speaker Right Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=114
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=5,iface=MIXER,name='Speaker Switch'
  ; type=BOOLEAN,access=rw---R--,values=2
  : values=on,on
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=4,iface=MIXER,name='Speaker Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=114,114
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=12,iface=MIXER,name='Speaker ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on

Re: Audio Capture using PortAudio on Chumby8

Some more information.
The problem seems even more basic.
having amixer configured properly (I think, see below). If I stop the control panel, running arecord, gives an error:

chumby-30-85-a5:~ # arecord -vvvv -D hw:0 -f cd -d10 file.wav
Recording WAVE 'file.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
Hardware PCM card 0 'SILVERMOON WM8961' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 2
  rate         : 44100
  exact rate   : 44100 (44100/1)
  msbits       : 16
  buffer_size  : 22440
  period_size  : 2040
  period_time  : 46258
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 2040
  period_event : 0
  start_threshold  : 1
  stop_threshold   : 22440
  silence_threshold: 0
  silence_size : 0
  boundary     : 1470627840
  appl_ptr     : 0
  hw_ptr       : 0
arecord: pcm_read:1692: read error: Input/output error

(file system is read/write)

Just to be sure, I re-installed the firmware from USB using the latest for chumby 8 (1.8.2, from http://www.chumby.com/help/chumby_8/latest_software ) and performed a factory reset.

Still have the same issue.

How can I use arecord successfully with the control panel stopped? (Note: if I don't stop it, it's able to record / playback fine).





Amixer set up:
chumby-30-85-a5:~ # amixer contents 
numid=2,iface=MIXER,name='Headphone Left Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=110
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=3,iface=MIXER,name='Headphone Right Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=110
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=9,iface=MIXER,name='Headphone Secondary Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=7,step=0
  : values=7,7
  | dBscale-min=-7.00dB,step=1.00dB,mute=0
numid=10,iface=MIXER,name='Headphone ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=1,iface=MIXER,name='Headphone Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=110,110
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=11,iface=MIXER,name='Mic Bias'
  ; type=BOOLEAN,access=rw------,values=1
  : values=on
numid=17,iface=MIXER,name='ADC High Pass Filter Mode'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'Hi-fi'
  ; Item #1 'Voice 1'
  ; Item #2 'Voice 2'
  ; Item #3 'Voice 3'
  : values=0
numid=16,iface=MIXER,name='ADC High Pass Filter Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=18,iface=MIXER,name='Capture Boost Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=3,step=0
  : values=2,2
  | dBrange-
0x00000001,0x00000008,0x00000000,0x00000000,0x00000001,0x00000008,0x0000000d,0x00000000,0x00000001,0x00000008,0x00000014,0x00000000,0x00000001,0x00000008,0x0000001d,0x00000000,0xbf0534d0,0xbf0534d5,0xbf0534db,0xbf0534e3,0xbf0534e9,0xbf0534ef,0xbf0534f7,0xbf0534ff,
numid=21,iface=MIXER,name='Capture PGA Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=19,iface=MIXER,name='Capture PGA Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=62,step=0
  : values=50,50
  | dBscale-min=-23.25dB,step=0.75dB,mute=0
numid=20,iface=MIXER,name='Capture PGA ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on
numid=8,iface=MIXER,name='Capture Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=96,96
  | dBscale-min=-72.00dB,step=0.75dB,mute=1
numid=15,iface=MIXER,name='DAC Deemphasis'
  ; type=ENUMERATED,access=rw------,values=1,items=4
  ; Item #0 'None'
  ; Item #1 '32kHz'
  ; Item #2 '44.1kHz'
  ; Item #3 '48kHz'
  : values=0
numid=14,iface=MIXER,name='DAC x128 OSR Switch'
  ; type=BOOLEAN,access=rw------,values=1
  : values=off
numid=13,iface=MIXER,name='Speaker AC Gain'
  ; type=INTEGER,access=rw------,values=1,min=0,max=7,step=0
  : values=7
numid=6,iface=MIXER,name='Speaker Left Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=119
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=7,iface=MIXER,name='Speaker Right Volume'
  ; type=INTEGER,access=rw---R--,values=1,min=0,max=127,step=0
  : values=119
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=5,iface=MIXER,name='Speaker Switch'
  ; type=BOOLEAN,access=rw---R--,values=2
  : values=on,on
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=4,iface=MIXER,name='Speaker Volume'
  ; type=INTEGER,access=rw---R--,values=2,min=0,max=127,step=0
  : values=119,119
  | dBscale-min=-121.00dB,step=1.00dB,mute=1
numid=12,iface=MIXER,name='Speaker ZC Switch'
  ; type=BOOLEAN,access=rw------,values=2
  : values=on,on

Re: Audio Capture using PortAudio on Chumby8

Hi Greg,

Both the input and output streams go through an SRS audio plugin.  The plugin assumes you're always going to be playing back, so it will block when you record without playing back data.

A permanent solution would be to modify /psp/asound.conf to remove the SRS plugin.  If you're doing audio processing, you'll probably want to do this anyway.  But as a workaround, you can manually specify your recording devices as hw:0,0.

This is the script we run in the factory to verify that the microphone works:

amixer set Capture 85%
amixer set "Capture PGA" 100%
amixer set "Capture PGA" on
amixer set "Capture Boost" 100%
amixer set "Mic Bias" on

arecord -D hw:0,0 -f cd -d 5 > /tmp/pcm1.bin

Re: Audio Capture using PortAudio on Chumby8

Thanks. I was stuck looking at the alsa mixer settings.
Thanks for your quick response.