diff --git a/README.md b/README.md index 216815b2b6131f5703f4579cfe8438c5dc728035..966ce5e9b689e62739aae367d03ab5b5dd5339e3 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,21 @@ # 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 + diff --git a/ebur128 b/ebur128 new file mode 100755 index 0000000000000000000000000000000000000000..49b6afa818829e46df89e07ba62ff9355d6657b5 --- /dev/null +++ b/ebur128 @@ -0,0 +1,11 @@ +#! /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 + diff --git a/meterbridge-inputs-all b/meterbridge-inputs-all new file mode 100755 index 0000000000000000000000000000000000000000..96f12f8052c40e652490cdac2eb8dccb93aea8fe --- /dev/null +++ b/meterbridge-inputs-all @@ -0,0 +1,18 @@ +#!/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 diff --git a/meterbridge-pa-sink b/meterbridge-pa-sink new file mode 100755 index 0000000000000000000000000000000000000000..91842239ed82896f24da546a8c6abe0b6b0fe909 --- /dev/null +++ b/meterbridge-pa-sink @@ -0,0 +1,5 @@ +#!/bin/sh + +meterbridge -t dpm\ + "PulseAudio JACK Sink:front-left"\ + "PulseAudio JACK Sink:front-right" diff --git a/meterbridge-system-inputs b/meterbridge-system-inputs new file mode 100755 index 0000000000000000000000000000000000000000..e9fc4895907442fff80fa9184467e3ad12d3cdd3 --- /dev/null +++ b/meterbridge-system-inputs @@ -0,0 +1,27 @@ +#!/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" diff --git a/myjackctl-LP16 b/myjackctl-LP16 new file mode 100755 index 0000000000000000000000000000000000000000..147f48aa0f21ca074f069e396487b353462ba9bf --- /dev/null +++ b/myjackctl-LP16 @@ -0,0 +1,90 @@ +#!/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 + diff --git a/myjackctl-MTK b/myjackctl-MTK new file mode 100755 index 0000000000000000000000000000000000000000..3c1598eddb061a4dbb0cd312392f6bb58ae7edbe --- /dev/null +++ b/myjackctl-MTK @@ -0,0 +1,90 @@ +#!/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 + diff --git a/myjackctl-umc1820 b/myjackctl-umc1820 new file mode 100755 index 0000000000000000000000000000000000000000..be28417337d15678e76bc3bc0d1a2f7bd6986116 --- /dev/null +++ b/myjackctl-umc1820 @@ -0,0 +1,89 @@ +#!/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