3

How can I output 8 different audio channels to 8different speakers simultaneously using a Raspberry Pi 3 and its or any other accessories?

I am using the Wolfram Language, so I have 8 different "audio channels" which I like to feed to 8 independent speakers but I don't know how one can feed more than two speakers. I don't know what hardware I need. I am able to export these audio channels as 8 independent mp3 files if you recommend other programming languages. So the question is, how do I connect 8 independent speakers to my Raspberry Pi and how do I feed those speakers 8 different analog audio signals?

Just brain storming: Could I use a USB hub (1 USB to 8 USB's) and 8 USB-to-audio adapter? If so, how can I feed them using the Wolfram Language or Python?

  • Different or "Independent", that is do you mean reading and decoding multiple independent streams, demultiplexing a single source stream, or outputting the same stream to ten outputs at the same time. – crasic Oct 26 '17 at 0:54
  • I don't have a full answer for you, but you will likely run out of CPU resources to do this on a PI. Your best bet is to produce a multi-channel file and use an output device that can consume multiple channels, E.G. a mixer or receiver. The connection is then S/PDIF or similar digital audio stream. – crasic Oct 26 '17 at 1:26
  • The largest number of channels a GPIO sound card for the Pi can handle is 8 (at the moment - the Ausio Injector Octo). You can find USB cards which can handle more then 8 channels. As far as Wolfram goes, not sure if it supports audio output ... does it ? If not, then save to a multichannel sound file and use something like aplay to play it back. – Matt Oct 26 '17 at 1:35
  • @Matt, 8 would work just fine. I'll update the question from 10 to 8. – Miladiouss Oct 26 '17 at 1:36
  • Do you have a fidelity requirement? 8bit at 8KHZ on a GPIO PWM is one thing, a 48KHZ 24bit sound card is very different – crasic Oct 26 '17 at 1:54
5

This type of problem is actually quite difficult for an embedded device to do. Decoding and multiplexing audio streams in real time is the realm of a dedicated Digital Signal Processor (DSP).

Using 8 Output Devices

aplay -l will list the available audio devices

You best bet is to write your audio data to a raw audio file

Using 8 separate sound cards, you would start each file with a script

aplay -D device1 file1.wav
aplay -D device2 file2.wav
...
aplay -D deviceN fileN.wav

This has certain caveats, the audio is very likely to be poorly synchronized.

Using 1 -8channel Device

What is needed is a single device that can accept an 8 channel stream. This would be a dedicated sound card our receiver that can decode an 8 channel audio stream. An S/PDIF or HDMI connected 7.1 receiver or sound card would likely work.

You would generate a multichannel audio file using ffmpeg, an example of how to do this with 8 mono channels is shown bellow

ffmpeg -i channel1.wav \
       -i channel2.wav \
       -i channel3.wav \
       -i channel4.wav \
       -i channel5.wav \
       -i channel6.wav \
       -i channel7.wav \
       -i channel8.wav \
       -filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a][6:a][7:a]amerge=inputs=8[aout]" \
       -map "[aout]" output.wav

Then you would play this multichannel audio on your device

aplay output.wav

The routing of speakers would be done using cabling from the sound card.

| improve this answer | |
  • Can you elaborate on and provide links to hardware of the second method please? – Miladiouss Oct 26 '17 at 18:16
1

For Wolfram, there are various functions for playing back sound, such as Speak. E.g. Speak["variable"].

For hardware, you can use a GPIO sound card, HDMI audio or a USB sound card to make this happen.

The Audio Injector Octo is the only available GPIO header sound card which can do more then two channels for the Pi. Otherwise there are countless USB sound cards which can do the job. If you have an HDMI audio system which can play 8 channels to 8 speakers then that is another option.

It should be as simple as setting up the sound card, testing it with something like aplay and then using it from Wolfram.

| improve this answer | |
  • I know how to create sound in the Wolfram language. How do I send it to different USB sound cards? – Miladiouss Oct 26 '17 at 3:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.