music_on_linux:audio_관련_스크립트_모음
Table of Contents
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
JACK 구동 명령어를 스크립트 내에 삽입하였다. — 2022/04/05 15:47
#!/usr/bin/env bash option="-a jack --connect-jack-outputs" 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 echo "Starting JACK...!\n" echo "jackd -d alsa --device hw:Intel --rate 44100 --period 128 &" jackd -d alsa --device hw:Intel --rate 44100 --period 128 & echo "Sleeping five seconds.." sleep 5 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.4 ${array[$input]}" $CMD
정해영의 simple_synth 스크립트
PulseAudio를 오디오 드라이버로 사용하는 매우 단순한 FluidSynth 구동 스트립트. 사운드 폰트 파일을 인수로 지정하지 않으면 FluidR3_GM.sf2가 로드된다.
#!/usr/bin/bash if [ -z "$1" ] then SF=/usr/share/sounds/sf2/FluidR3_GM.sf2 else SF=$1 fi echo -e "\nSoundFont file: $SF\n" fluidsynth -a pulseaudio -m alsa_seq -o midi.autoconnect=1 -r 48000 -g 0.5 $SF sleep 5 connect_midi_keyboard
connect_midi_keyboard
aconnect -i aconnect -o echo aconnect "iCON iKeyboard" "FLUID Synth"
music_on_linux/audio_관련_스크립트_모음.txt · Last modified: 2023/09/08 04:08 by hyjeong