[AudioI] How-to play independent single channels?

Matt Flax matt at audioinjector.net
Tue Jul 20 21:38:35 UTC 2021


Hi Ian,

 

One way to split multichannel soundcards into sub-devices is to use the bindings functionality provided by ALSA's route plugin. It is likely however that the dmix plugin is required as well to enable the same slave soundcard to be opened many times at once.

 

The page listed below is also similar to this ALSA page from the alsa wiki :

 

https://alsa.opensrc.org/Splitting_front_and_rear_outputs_.asoundrc

 

My solution which I tested on my desktop multichannel system allows me to play a single channel file like so to channels 3 and 0 at the same time :

 

aplay -Dch2 /tmp/tone.wav &
 

 

aplay -Dch0 /tmp/tone.wav

 

====== Begin ~/.asoundrc (extend for pcm.ch5 onwards) ===============

 

pcm.dshare {
     type dmix
     ipc_key 2048
     slave {
                 pcm "hw:0"
                 #rate 48000
                 #period_time 0
                 #period_size 1024
                 #buffer_size 8192
                 channels 8
     }
     bindings {
         0 0
         1 1
         2 2
         3 3
         4 4
         5 5
         6 6
         7 7
     }
 }
 
 pcm.ch0 {
     type plug
     slave {
         pcm "dshare"
         channels 8
     }
     ttable.0.0 1
 }
 
 pcm.ch1 {
     type plug
     slave {
         pcm "dshare"
         channels 8
     }
     ttable.0.1 1
 }
 
 pcm.ch2 {
     type plug
     slave {
         pcm "dshare"
         channels 8
     }
     ttable.0.2 1
 }
 
 pcm.ch3 {
     type plug
     slave {
         pcm "dshare"
         channels 8
     }
     ttable.0.3 1
 }
 
 pcm.ch4 {
     type plug
     slave {
         pcm "dshare"
         channels 8
     }
     ttable.0.4 1
 }
 

 

===============================
 

 
On 21/7/21 12:27 am, Ian Crawford via People wrote:
 
 
I’m trying to use Python to play simultaneous separate audio files through *individual channels on a single audio device* (either the built in RPi audio output, or an Octo card). For example, playing two mono files at the same time, one in the left channel, one in the right independent of each other.
 
 There are a bunch of Python packages out there that use audio I/O libraries such as PortAudio to play files, and PortAudio for example allows you to pick specific channels for playback in some situations, but not for Raspberry Pi.
 
 It is trivial to play a single sound file on all channels at once  but being able to specifically pick which channels to send to is proving extremely challenging.
 
 I'm also trying to configure the ALSA audio framework to treat the channels of a single
 device as multiple separate (virtual) devices - (as described here for example:
 https://bootlin.com/blog/audio-multi-channel-routing-and-mixing-using-alsalib/)
 but the instructions in that blog are not clear - I’m having a bit of difficulty figuring out the complete configuration to put in the asound.conf file. (If anyone thinks they’d be able to assist me to

 make sense of asound syntax, I’d be very happy!)
 
 Has anyone attempted parallel/thread-driven playback of different audio files on different channels on a RPI’s audio device?
 

 
 
Tanks -
 
Ian
 
 
 
 




 

-- 
Checkout the community email list :
https://lists.audioinjector.net/mailman/listinfo/people

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.audioinjector.net/pipermail/people/attachments/20210720/1667170b/attachment.htm>


More information about the People mailing list