Skip to content
Snippets Groups Projects
Commit 539ab992 authored by tee's avatar tee
Browse files

initial import

parent f7c8db3a
No related branches found
No related tags found
No related merge requests found
# linuxaudio
Scripts, snippets, little helpers for audio on linux
\ No newline at end of file
scripts, snippets, little helpers etc for audio on linux
## meters
* ebur128 a stereo meter using live fft of ffmpeg
* meterbridge-inputs-all
* meterbridge-pa-sink
* meterbridge-system-inputs
## jack control scripts
These were written to get a reproducible audio setup with specific hardware, working around "user friendly" dysfunctions of the audio system, particularly PA.
Make sure to adapt the amount of input/output ports to your hardware.
These are thought of as commandline alternatives of qjackctl/cadence.
* myjackctl-LP16 start jackd for Cymatic Audio LP-16 Live Player
* myjackctl-MTK start jackd for Soundcraft MTK series
* myjackctl-umc1820 start jackd for umc1820
ebur128 0 → 100755
#! /bin/bash
# Creates a Jack input that displays a EBU R128 meter
if [ ! -z $1 ];
then
ffmpeg -y -f jack -i "$1 ebu r128" -filter_complex '[0] ebur128=video=1:target=-16:gauge=shortterm:scale=relative [v][a]' -map '[v]' -map '[a]' -pix_fmt yuv420p -c:v rawvideo -c:a pcm_s16le -f matroska -an - | ffplay -v 0 -an -autoexit -window_title "$1 ebu r128" -
else
echo "Usage: meter <name>";
fi
#!/bin/sh
foo=$(mktemp /tmp/mtrbrdg-XXXX)
if [ -z "$foo" ] ; then
echo "kaput"
exit
fi
echo -n "meterbridge -t dpm " > $foo
jack_lsp | egrep '(capture|Sink)' | grep -v midi | while read line ; do echo -n \"$line\" ; echo -n " " ; done >> $foo
echo "" >> $foo
chmod +x $foo
echo $foo
sh $foo
rm $foo
#!/bin/sh
meterbridge -t dpm\
"PulseAudio JACK Sink:front-left"\
"PulseAudio JACK Sink:front-right"
#!/bin/sh
meterbridge -t dpm\
"system:capture_1"\
"system:capture_2"\
"system:capture_3"\
"system:capture_4"\
"system:capture_5"\
"system:capture_6"\
"system:capture_7"\
"system:capture_8"\
"system:capture_9"\
"system:capture_10"\
"system:capture_11"\
"system:capture_12"\
"system:capture_13"\
"system:capture_14"\
"system:capture_15"\
"system:capture_16"\
"system:capture_17"\
"system:capture_18"\
"system:capture_19"\
"system:capture_20"\
"system:capture_21"\
"system:capture_22"\
"system:capture_23"\
"system:capture_24"
#!/usr/bin/env bash
# set all sorts of parameters, start jack and deal with pulseaudio.
# there are 2 different ways to have jack and pa running:
# a) jack runs on the external and pa on the internal card
# b) using pulseaudio-module-jack, pa is bridged into jack
# for case a), it makes sense to use pavucontrol to tell pa to
# leave the external card the fuck alone. (config -> device -> OFF)
# for case b), nothing will use the internal card and you need to connect
# the pulseaudio-sink to your preferred hardware outputs.
# 20210325 wotwot and d0
CARD="LP16"
INPUTS="2"
OUTPUTS="18"
usage() {
echo "usage: `basename $0` {start|stop|status}"
}
start_stuff(){
jack_control ds alsa
jack_control dps device hw:$CARD,0
# some devices might work with values as low as 64 (2^n values only)
jack_control dps period 1024
# USB devices are recommended to be set to 3
jack_control dps nperiods 3
jack_control dps rate 44100
jack_control dps midi-driver seq
jack_control eps driver alsa
jack_control eps realtime True
jack_control eps realtime-priority 85
jack_control dps inchannels $INPUTS
jack_control dps outchannels $OUTPUTS
jack_control start
jack_control status
jack_control ep
pacmd suspend true
# scenario a)
pactl unload-module module-jack-sink
pactl unload-module module-jack-source
pacmd set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
# scenario b)
# only enable the sources if you want feedback in the audio system
#pactl load-module module-jack-sink channels=2
#pacmd set-default-sink jack_out
## only enable this if you need pa inputs bridged and if you do, make sure
## they do not cause feedback loops !
##pactl load-module module-jack-source channels=2
##pacmd set-default-source jack_in
#jack_connect "PulseAudio JACK Sink:front-left" "system:playback_15"
#jack_connect "PulseAudio JACK Sink:front-right" "system:playback_16"
#jack_disconnect "PulseAudio JACK Sink:front-left" "system:playback_1"
#jack_disconnect "PulseAudio JACK Sink:front-right" "system:playback_2"
pacmd suspend false
}
stop_stuff(){
jack_control stop
pacmd suspend true
SINKID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g')
SOURCEID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g')
if [ ! -z "$SINKID" ] ; then
pactl unload-module $SINKID
fi
if [ ! -z "$SOURCEID" ] ; then
pactl unload-module $SOURCEID
fi
pacmd suspend false
}
case "$1" in
start)
start_stuff
;;
stop)
stop_stuff
;;
status)
jack_control status
;;
*)
usage
;;
esac
#!/usr/bin/env bash
# set all sorts of parameters, start jack and deal with pulseaudio.
# there are 2 different ways to have jack and pa running:
# a) jack runs on the external and pa on the internal card
# b) using pulseaudio-module-jack, pa is bridged into jack
# for case a), it makes sense to use pavucontrol to tell pa to
# leave the external card the fuck alone. (config -> device -> OFF)
# for case b), nothing will use the internal card and you need to connect
# the pulseaudio-sink to your preferred hardware outputs.
# 20210325 wotwot and d0
CARD="MTK"
INPUTS="24"
OUTPUTS="22"
usage() {
echo "usage: `basename $0` {start|stop|status}"
}
start_stuff(){
jack_control ds alsa
jack_control dps device hw:$CARD,0
# some devices might work with values as low as 64 (2^n values only)
jack_control dps period 1024
# USB devices are recommended to be set to 3
jack_control dps nperiods 3
jack_control dps rate 44100
jack_control dps midi-driver seq
jack_control eps driver alsa
jack_control eps realtime True
jack_control eps realtime-priority 85
jack_control dps inchannels $INPUTS
jack_control dps outchannels $OUTPUTS
jack_control start
jack_control status
#jack_control ep
pacmd suspend true
# scenario a)
pactl unload-module module-jack-sink
pactl unload-module module-jack-source
pacmd set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
# scenario b)
# only enable the sources if you want feedback in the audio system
#pactl load-module module-jack-sink channels=2
#pacmd set-default-sink jack_out
## only enable this if you need pa inputs bridged and if you do, make sure
## they do not cause feedback loops !
##pactl load-module module-jack-source channels=2
##pacmd set-default-source jack_in
#jack_connect "PulseAudio JACK Sink:front-left" "system:playback_15"
#jack_connect "PulseAudio JACK Sink:front-right" "system:playback_16"
#jack_disconnect "PulseAudio JACK Sink:front-left" "system:playback_1"
#jack_disconnect "PulseAudio JACK Sink:front-right" "system:playback_2"
pacmd suspend false
}
stop_stuff(){
jack_control stop
pacmd suspend true
SINKID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g')
SOURCEID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g')
if [ ! -z "$SINKID" ] ; then
pactl unload-module $SINKID
fi
if [ ! -z "$SOURCEID" ] ; then
pactl unload-module $SOURCEID
fi
pacmd suspend false
}
case "$1" in
start)
start_stuff
;;
stop)
stop_stuff
;;
status)
jack_control status
;;
*)
usage
;;
esac
#!/usr/bin/env bash
# set all sorts of parameters, start jack and deal with pulseaudio.
# there are 2 different ways to have jack and pa running:
# a) jack runs on the external and pa on the internal card
# b) using pulseaudio-module-jack, pa is bridged into jack
# for case a), it makes sense to use pavucontrol to tell pa to
# leave the external card the fuck alone. (config -> device -> OFF)
# for case b), nothing will use the internal card and you need to connect
# the pulseaudio-sink to your preferred hardware outputs.
# cc-by-sa 20210325 wotwot and d0
CARD="UMC1820"
INPUTS="18"
OUTPUTS="20"
usage() {
echo "usage: `basename $0` {start|stop|status}"
}
start_stuff(){
jack_control ds alsa
jack_control dps device hw:$CARD,0
# some devices might work with values as low as 64 (2^n values only)
jack_control dps period 1024
# USB devices are recommended to be set to 3
jack_control dps nperiods 3
jack_control dps rate 44100
jack_control dps midi-driver seq
jack_control eps driver alsa
jack_control eps realtime True
jack_control eps realtime-priority 85
jack_control dps inchannels $INPUTS
jack_control dps outchannels $OUTPUTS
jack_control start
jack_control status
#jack_control ep
pacmd suspend true
# scenario a)
pactl unload-module module-jack-sink
pactl unload-module module-jack-source
pacmd set-default-sink alsa_output.pci-0000_00_1b.0.analog-stereo
# scenario b)
# only enable the sources if you want feedback in the audio system
#pactl load-module module-jack-sink channels=2
#pacmd set-default-sink jack_out
## only enable this if you need pa inputs bridged and if you do, make sure
## they do not cause feedback loops !
##pactl load-module module-jack-source channels=2
##pacmd set-default-source jack_in
#jack_connect "PulseAudio JACK Sink:front-left" "system:playback_15"
#jack_connect "PulseAudio JACK Sink:front-right" "system:playback_16"
#jack_disconnect "PulseAudio JACK Sink:front-left" "system:playback_1"
#jack_disconnect "PulseAudio JACK Sink:front-right" "system:playback_2"
pacmd suspend false
}
stop_stuff(){
jack_control stop
pacmd suspend true
SINKID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-sink" | grep Module | sed 's/[^0-9]//g')
SOURCEID=$(LANG=C pactl list | grep -B 1 "Name: module-jack-source" | grep Module | sed 's/[^0-9]//g')
if [ ! -z "$SINKID" ] ; then
pactl unload-module $SINKID
fi
if [ ! -z "$SOURCEID" ] ; then
pactl unload-module $SOURCEID
fi
pacmd suspend false
}
case "$1" in
start)
start_stuff
;;
stop)
stop_stuff
;;
status)
jack_control status
;;
*)
usage
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment