|
| 1 | +#!/usr/bin/env bash |
| 2 | +#Noah Bliss |
| 3 | + |
| 4 | +# quick mod of this script to test my jdsp plugin |
| 5 | +# if someone reads this: feel free to send a PR with an optimized script for jdsp4linux (+compatibility for V4L) |
| 6 | +# ~thepbone |
| 7 | +configpath=$HOME/.config/jamesdsp |
| 8 | +fallbackconfigpath=/etc/jamesdsp |
| 9 | +if ! [ -d "$configpath" ]; then configpath="$fallbackconfigpath"; fi |
| 10 | +audiofile=$configpath/audio.conf |
| 11 | +devicefile=$configpath/devices.conf |
| 12 | +tmppath=/tmp/jamesdsp |
| 13 | +idfile=$tmppath/sinkid.tmp |
| 14 | +if [ -f $idfile ]; then oldid=$(< $idfile); fi |
| 15 | +pidfile=$tmppath/pid.tmp |
| 16 | +if [ -f $pidfile ]; then pid=$(< $pidfile); fi |
| 17 | +logfile=$tmppath/viper.log |
| 18 | +vipersink=jdsp |
| 19 | +mkdir -p $configpath |
| 20 | +mkdir -p $tmppath |
| 21 | +# Make $configpath the working directory. This allows IRS and similar files to be referenced in configs without needing a path prefix. |
| 22 | +cd "$configpath" |
| 23 | + |
| 24 | + |
| 25 | +start () { |
| 26 | + stop |
| 27 | + if [ -f $devicefile ]; then |
| 28 | + declare $(head -n1 $devicefile) #get location and desc from file else |
| 29 | + #Do our best. |
| 30 | + location=$(pactl info | grep "Default Sink" | awk -F ": " '{print $2}') |
| 31 | + if [ "$location" == "$vipersink" ]; then echo "Something is very wrong (Target is same as our vipersink name)."; return; fi |
| 32 | + fi |
| 33 | + idnum=$(pactl load-module module-null-sink sink_name=$vipersink sink_properties=device.description="JDSP4Linux") |
| 34 | + echo $idnum > $idfile |
| 35 | + echo "Setting original sink to full volume..." |
| 36 | + pactl set-sink-volume $location 1.0 |
| 37 | + echo "Changing primary sink to Viper..." |
| 38 | + pactl set-default-sink $vipersink |
| 39 | + source $audiofile |
| 40 | + gst-launch-1.0 -v pulsesrc device=$vipersink.monitor volume=1.0 \ |
| 41 | + ! audio/x-raw,channels=2,rate=44100,format=F32LE,endianness=1234 \ |
| 42 | + ! audioconvert \ |
| 43 | + ! jdspfx enable="$enable" analogmodelling-enable="$analogmodelling_enable" analogmodelling-tubedrive="$analogmodelling_tubedrive" bass-enable="$bass_enable" bass-mode="$bass_mode" bass-filtertype="$bass_filtertype" bass-freq="$bass_freq" headset-enable="$headset_enable" headset-preset="$headset_preset" stereowide-enable="$stereowide_enable" stereowide-mode="$stereowide_mode" bs2b-enable="$bs2b_enable" bs2b-mode="$bs2b_mode" compression-enable="$compression_enable" compression-pregain="$compression_pregain" compression-threshold="$compression_threshold" compression-knee="$compression_knee" compression-ratio="$compression_ratio" compression-attack="$compression_attack" compression-release="$compression_release" tone-enable="$tone_enable" tone-filtertype="$tone_filtertype" tone-eq="$tone_eq" masterswitch-limthreshold="$masterswitch_limthreshold" masterswitch-limrelease="$masterswitch_limrelease" ddc-enable="$ddc_enable" ddc-file="$ddc_file" \ |
| 44 | + ! audio/x-raw,channels=2,rate=44100,format=F32LE,endianness=1234 \ |
| 45 | + ! audioconvert ! pulsesink device="$location" & |
| 46 | + echo $! > $pidfile |
| 47 | + echo "Moving existing audio streams to Viper..." |
| 48 | + while read existing_sink; do pactl move-sink-input $existing_sink $vipersink; done < <(pactl list sink-inputs short | awk '{print $1}') |
| 49 | +} |
| 50 | + |
| 51 | +stop () { |
| 52 | + if [ -f $pidfile ]; then |
| 53 | + if ps -p $pid &>/dev/null; then kill $pid; murdercanary="Killed process."; else murdercanary="Looks like it was already dead...?"; fi |
| 54 | + rm $pidfile && pidcanary="Deleted pidfile." |
| 55 | + echo "$murdercanary $pidcanary" |
| 56 | + fi |
| 57 | + if [ -f $idfile ]; then |
| 58 | + pactl unload-module $oldid |
| 59 | + rm $idfile |
| 60 | + echo "Unloaded Viper sink." |
| 61 | + fi |
| 62 | +} |
| 63 | + |
| 64 | +restart () { |
| 65 | + start |
| 66 | +} |
| 67 | + |
| 68 | +status () { |
| 69 | + if [ -f $pidfile ]; then pidfilestatus="There is a pidfile."; |
| 70 | + if ps -p $pid &>/dev/null; then |
| 71 | + pidstatus="There is also a process running at pid $pid." |
| 72 | + running="[RUNNING]"; else |
| 73 | + pidstatus="However, there is no process running with the expected pid." |
| 74 | + running="[ERROR]" |
| 75 | + fi; else |
| 76 | + pidfilestatus="No process." |
| 77 | + running="[STOPPED]" |
| 78 | + fi |
| 79 | + if [ -f $idfile ]; then |
| 80 | + idfilestatus="There is an idfile. The viper sink seems to be loaded at id: $oldid."; else |
| 81 | + idfilestatus="No idfile found." |
| 82 | + fi |
| 83 | + echo "$running" |
| 84 | + echo "$pidfilestatus $pidstatus" |
| 85 | + echo "$idfilestatus" |
| 86 | +} |
| 87 | +$@ |
| 88 | + |
0 commit comments