Question

I'm using a playstation eye, plugged into a raspberry pi. I have the raspberry pi recognising the built in microphone array of the PSEye and I can sample input levels using

arecord -vv /dev/null -r 16000 -f S16_LE -c 4 -D iec958:CARD=CameraB409241,DEV=0 /dev/null < /dev/null

Now obviously this shows the levels for all 4 channels being summed together. What I wish to do is record each channel separately. Is this possible using the ALSA API?

I've looked through this http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

And took a look at this http://www.linuxjournal.com/article/6735?page=0,2

But neither seemed to what I needed. This is also similar to sampling both channels of a stereo mic over ALSA as well I suppose. Eventually I want to be able to sample the dB from each microphone at a specific point in time.

Was it helpful?

Solution

To read into a separate buffer for each channel, replace SND_PCM_ACCESS_RW_INTERLEAVED with SND_PCM_ACCESS_RW_NONINTERLEAVED, and replace snd_pcm_readi with snd_pcm_readn.

OTHER TIPS

If you want to record each channel to independent audio files, then you can use this application :

https://github.com/flatmax/gtkiostream/blob/master/applications/ALSACaptureSplitter.C

It needs to be compiled, which is described here : https://lists.audioinjector.net/pipermail/people/2020-March/000028.html

To use the application specify the base file name and the extension, for example : ALSACaptureSplitter /tmp/test wav

It can record to many different audio file formats.

You can use the options to change the device, specify the recording time, channel count, etc. Here is the help printed out by the application :

     ./applications/ALSACaptureSplitter -h
     ALSACaptureSplitter : An application to capture input and save to 
 independent files.
    Usage:
         ALSACaptureSplitter [options] outFileNamePrefix ext
         e.g. ALSACaptureSplitter [options] /tmp/out wav
         -D : The name of the device : (-D hw:0)
         -c : The number of channels to open, if the available number is less, then it is reduced to the available : (-c 2)
         -t : The duration to sample for : (-t 2.1)
         -r : The sample rate to use in Hz : (-r 48000)
    AUDIO FILE FORMATS:The known output file extensions (output file formats) are the following :
    8svx aif aifc aiff aiffc al amb amr-nb amr-wb anb au avr awb caf cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8 fap flac fssd gsm gsrt hcom htk ima ircam la lpc lpc10 lu mat mat4 mat5 maud mp2 mp3 nist ogg paf prc pvf raw s1 s16 s2 s24 s3 s32 s4 s8 sb sd2 sds sf sl sln smp snd sndfile sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8 ub ul uw vms voc vorbis vox w64 wav wavpcm wv wve xa xi 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top