0

How do I configure ALSA's asoundrc file to input and output audio data to two Bluetooth devices? I have tried using the dmix and dsnoop plugins to go about doing this similar to what is shown in the following post: ALSA Api: How to play two wave files simultaneously?. And have looked at the following sources: https://www.alsa-project.org/main/index.php/Asoundrc#Software_mixing, and https://github.com/Arkq/bluez-alsa/wiki/Using-the-bluealsa-ALSA-pcm-plugin. All I want to do is use the arecord and aplay commands to output to these two Bluetooth devices. Any suggestions would truly be appreciated.

When I ran: aplay -D mix_stream /home/pi/Desktop/noise.wav

Error: ALSA lib pcm_direct.c:1809:(_snd_pcm_direct_get_slave_ipc_offset) Invalid type 'bluealsa' for slave PCM

aplay: main:828: audio open error: Invalid argument

Edit: I learned that dmix and dsnoop only work with hardware devices so I'm using the multi plugin instead. However, I'm still experiencing issues with the following command: arecord -D bth-multi -c 2 -r 44100 -f s16_le test.wav. It outputs the following error: ALSA lib bluealsa-pcm.c:763:(_snd_pcm_bluealsa_open) Couldn't get BlueALSA PCM: PCM not found arecord: main:828: audio open error: No such device.

Here is my current asoundrc file which I referenced off of @Arkq on the bluez-alsa github page. Here is the offical link: https://github.com/Arkq/bluez-alsa/issues/379#issuecomment-707309026

pcm.bth-1 {
    type plug
    slave.pcm {
        type bluealsa
        device "FA:D8:78:FB:57:36"
        profile "a2dp"
    }
}

pcm.bth-2 {
    type plug
    slave.pcm {
        type bluealsa
        device "5C:44:3E:54:E0:01"
        profile "a2dp"
    }
}

pcm.bth-multi {
   type plug;
   slave.pcm {
       type multi;
       slaves.a.pcm "bth-1";
       slaves.a.channels 2;
       slaves.b.pcm "bth-2";
       slaves.b.channels 2;
       bindings.0 { slave a; channel 0; }
       bindings.1 { slave a; channel 1; }
       bindings.2 { slave b; channel 0; }
       bindings.3 { slave b; channel 1; }
       master 1
   }
   ttable.0.0 1
   ttable.1.1 1
   ttable.0.2 1
   ttable.1.3 1
}
TristonL
  • 11
  • 4

1 Answers1

0

I think that you missed closing brace (}) of slave.pcm block in pcm.y30. It should look like this:

pcm.y30 {
    type plug
    slave.pcm {
        type bluealsa
        device "FA:D8:78:FB:57:36"
        profile "a2dp"
    }
}
fildaw
  • 11
  • 1
  • Thanks, I did missed that. However, I'm still getting the following error: ALSA lib pcm_direct.c:1809:(_snd_pcm_direct_get_slave_ipc_offset) Invalid type 'bluealsa' for slave PCM aplay: main:828: audio open error: Invalid argument. So I think there is more to it. – TristonL Jul 29 '21 at 16:14
  • Try this configuration: https://pastebin.com/76VmfbYq. ALSA playback device is pcm.final (aplay -D final ...) Source: https://stackoverflow.com/questions/43939191/alsa-how-to-duplicate-a-stream-on-2-outputs-and-save-system-configs – fildaw Jul 30 '21 at 14:31
  • Whenever I use that config file and run the command aplay -D final test.wav. I get the following error: aplay: xrun:1664: read/write error, state = PREPARED. I however did find an alsa config file online that allows me to run the command above and have both Bluetooth headsets play the sound at the same time. I'll post that above. However, it doesn't solve my arecord issue. – TristonL Aug 01 '21 at 01:45