GenoGlobe

Haeyoung's wiki

User Tools

Site Tools


music_on_linux:audio_관련_스크립트_모음

Audio 관련 스크립트 모음

Ted's original audio script

Available from http://tedfelix.com/linux/linux-midi.html

#!/bin/bash

# Script to launch audio servers for music-making.

case $1 in

  start )
    echo Starting JACK...

    # Start JACK
    # As of Ubuntu 12.10, a period of 128 is needed for good fluidsynth
    # timing.  (jackd 1.9.9, fluidsynth 1.1.5)
    # If you aren't running pulseaudio, you can remove the pasuspender line.
    pasuspender -- \
        jackd -d alsa --device hw:0 --rate 44100 --period 128 \
            &>/tmp/jackd.out &

    sleep .5

    echo Starting fluidsynth...

    # Start fluidsynth
    fluidsynth --server --no-shell -p "fluidsynth 1" --audio-driver=jack \
        --connect-jack-outputs --reverb=0 --chorus=0 --gain=0.8 \
        -o midi.autoconnect=false \
        /usr/share/sounds/sf2/FluidR3_GM.sf2 \
        &>/tmp/fluidsynth.out &

    sleep 1

    if pgrep -l jackd && pgrep -l fluidsynth
    then
      echo Audio servers running.
    else
      echo There was a problem starting the audio servers.
    fi

    ;;

  stop )
    killall fluidsynth
    killall jackd
    echo Audio servers stopped.
    ;;

  * )
    echo Please specify start or stop...
    ;;
esac

정해영의 audio.qsynth script

#!/bin/bash

# Script to launch audio servers for music-making.
# from Ted's Linux MIDI Guide (http://tedfelix.com/linux/linux-midi.html)
# modified by Haeyoung Jeong

DEVICE=$2

case $1 in

  start )
    if [ -z ${DEVICE} ]
    then
        echo You did not specify any sound card!
        exit 1
    fi

    PATTERN="\[${DEVICE}  "
    if grep -q "${PATTERN}" /proc/asound/cards; then
        echo Audio device ${DEVICE} found!
    else
        echo ${DEVICE} is not a valid sound card!
        exit 1
    fi
    echo Starting JACK using ${DEVICE}...

    # Start JACK
    # As of Ubuntu 12.10, a period of 128 is needed for good fluidsynth
    # timing.  (jackd 1.9.9, fluidsynth 1.1.5)
    # If you aren't running pulseaudio, you can remove the pasuspender line.
   pasuspender -- \
        jackd -d alsa --device hw:${DEVICE} --rate 48000 --period 128 \
              --nperiod 3 &>/tmp/jackd.out &

    sleep .5

    # Start Qsynth
    echo "Press Esc key within 3 seconds to skip Qsynth:"
    read -t 3 -rsn 1 input
    if [ "$input" = $'\e' ]; then
        echo "Skipping Qsynth..."
        if pgrep -l jackd
        then
            echo JACK server running.
        fi
    else
        echo Starting Qsynth...
        qsynth -m alsa_seq -a jack \
            --connect-jack-outputs --reverb=0 --chorus=0 --gain=0.8 \
            /usr/share/sounds/sf2/FluidR3_GM.sf2 \
            &>/tmp/qsynth.out &
        sleep 1
        if pgrep -l jackd && pgrep -l qsynth
        then
          echo Audio servers running.
        else
          echo There was a problem starting the audio servers.
        fi
    fi

    echo You may start qjackctl and PulseAudioJackSink \(post_jack\).
    echo Please run 'a2jmidid -e' if you have hardware MIDI devices connected.
    echo You may use 'a2j -e' instead.

    ;;

  stop )
    if pgrep -l qsynth
    then
        killall qsynth
    fi
    killall jackd
    echo Audio servers stopped.
    ;;

  * )
    echo Please specify start or stop...
    ;;
esac

정해영의 start_jack_uca200 script

#!/bin/bash

#echo "suspend 1" | pacmd

jack_control start
jack_control ds alsa
jack_control dps device hw:CODEC
jack_control dps rate 48000
jack_control dps nperiods 3
jack_control dps period 128
sleep 5
#a2jmidid -e &
sleep 5
qjackctl 2> /dev/null &

process_id=$(pidof pavucontrol)
if [[ -z $process_id ]]; then
    echo "Starting PulseAudio Volume Control..."
    pavucontrol 2> /dev/null &
fi

범용 스크립트 start_jack_generic

#!/bin/bash

#echo "suspend 1" | pacmd

DEVICE=$1

if [ -z ${DEVICE} ]
then
    echo You did not specify any sound card!
    exit 1
fi

PATTERN="\[${DEVICE}  "
if grep -q "${PATTERN}" /proc/asound/cards; then
    echo Audio device ${DEVICE} found!
else
    echo ${DEVICE} is not a valid sound card!
    exit 1
fi

jack_control start
jack_control ds alsa
jack_control dps device hw:${DEVICE}
jack_control dps rate 48000
jack_control dps nperiods 3
jack_control dps period 128
sleep 5
#a2jmidid -e &
sleep 5
qjackctl 2> /dev/null &

process_id=$(pidof pavucontrol)
if [[ -z $process_id ]]; then
    echo "Starting PulseAudio Volume Control..."
    pavucontrol 2> /dev/null &
fi

사용 방법은 다음과 같다.

$ start_jack CODEC
Audio device CODEC found!
--- start
--- driver select "alsa"
--- driver param set "device" -> "hw:CODEC"
--- driver param set "rate" -> "48000"
--- driver param set "nperiods" -> "3"
--- driver param set "period" -> "128"

정해영의 run_fluidsynth script

#!/usr/bin/env bash

option="-a jack --connect-jack-outputs --reverb=1 --chorus=1 --gain=0.8"

if [ "$1" = "alsa" ] || [ "$1" = "-a" ] || [ "$1" = "-alsa" ]
    then
        option="-a alsa"
        echo
        echo "ALSA audio driver will be used (default: JACK)"
    elif ! pgrep -l jackd
    then
        echo "Run JACK server prirot to running FluidiSynth!"
        exit
fi

OIFS=$IFS; IFS=$'\n'
array=($(find $HOME/sf2 -type f)); IFS=$OIFS

echo
echo "Soundfonts installed in $HOME/sf2: "
i=0
for var in "${array[@]}"
do
    echo "[$i]:  $(du -sh ${var})" | \
        awk '{idx = split($3, parts, "/"); print $1, parts[idx], "-", $2}'
    i=`expr $i + 1`
done
echo
echo -n "Select sf2 index number: "
read -r input
CMD="fluidsynth --server $option --reverb=0 --chorus=0 --gain=0.8 ${array[$input]}"
$CMD
music_on_linux/audio_관련_스크립트_모음.txt · Last modified: 2021/03/23 17:28 by hyjeong