Audio config: verschil tussen versies

Uit Hackerspace Bitlair

Bobo1on1 (overleg | bijdragen)
Geen bewerkingssamenvatting
kGeen bewerkingssamenvatting
 
(8 tussenliggende versies door een andere gebruiker niet weergegeven)
Regel 1: Regel 1:
Install jackd1 (not jackd2 since it depends on dbus, meh).
{{Archive}}


Put this in /etc/environment
Install jackd2 from /root/jackd2, which is a jackd2 compiled without dbus (--dbus removed from debian/rules in the debian source package).
Make sure to enable rtprio and memlock permissions, the jackd installer on debian asks for this.


Make a new file /root/jackd_start, chmod to 755 and put this in it:
<pre><nowiki>
<pre><nowiki>
export JACK_PROMISCUOUS_SERVER=""
#!/bin/bash
</nowiki></pre>


Use this /etc/init.d/jackd file
#make sure jackd and bobdsp are terminated when this script ends
<pre><nowiki>
cleanup()
#!/bin/sh
{
#
  killall jackd
# Jackd init script
  killall bobdsp
#
  exit 0
### BEGIN INIT INFO
}
# Provides:          jackd
trap cleanup SIGINT
# Required-Start:    $local_fs
trap cleanup SIGTERM
# Required-Stop:
# Default-Start:    2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: init-Script for system wide fetchmail daemon
### END INIT INFO
#
# A fetchmailrc file containg hosts and passwords for all local users should be
# placed in /etc/fetchmailrc.  Remember to make the /etc/fetchmailrc mode 600
# to avoid disclosing the users' passwords.
#
# This script will NOT start or stop fetchmail if the /etc/fetchmailrc file
# does not exist or /etc/default/fetchmail is set to no.


set -e
#JACK_PROMISCUOUS_SERVER is exported here and in /etc/environment
#this tells jackd and libjack to use /dev/shm/jack instead of /dev/shm/jack-<uid>
#and to set the permissions to 777, however umask needs to be set to 0 first
export JACK_PROMISCUOUS_SERVER=""


# Defaults
#allow rtprio and mem locking
PATH=/sbin:/bin:/usr/sbin:/usr/bin
ulimit -l unlimited
DAEMON=/usr/bin/jackd
ulimit -r 95
USER=
OPTIONS=""


PIDFILE="/var/run/jackd.pid"
#start bobdsp
su -l bitlair -c "cd /home/bitlair/bobdsp; ./build/bobdsp -f -d"


test -f /etc/default/jackd || exit 0
#start jackd with -l passed to su to make the environment a login shell, restart when it dies
. /etc/default/jackd
#jackd needs to run as root, probably because it needs to send signals to its clients
while [ 1 ]
do
  su -l -c "mkdir ~/.jackd; umask 0; jackd -R -d alsa -d jack51 -r 48000 -p 1024 -n 2 -i 2 -o 6 2>&1 | tee ~/.jackd/jackd.log" || true
  sleep 1
done
</nowiki></pre>


OPTIONS="$OPTIONS"
Put this in /etc/rc.local
<pre><nowiki>
/root/jackd_start&
</nowiki></pre>


if [ ! "x$START_DAEMON" = "xyes" -a ! "$1" = "stop" ]; then
At the top of /etc/init.d/mpd change
echo "Edit /etc/default/jackd to start jackd"
<pre><nowiki>
exit 0
#!/bin/sh
fi
</nowiki></pre>
to
<pre><nowiki>
#!/bin/bash
</nowiki></pre>


test -f $DAEMON || exit 0
Then change
<pre><nowiki>
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
</nowiki></pre>
into
<pre><nowiki>
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0


. /lib/lsb/init-functions
#allow rtprio and mem locking
ulimit -l unlimited
ulimit -r 95
</nowiki></pre>


case "$1" in
And
start)
<pre><nowiki>
if test -e $PIDFILE ; then
user "mpd"
pid=`cat $PIDFILE | sed -e 's/\s.*//'|head -n1`
</nowiki></pre>
PIDDIR=/proc/$pid
into
    if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
<pre><nowiki>
log_failure_msg "jackd already started; not starting."
user "bitlair"
exit 0
</nowiki></pre>
else
log_warning_msg "Removing stale PID file $PIDFILE."
rm -f $PIDFILE
fi
fi
if pgrep -u $USER jackd > /dev/null 2>&1; then
log_failure_msg "jackd already running as user $USER; not starting."
exit 0
fi
        log_begin_msg "Starting jackd audio server:" "jackd"


if start-stop-daemon -b -S -o -q -x $DAEMON -u $USER -a /bin/su -- - $USER -c "$DAEMON $OPTIONS"; then
Then run as root:
while ! pgrep -u $USER jackd > /dev/null 2>&1; do continue; done
<pre><nowiki>
pgrep -u $USER jackd > $PIDFILE
dpkg-statoverride --remove /var/run/mpd
while ! su - $USER -c jack_lsp > /dev/null 2>&1; do
dpkg-statoverride --add bitlair audio 755 /var/run/mpd
sleep 0.1
done
log_end_msg 0
else
log_end_msg 1
exit 1
fi
                #JACK_PROMISCUOUS_SERVER is exported in /etc/environment, but the permissions are not set up correctly
                chmod -R 777 /dev/shm/jack
;;
stop)
if ! test -e $PIDFILE ; then
log_failure_msg "Pidfile not found! Is jackd running?"
exit 0
fi
        log_begin_msg "Stopping jackd audio server:" "jackd"
if start-stop-daemon -m -K -o -q -p $PIDFILE -x $DAEMON -u $USER; then
                        rm -f $PIDFILE
log_end_msg 0
else
log_end_msg 1
exit 1
fi
if pgrep -u $USER jackd; then
killall -9 $DAEMON
exit 0
fi
;;
force-reload|restart)
        log_begin_msg "Restarting jackd audio server:" "jackd"
if ! start-stop-daemon -m -K -o -q -p $PIDFILE -x $DAEMON -u $USER; then
log_end_msg 1
exit 1
fi
sleep 1
                rm -f $PIDFILE || true
if start-stop-daemon -m -b -S -o -q -p $PIDFILE -x $DAEMON -u $USER -c $USER -a $DAEMON -- $OPTIONS; then
log_end_msg 0
else
log_end_msg 1
exit 1
fi
;;
try-restart)
if test -e $PIDFILE ; then
pid=`cat $PIDFILE | sed -e 's/\s.*//'|head -n1`
PIDDIR=/proc/$pid
if [ -d ${PIDDIR} -a  "$(readlink -f ${PIDDIR}/exe)" = "${DAEMON}" ]; then
$0 restart
exit 0
fi
fi
test -f /etc/rc`/sbin/runlevel | cut -d' ' -f2`.d/S*jackd* && $0 start
;;
awaken)
        log_begin_msg "Awakening jackd audio server:" "jackd"
if [ -s $PIDFILE ]; then
start-stop-daemon -K -s 10 -q -p $PIDFILE -x $DAEMON
log_end_msg 0
exit 0
else
log_end_msg 1
exit 1
fi
;;
*)
log_warning_msg "Usage: /etc/init.d/jackd {start|stop|restart|force-reload|awaken|debug-run}"
log_warning_msg "  start - starts system-wide jackd service"
log_warning_msg "  stop  - stops system-wide jackd service"
log_warning_msg "  restart, force-reload - starts a new system-wide jackd service"
log_warning_msg "  awaken - tell system-wide jackd to start a poll cycle immediately"
log_warning_msg "  debug-run [strace [strace options...]] - start a debug run of the"
log_warning_msg "    system-wide jackd service, optionally running it under strace"
exit 1
;;
esac


exit 0
chown -R bitlair:audio /var/lib/mpd
chown -R bitlair:audio /var/run/mpd
chown -R bitlair:audio /var/log/mpd
</nowiki></pre>
</nowiki></pre>


Use this /etc/default/jackd file
Use this /etc/asound.conf file
 
<pre><nowiki>
<pre><nowiki>
# Set to "yes" to start jackd at boot
pcm.!default {
START_DAEMON=yes
    type plug
    slave { pcm "jack" }
}


# The jackd process will run under this user
pcm.jack {
USER=bitlair
    type jack
    playback_ports {
        0 system:playback_1
        1 system:playback_2
        2 system:playback_3
        3 system:playback_4
        4 system:playback_5
        5 system:playback_6
    }
    capture_ports {
        0 system:capture_1
        1 system:capture_2
    }
}


# Options to pass to jackd
ctl.mixer0 {
OPTIONS="-R -d alsa -d jack51 -r 48000 -p 1024 -n 2 -i 2 -o 6"
    type hw
</nowiki></pre>
    card 0
}


Use this /etc/asound.conf file
<pre><nowiki>
ctl.jack51 {
ctl.jack51 {
     type hw
     type hw
     card 0
     #card 0
     #default:CARD=Audigy
     card Audigy
}
}


Regel 185: Regel 128:
         # route for mmap workaround
         # route for mmap workaround
         type plug
         type plug
         #slave.pcm "surround51:CARD=Audigy,DEV=0"
         slave.pcm "surround51:CARD=Audigy"
         slave.pcm "surround51"
         #slave.pcm "surround51"
         slave.channels 6
         slave.channels 6
         route_policy duplicate
         route_policy duplicate
Regel 193: Regel 136:
         # 2 channels only
         # 2 channels only
         type hw
         type hw
         card 0
         #card 0
         #type plug
         card Audigy
        #slave.pcm "default:CARD=Audigy,DEV=0"
     }
     }
}
</nowiki></pre>
In /etc/mpd.conf comment the current audio output, and use this instead:
<pre><nowiki>
audio_output {     
      type    "jack"     
      name    "mpd"   
}
}
</nowiki></pre>
</nowiki></pre>

Huidige versie van 10 jan 2026 16:58


Deze pagina is aangemerkt als gearchiveerd. De informatie is niet langer relevant voor de space, gereedschappen of documentatie maar is bewaard gebleven omdat het misschien historische context geeft of gewoon leuk/grappig/interessant/etc. is.


Install jackd2 from /root/jackd2, which is a jackd2 compiled without dbus (--dbus removed from debian/rules in the debian source package). Make sure to enable rtprio and memlock permissions, the jackd installer on debian asks for this.

Make a new file /root/jackd_start, chmod to 755 and put this in it:

#!/bin/bash

#make sure jackd and bobdsp are terminated when this script ends
cleanup()
{
  killall jackd
  killall bobdsp
  exit 0
}
trap cleanup SIGINT
trap cleanup SIGTERM

#JACK_PROMISCUOUS_SERVER is exported here and in /etc/environment
#this tells jackd and libjack to use /dev/shm/jack instead of /dev/shm/jack-<uid>
#and to set the permissions to 777, however umask needs to be set to 0 first
export JACK_PROMISCUOUS_SERVER=""

#allow rtprio and mem locking
ulimit -l unlimited
ulimit -r 95

#start bobdsp
su -l bitlair -c "cd /home/bitlair/bobdsp; ./build/bobdsp -f -d"

#start jackd with -l passed to su to make the environment a login shell, restart when it dies
#jackd needs to run as root, probably because it needs to send signals to its clients
while [ 1 ]
do
  su -l -c "mkdir ~/.jackd; umask 0; jackd -R -d alsa -d jack51 -r 48000 -p 1024 -n 2 -i 2 -o 6 2>&1 | tee ~/.jackd/jackd.log" || true
  sleep 1
done

Put this in /etc/rc.local

/root/jackd_start&

At the top of /etc/init.d/mpd change

#!/bin/sh

to

#!/bin/bash

Then change

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

into

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

#allow rtprio and mem locking
ulimit -l unlimited
ulimit -r 95

And

user				"mpd"

into

user				"bitlair"

Then run as root:

dpkg-statoverride --remove /var/run/mpd
dpkg-statoverride --add bitlair audio 755 /var/run/mpd

chown -R bitlair:audio /var/lib/mpd
chown -R bitlair:audio /var/run/mpd
chown -R bitlair:audio /var/log/mpd

Use this /etc/asound.conf file

pcm.!default {
    type plug
    slave { pcm "jack" }
}

pcm.jack {
    type jack
    playback_ports {
        0 system:playback_1
        1 system:playback_2
        2 system:playback_3
        3 system:playback_4
        4 system:playback_5
        5 system:playback_6
    }
    capture_ports {
        0 system:capture_1
        1 system:capture_2
    }
}

ctl.mixer0 {
    type hw
    card 0
}

ctl.jack51 {
    type hw
    #card 0
    card Audigy
}

pcm.jack51 {
    # "asym" allows for different
    # handling of in/out devices
    type asym
    playback.pcm {
         # route for mmap workaround
         type plug
         slave.pcm "surround51:CARD=Audigy"
         #slave.pcm "surround51"
         slave.channels 6
         route_policy duplicate
    }
    capture.pcm {
        # 2 channels only
        type hw
        #card 0
        card Audigy
    }
}

In /etc/mpd.conf comment the current audio output, and use this instead:

audio_output {       
       type    "jack"       
       name    "mpd"     
}