geoffreybennett/alsa-scarlett-gui

Virtual audio channels like in windows / macos

Closed this issue · 9 comments

Confirmation

  • I confirm that I have read the FAQ.

Issue Category

Please select the category that best describes your issue:

  • Help Request
  • Bug Report
  • Feature Request

Environment Details

Please provide the following details about your environment.

Linux Distribution and Version

  • Distribution: Parrot Security
  • Version: 6.0 (lorikeet)

Kernel Version

  • Kernel version: 6.5.0-13parrot1-amd64

Focusrite Interface Series and Model

  • Series: Scarlett 3rd gen
  • Model: 18i8

Audio System

  • PulseAudio
  • JACK
  • PipeWire

Issue Description

In windows there's an option to "expose" all the available virtual channels to the windows sound control.
This way I'm able to select which virtual channel an application should output it's sound to. E.g spotify into "Scarlett 18i8 channel 7/8" and FL Studio into "scarlett 18i8 channel 5/6" which I can then route in the software to a specific hardware output into my behringer mixer.

It would be very helpful if this program got such an option as well.

Hi @jeffreydereus,

alsa-scarlett-gui only deals with controlling the settings on the interface itself, nothing to do with audio from the Linux application perspective (that's handled by ALSA/PulseAudio/JACK/PipeWire).

PulseAudio already has a facility to create virtual sound cards with the Module Remap Sink and module-remap-source modules.

Let me know if you need assistance with that and I'll write up an example.

Regards,
Geoffrey,

Hi @geoffreybennett,

Thanks for your reply! I couldn’t figure it out with the pulseAudio module and then realised that the scarlett software had something similar already, hence the question.

if you could write up an example that’d be super helpful!
Main part that I couldn’t figure out was giving the sink a name, for some reason it kept defaulting to “Null sink” or something like that and how to then link it to the configurable I/O in alsa-scarlet-gui

@jeffreydereus try pipewire -- it's awesome!
There's also pipewire-pulseaudio, pipewire-jack for compatibility with PA/JACK.

In an audio software, keep the default options (system / capture and system / playback). Here's I'm using Bitwig:
image

Then, install qpwgraph, which is a patchbay for everything audio/midi:
image

As you can see, Bitwig requested two audio inputs, and you can plug in whatever source available in your system, or add multiple connections so that pipewire will mix it for you:

image

^^ here, both the mic, and ADAT input 3/4 are mixed and sent to Bitwig.

btw: if you're seeing nonsense like "Scarlett 7.1 surround system" with FL, FR, ... even a Subwoofer channel, switch the audio profile to "Pro Audio", and it shall expose the real names :)

I find this setup particularly useful for software that doesn't support channel selection and defaults to "first N channels" (Audacity!)

@yatli

Thanks for your suggestion!

However for now I wanna try and get it working without installing any additional packages as my use case isn't quite for using it with any music creation programs.
I will keep it in mind though and might try it in a couple months.

Hi @jeffreydereus,

Sorry for the delay. I don't have Parrot Security, but I've got Mint which also uses PulseAudio and this worked for me...

In pavucontrol go to Configuration and select "Analogue Surround 7.1 Output + Multichannel Input".

Get the PulseAudio sink name for your output:

pactl list sinks short | grep Scarlett

Should show something like:

3       alsa_output.usb-Focusrite_Scarlett_18i8_USB_XXXXXXXXXXXXXX-00.analog-surround-71        module-alsa-card.c      s32le 8ch 44100Hz       RUNNING

It's handy to pull that sink name out (that's the thing beginning alsa_output...) and save it in a shell variable for later:

SINK=$(pactl list sinks short | grep Scarlett | cut -f2)
echo $SINK

Then use the module-remap-sink module to create a virtual output:

pactl load-module module-remap-sink \
  sink_name=output-1-2 \
  sink_properties=device.description=output-1-2 \
  master=$SINK \
  channels=2 \
  remix=no \
  master_channel_map=front-left,front-right \
  channel_map=left,right

Check in pavucontrol and you'll see a new output available.

Update the above replacing 1-2 with 3-4, 5-6, 7-8, and replacing front-left,front-right with:

  • front-center,lfe (3-4)
  • rear-left,rear-right (5-6)
  • side-left,side-right (7-8)

You could then put this in a shell script like:

#!/bin/bash

function load_remap_module() {
  local SINK=$1
  local PAIR=$2
  local MAP=$3

  pactl load-module module-remap-sink \
    sink_name="output-$PAIR" \
    sink_properties=device.description="output-$PAIR" \
    master="$SINK" \
    channels=2 \
    remix=no \
    master_channel_map="$MAP" \
    channel_map="left,right"
}

DEVICE_NAME="Scarlett"
SINK=$(pactl list sinks short | grep "$DEVICE_NAME" | cut -f2)

load_remap_module "$SINK" "1-2" "front-left,front-right"
load_remap_module "$SINK" "3-4" "front-center,lfe"
load_remap_module "$SINK" "5-6" "rear-left,rear-right"
load_remap_module "$SINK" "7-8" "side-left,side-right"

Or instead of a shell script doing it on-demand, you could add lines like this to your ~/.config/pulse/default.pa file to make PulseAudio load those modules when it starts:

.include /etc/pulse/default.pa

load-module module-remap-sink sink_name=output-1-2 sink_properties=device.description=output-1-2 master=alsa_output.usb-Focusrite_Scarlett_18i8_USB_XXXXXXXXXXXXXX-00.analog-surround-71 channels=2 remix=no master_channel_map=front-left,front-right channel_map=left,right
[...etc...]

I hope this helps you! Note that the above actually has nothing to do with Scarlett interfaces specifically but is applicable to configuring PulseAudio for any multi-channel audio interface that uses the default channel map.

The Scarlett-specific thing is to now note the outputs 1-8 correspond to the 8 PCM Outputs in alsa-scarlett-gui shown in the Routing window:

image

The Scarlett 3rd Gen 18i8 is a little unusual because despite the name "18i8" which implies 18 inputs and 8 outputs, it actually has 10 hardware outputs! But you can't have something independent going to all 10 outputs, something has to miss out or be doubled up:

image

  • Analogue 1: Line 1 Out (Monitor L)
  • Analogue 2: Line 2 Out (Monitor R)
  • Analogue 3: Line 3 Out (Alt Monitor L)
  • Analogue 4: Line 4 Out (Alt Monitor R)
  • Analogue 5: Headphone 1 Left
  • Analogue 6: Headphone 1 Right
  • Analogue 7: Headphone 2 Left
  • Analogue 8: Headphone 2 Right

Good luck and let me know if you have any questions!

Regards,
Geoffrey.

@geoffreybennett

Thanks! This seems to work, only issue I now have is that pulse audio doesn't save which applications made use of which virtual output.

Do you by chance have a solution to that as well?

Hi @jeffreydereus,

That's great news that the virtual outputs work!

Unfortunately I don't know why PA isn't remembering your output device selection. When I select a different output for an application in pavucontrol on the Playback tab, the selection is remembered. You might want to try asking in a forum for PulseAudio support, maybe start here: https://www.freedesktop.org/wiki/Software/PulseAudio/

Another thing you could try is setting the PULSE_SINK environment variable to select the output device as per https://www.freedesktop.org/wiki/Software/PulseAudio/FAQ/

Regards,
Geoffrey.

I also found this which (as I read it) says that the stream-restore module should just do what you want. Maybe you don't have that module loaded? Maybe you have the restore_device=false setting set? Maybe the software you're using selects the stream itself? Maybe the software you're using does something to make PA think it's a new stream, not the same stream as before?
https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/DefaultDevice/

@geoffreybennett

Thanks for checking! I'll see if I can fix it with the links you provided.

Regards,
Jeffrey