#!/bin/sh
# Version 0.2
# (C) 2005-2006 por Marcos Guglielmetti
# GNU GPL

export USAR_NLS=si
export TEXTDOMAIN=meterbridge.sh
export TEXTDOMAINDIR="/etc/musix/locales"


# si jack está corriendo, todo bien, sino, lo iniciamos
JACK_ACTIVO=0
if pidof jackd 2>&1 >/dev/null; then
JACK_ACTIVO=1
fi

# Si no esta activo jack , lo iniciamos con valor predeterminado
if [ "$JACK_ACTIVO" = "0" ]
then
/usr/bin/jackd -R -t2000 -m -dalsa -dhw:0 -r44100 -p1024 -n2 -s -S &
sleep 3s
fi


QJACK_ACTIVO=0
if pidof qjackctl 2>&1 >/dev/null; then
QJACK_ACTIVO=1
fi


# Si no esta activo jack , lo iniciamos con valor predeterminado
if [ "$QJACK_ACTIVO" = "0" ]
then
qjackctl &
sleep 3s
fi

pos="-nearmouse"
echo -n "
     'vu'  - classic moving needle VU meter
     'ppm' - PPM meter
     'dpm' - Digital peak meter
     'jf'  - 'Jellyfish' phase meter
     'sco' - Oscilloscope meter
" | gmessage -title 'Choose-Type' -geometry 600x150 -file - $pos -buttons "vu:0,ppm:1,dpm:2,jf:3,sco:4,Abort:8"


NB="$?"

if [ "$NB" = "8" ]; then exit 2; fi

if [ "$NB" = "0" ]; then  meterbridge -t vu alsa_pcm:playback alsa_pcm:record;fi
if [ "$NB" = "1" ]; then  meterbridge -t ppm alsa_pcm:playback alsa_pcm:record;fi
if [ "$NB" = "2" ]; then  meterbridge -t dpm alsa_pcm:playback alsa_pcm:record;fi
if [ "$NB" = "3" ]; then  meterbridge -t jf alsa_pcm:playback alsa_pcm:record;fi
if [ "$NB" = "4" ]; then  meterbridge -t sco alsa_pcm:playback alsa_pcm:record;fi

