Skip to content

Instantly share code, notes, and snippets.

@y8s
Last active February 5, 2022 22:28
Show Gist options
  • Save y8s/c032f3a2ba12504eff5f0184f0dec7d1 to your computer and use it in GitHub Desktop.
Save y8s/c032f3a2ba12504eff5f0184f0dec7d1 to your computer and use it in GitHub Desktop.
example camilladsp config for pi zero with two usb sound cards using alsa multi
#The UGreen 80864 usb dongle uses the 32bit/384khz capable ALC4030
#but changes product id depending on whats in the jack.
#this helps keep that name consistent. Future version may use serial number.
SUBSYSTEM!="sound", GOTO="my_usb_audio_end"
ACTION!="add", GOTO="my_usb_audio_end"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0/sound/card?", ATTR{id}="Ugreen_CM"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/sound/card?", ATTR{id}="Ugreen_RT"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/sound/card?", ATTR{id}="Ugreen_RT"
LABEL="my_usb_audio_end"
SUBSYSTEM!="sound", GOTO="pa_naming_end"
ACTION!="change", GOTO="pa_naming_end"
KERNEL!="card*", GOTO="pa_naming_end"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.1/1-1.1:1.0/sound/card?", ENV{PULSE_NAME}="Ugreen_CM"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/sound/card?", ENV{PULSE_NAME}="Ugreen_RT"
DEVPATH=="/devices/platform/soc/20980000.usb/usb1/1-1/1-1.4/1-1.4:1.0/sound/card?", ENV{PULSE_NAME}="Ugreen_RT"
LABEL="pa_naming_end"
devices:
adjust_period: 10
capture:
avoid_blocking_read: false
channels: 2
device: hw:Loopback,1,0
format: S32LE
retry_on_error: false
type: Alsa
capture_samplerate: 0
chunksize: 1024
enable_rate_adjust: false
enable_resampling: false
playback:
channels: 4
device: multicard
format: S16LE
type: Alsa
queuelimit: 4
resampler_type: BalancedAsync
samplerate: 44100
silence_threshold: 0
silence_timeout: 0
target_level: 0
filters:
LR HP 4O:
parameters:
freq: 3000
order: 4
type: LinkwitzRileyHighpass
type: BiquadCombo
LR LP 4O:
parameters:
freq: 3000
order: 4
type: LinkwitzRileyLowpass
type: BiquadCombo
Tweetblast:
parameters:
freq: 5000
gain: 6
slope: 6
type: Highshelf
type: Biquad
low shelf:
parameters:
freq: 1000
gain: 6
slope: 6
type: Lowshelf
type: Biquad
mixers:
to4chan:
channels:
in: 2
out: 4
mapping:
- dest: 0
mute: false
sources:
- channel: 0
gain: 0
inverted: false
mute: false
- dest: 1
mute: false
sources:
- channel: 1
gain: 0
inverted: false
mute: false
- dest: 2
mute: false
sources:
- channel: 0
gain: 0
inverted: false
mute: false
- dest: 3
mute: false
sources:
- channel: 1
gain: 0
inverted: false
mute: false
pipeline:
- name: to4chan
type: Mixer
- channel: 0
names:
- LR HP 4O
- Tweetblast
type: Filter
- channel: 1
names:
- LR HP 4O
- Tweetblast
type: Filter
- channel: 2
names:
- LR LP 4O
- low shelf
type: Filter
- channel: 3
names:
- LR LP 4O
- low shelf
type: Filter
# create a virtual four-channel device with two sound devices:
# This is in fact two interleaved stereo streams in
# different memory locations, so JACK will complain that it
# cannot get mmap-based access. see below.
pcm.multicard {
type multi;
slaves.a.pcm "hw:Ugreen_CM";
slaves.a.channels 2;
slaves.b.pcm "hw:Ugreen_RT";
slaves.b.channels 2;
bindings.0.slave a;
bindings.0.channel 0;
bindings.1.slave a;
bindings.1.channel 1;
bindings.2.slave b;
bindings.2.channel 0;
bindings.3.slave b;
bindings.3.channel 1;
}
# JACK will be unhappy if there is no mixer to talk to, so we set
# this to card 0. This could be any device but 0 is easy.
ctl.multicard {
type hw;
card 3;
}
# This creates a 4 channel interleaved pcm stream based on
# the multi device. JACK will work with this one.
pcm.multicard2 {
type route;
slave.pcm "multicard";
slave.channels 4;
ttable.0.0 1;
ttable.1.1 1;
ttable.2.2 1;
ttable.3.3 1;
}
# see above.
ctl.multicard2 {
type hw;
card 3;
}
#
# Place your global alsa-lib configuration here...
#
#
pcm.!default {
type plug
slave.pcm "camilladsp"
}
pcm.camilladsp {
# Use the ALSA plug-in "plug" for rate-/format-conversion.
type plug
# Forward the audio stream to the ALSA loopback-device
slave {
pcm {
# Direct hardware access
type hw
# Loopback card name
#
# Has to match "id" in the options of the snd-aloop module
card "Loopback"
# Loopback device ID
device 0
# Number of audio channels
#
# Has to match the number of channels in music player app
# and in the CamillaDSP input configuration
channels 2
# Format of audio stream
#
# Has to match the format defined in the
# of the CamillaDSP input configuration
format "S32_LE"
# Sampling-rate of audio stream
#
# Has to match the sampling-rate defined in the
# CamillaDSP configuration
rate 44100
}
}
}
ctl.!default {
type hw
card "Loopback"
}
# Create an ALSA default control-device for the ALSA loopback-device.
ctl.camilladsp {
# Direct hardware access
type hw
# Loopback card name
#
# Has to match "id" in the options of the snd-aloop module
card "Loopback"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment