使用ALSA API记录每个频道

问题描述 投票:0回答:2

我使用的是PlayStation Eye,已插入树莓派。我让Raspberry Pi识别了PSEye的内置麦克风阵列,可以使用

对输入电平进行采样
arecord -vv /dev/null -r 16000 -f S16_LE -c 4 -D iec958:CARD=CameraB409241,DEV=0 /dev/null < /dev/null

现在显然这显示了所有4个通道的电平总和。我想做的是分别记录每个频道。是否可以使用ALSA API?

我已经浏览过此http://www.alsa-project.org/alsa-doc/alsa-lib/pcm.html

并看了看这个http://www.linuxjournal.com/article/6735?page=0,2

但是我似乎都没有。我想这也类似于在ALSA上对立体声麦克风的两个通道进行采样。最终,我希望能够在特定的时间点从每个麦克风采样dB。

audio signal-processing raspberry-pi alsa pulseaudio
2个回答
1
投票

要读入每个通道的单独缓冲区,请将SND_PCM_ACCESS_RW_INTERLEAVED替换为SND_PCM_ACCESS_RW_NONINTERLEAVED,并将snd_pcm_readi替换为snd_pcm_readn


0
投票

如果您想将每个频道录制到独立的音频文件中,则可以使用此应用程序:

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

它需要编译,在这里描述:https://lists.audioinjector.net/pipermail/people/2020-March/000028.html

要使用该应用程序,请指定基本文件名和扩展名,例如:ALSACaptureSplitter /tmp/test wav

它可以录制成许多不同的音频文件格式。

您可以使用选项来更改设备,指定记录时间,频道数等。这是应用程序打印出来的帮助:

     ./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 
© www.soinside.com 2019 - 2024. All rights reserved.