5.1 audio output?

Is it possible to output multichannel audio other than stereo from Sonic Pi? (including panning, not just pushing stereo to multiple speakers)

1 Like

How would You wire that ?

Yes! See section 13.3 of the Sonic Pi Tutorial. I haven’t tried it myself, but I suspect the specifics of how channels are mapped to speakers will depend on your sound setup. What OS are you using, and what’s the audio interface? (e.g. I use a Behringer UMC204HD on Arch Linux, which has just two channels.)

As for panning, I’m pretty sure the built-in panning functions only work between the first two audio channels (left and right, by assumption). But you should be able to achieve the same effect by sending audio to other channels and modifying the amp: keywords to adjust levels. If you want the volume to stay constant, there are some small subtleties—see the SuperCollider documentation for some hints.

Good luck, and please let us know how it goes!

2 Likes

I’m currently trying a rpi 4 with raspbian and a cheapo StarTech usb audio device. Raspbian sees the channels on the device and I have output in the speaker-test. I do have some problems where the audio device is occasionally giving speaker test a busy error though, so I may move over to a Mac with whatever mac compatible 5.1 audio device I can locate. I’d love to stay on the Rpi and run the project headless (this is for an art installation), so maybe I should look for a more dependable audio interface.

I’ll keep you posted as I experiment.

1 Like

On Linux with Jack or Pipewire backends you can route up to 16 channels coming from SupperCollider. In the Sonic Pi script use the sound_out or sound_out_stereo fx, I would think this is the same on Raspberry Pi if you install Jack and QJackCtl?:

    with_fx :sound_out_stereo, output: 3 do
      ...
    end
    
    with_fx :sound_out_stereo, output: 5 do
      ...
    end
    
    with_fx :sound_out_stereo, output: 7 do
      ...
    end

On my system routing looks like this:

Schermafdruk_2023-02-23_15-20-02

Where output 1 and 2 are the default, with_fx :sound_out_stereo, output: 3 sends the output to 3 and 4 and so on.

So it will still be mono going to one channel or stereo going to 2 channels, no true surround sound.

1 Like

This is very helpful! I’m not playing anything from a 5.1 mix down so just playing to individual mono lines out is fine for me.