Skip to content

Instantly share code, notes, and snippets.

@PatrickLang
Last active November 12, 2023 04:46
Show Gist options
  • Save PatrickLang/79a3090eea6f2d640179457b5d428134 to your computer and use it in GitHub Desktop.
Save PatrickLang/79a3090eea6f2d640179457b5d428134 to your computer and use it in GitHub Desktop.
Cleaning up Alsa + Pipewire for Focusrite Scarlett series

These are just some notes on how I'm trying to clean up Linux support a bit to make the Focusrite Scarlett 18i8 (gen2) and 2i4 a bit easier to use.

Getting UCM profiles

Currently having issues getting a clean test run on upstream project. See failing history

Going to proceed with trying to label inputs better, make a profile for recording analog & spdif, ignoring ADAT for now

Pipewire policy

I still haven't fully worked through how GNOME sets its defaults, but my hope is to set up a policy so that these interfaces can be used for:

  • default output, with volume configurable in Gnome. Mute it in gnome to get rid of system sounds, firefox, etc
  • JACK apps, such as Renoise

In either case, I'd like to be able to work on music in Renoise+Reaper, without system sounds showing up in the recording

Scarlett 18i8 2nd gen

I have the mixer driver loaded during all of this. I have not tested this device without the mixer driver loaded. The alsa-scarlett-gui page shows how to do this in the prerequisites.

[172458.667696] usb 3-1: New USB device found, idVendor=1235, idProduct=8204, bcdDevice= 6.2f
[172458.667708] usb 3-1: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[172458.667713] usb 3-1: Product: Scarlett 18i8 USB
[172458.667716] usb 3-1: Manufacturer: Focusrite
[172458.667720] usb 3-1: SerialNumber: 00034685
[172461.685937] usb 3-1: Focusrite Scarlett Gen 2/3 Mixer Driver enabled pid=0x8204

Initial State

Here's the initial state from aplay -L . Instead of labelling things surround, I'd like them to be direct and reference the labels on the device itself.

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
sysdefault
    Default Audio Device
pipewire
    PipeWire Sound Server
default
    Default ALSA Output (currently PipeWire Media Server)
sysdefault:CARD=sofhdadsp
    sof-hda-dsp, 
    Default Audio Device
sysdefault:CARD=USB
    Scarlett 18i8 USB, USB Audio
    Default Audio Device
front:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    Front output / input
surround21:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USB,DEV=0
    Scarlett 18i8 USB, USB Audio
    IEC958 (S/PDIF) Digital Audio Output

QJackCtl does not have helpful labels for any pins:

qjackctl screen capture from 18i8

Here's the routing I set up for basic use in alsa-scarlett-gui

Scarlett 18i8 routing pic

It was based off the "Direct" mapping, except I mapped PCM 1 and 2 to both analog out 1 & 2, as well as 3 & 4.

In the alsa-scarlett-gui app, the labels are accurate, but the outputs were a bit confusing.

The output labels seem to be:

  • Analogue 1, 2 - monitor out
  • Analogue 3, 4 - Headphone 1
  • Analogue 5, 6 - Headphone 2
  • S/PDIF 1, 2 - SPDIF

These do not correspond to the Alsa device labels yet. Those are all AUX# . UCM should be able to fix that up.

Scarlett 2i4 2nd gen

initial state

Bus 003 Device 005: ID 1235:8200 Focusrite-Novation Scarlett 2i4 USB

aplay -L output

$ aplay -L
null
    Discard all samples (playback) or generate zero samples (capture)
pipewire
    PipeWire Sound Server
default
    Default ALSA Output (currently PipeWire Media Server)
sysdefault:CARD=sofhdadsp
    sof-hda-dsp, 
    Default Audio Device
sysdefault:CARD=USB
    Scarlett 2i4 USB, USB Audio
    Default Audio Device
front:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    Front output / input
surround21:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    4.0 Surround output to Front and Rear speakers
surround41:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=USB,DEV=0
    Scarlett 2i4 USB, USB Audio
    IEC958 (S/PDIF) Digital Audio Output

qjackctl screen capture from 2i4

Cleaned Up

This shows up clean with each pair of outputs in pavucontrol, qjackctl, GNOME Settings.

$ alsaucm -c hw:1 dump text
Verb.HiFi {
	Comment Default
	Device.Line1 {
		Comment "Line 1-2"
		Values {
			CaptureCTL "_ucm0001.hw:USB"
			PlaybackCTL "_ucm0001.hw:USB"
			PlaybackChannels 2
			PlaybackMixer "_ucm0001.default:USB"
			PlaybackMixerElem "Line 1-2"
			PlaybackPCM "_ucm0001.scarlett2i4_stereo_out:USB,0,0,1"
			PlaybackPriority 200
		}
	}
	Device.Line2 {
		Comment "Line 3-4"
		Values {
			CaptureCTL "_ucm0001.hw:USB"
			PlaybackCTL "_ucm0001.hw:USB"
			PlaybackChannels 2
			PlaybackMixer "_ucm0001.default:USB"
			PlaybackMixerElem "Line 3-4"
			PlaybackPCM "_ucm0001.scarlett2i4_stereo_out:USB,0,2,3"
			PlaybackPriority 100
		}
	}
	Device.Mic1 {
		Comment "Input 1"
		Values {
			CaptureCTL "_ucm0001.hw:USB"
			CaptureChannels 1
			CaptureMixer "_ucm0001.default:USB"
			CaptureMixerElem "Input 1"
			CapturePCM "_ucm0001.scarlett2i4_mono_in:USB,0,0"
			CapturePriority 200
			PlaybackCTL "_ucm0001.hw:USB"
		}
	}
	Device.Mic2 {
		Comment "Input 2"
		Values {
			CaptureCTL "_ucm0001.hw:USB"
			CaptureChannels 1
			CaptureMixer "_ucm0001.default:USB"
			CaptureMixerElem "Input 2"
			CapturePCM "_ucm0001.scarlett2i4_mono_in:USB,0,1"
			CapturePriority 100
			PlaybackCTL "_ucm0001.hw:USB"
		}
	}
}
Verb.Direct {
	Comment "Direct Scarlett 2i4 USB"
	Device.Direct {
		Comment "Direct Scarlett 2i4 USB"
		Values {
			CaptureCTL "_ucm0001.hw:USB"
			CaptureChannels 2
			CapturePCM "_ucm0001.hw:USB"
			CapturePriority 1000
			PlaybackCTL "_ucm0001.hw:USB"
			PlaybackChannels 4
			PlaybackPCM "_ucm0001.hw:USB"
			PlaybackPriority 1000
		}
	}
}

qjackctl cleaned up 2i4 view

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment