Re: [LAU] Jack command line connect

From: Florian Schmidt <mista.tapas@email-addr-hidden>
Date: Fri Oct 12 2007 - 10:50:54 EEST

On Friday 12 October 2007, Simon Williams wrote:
> In my attempt to stop the flipping xruns I get even from a really simple
> jack/fluidsynth (with 6.5mb soundfont) setup, I'm going to see if I can
> get it to run without xruns at all- so I'm going to stop the X server
> (which takes up quite a lot of cpu and memory).
>
> Before I can do this, I need to work out how on earth to connect
> fluidsynth to alsa_pcm without qjackctl. Why are there no man pages or
> --help or anything for jack_connect, etc? I've tried the obvious:
> "jack_connect fluidsynth alsa_pcm", but that doesn't work and without
> any usage information whatsoever I'm completely stuffed. Also, a command
> line list of port names that can be connected would be nice.

Add the stuff below to your bash auto completion setup [in ubuntu
it's /etc/bash_completion.d/jackd]. This way you can simply use tab to
autocomplete ports, e.g.:

~$ jack_connect [hit tab tab]
~$ jack_connect alsa_pcm\:capture_
alsa_pcm:capture_1 alsa_pcm:capture_2 alsa_pcm:capture_6
alsa_pcm:capture_10 alsa_pcm:capture_3 alsa_pcm:capture_7
alsa_pcm:capture_11 alsa_pcm:capture_4 alsa_pcm:capture_8
alsa_pcm:capture_12 alsa_pcm:capture_5 alsa_pcm:capture_9

#-*- mode: shell-script;-*-
# Inputs:
# $1 -- name of the command whose arguments are being completed
# $2 -- word being completed
# $3 -- word preceding the word being completed
# $COMP_LINE -- current command line
# $COMP_PONT -- cursor position
# $COMP_WORDS -- array containing individual words in the current
# command line
# $COMP_CWORD -- index into ${COMP_WORDS} of the word containing the
# current cursor position
# Output:
# COMPREPLY array variable contains possible completions

# Syntax:
# jack_connect <src_port> <dst_port>
# jack_disconnect <src_port> <dst_port>
# jackd [options] -d backend [backend-parameters]
# jackstart [options] -d backend [backend-parameters]

# Bugs/Todo:
# jack_{dis,}connect should support for spaces in port names
# restrict jack_disconnect completions to existing connections

# Bugreports: Paul Brossier <piem@email-addr-hidden>

have jack_connect &&
_jack_lsp_type() {
 jack_lsp -p 2>/dev/null | grep -B1 $1 | \
        grep -v 'properties.*,$' | grep -v ^-- \
                | sed 's/\([\/ :]\)/\\\1/g'
                #| sed 's/\([\\: ]\)/\\\1/g'
                #| sed 's/\(.*\)/"\1"/g'
}

have jackd &&
_jackd_driver_help() {
 jackd -d $1 --help 2> /dev/null | grep - | \
        sed 's/-\(.*\), --\([^\ .]*\) *\(.*\)/-\1 --\2/'
}

have jack_connect &&
_jack_connections() {

        local cur prev output IFS=$'\n'

        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        prev=${COMP_WORDS[COMP_CWORD-1]}

        # check if this is the first argument
        if [[ "$1" == "$prev" ]]; then
                COMPREPLY=( $( compgen -W "$(_jack_lsp_type output)" -- $cur ) )
        else
                COMPREPLY=( $( compgen -W "$(_jack_lsp_type input)" -- $cur ) )
        fi

        return 0

}

have jackd &&
_jackd()
{
        local cur prev special

        COMPREPLY=()
        cur=${COMP_WORDS[COMP_CWORD]}
        prev=${COMP_WORDS[COMP_CWORD-1]}

        # check if backend was specified
        for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
                if [[ ${COMP_WORDS[i]} == @(alsa|dummy|oss|coreaudio|portaudio) ]]; then
                        special=${COMP_WORDS[i]}
                fi
        done

        # list backends
        if [[ "$prev" == -d || "$prev" == --driver ]]; then
                COMPREPLY=( $( compgen -W 'alsa dummy oss coreaudio
portaudio' -- $cur ) )
        # list backend specific options
        elif [ -n "$special" ]; then
                COMPREPLY=( $( compgen -W '`_jackd_driver_help
$special` --help' -- $cur ) )
        # list common options
        else
                COMPREPLY=( $( compgen -W '--help -h \
                        --driver -d \
                        --realtime -R \
                        --realtime-priority -P \
                        --name -n \
                        --no-mlock -m \
                        --unlock -u \
                        --timeout -t \
                        --port-max -p \
                        --verbose -v \
                        --silent -s \
                        --version -V' -- $cur ) )
        fi

        return 0
}

[ "$have" ] && complete -F _jack_connections $filenames jack_connect
[ "$have" ] && complete -F _jack_connections $filenames jack_disconnect
[ "$have" ] && complete -F _jackd $filenames jackd
[ "$have" ] && complete -F _jackd $filenames jackstart

-- 
Palimm Palimm!
http://tapas.affenbande.org
_______________________________________________
Linux-audio-user mailing list
Linux-audio-user@email-addr-hidden
http://lists.linuxaudio.org/mailman/listinfo.cgi/linux-audio-user
Received on Fri Oct 12 12:15:02 2007

This archive was generated by hypermail 2.1.8 : Fri Oct 12 2007 - 12:15:02 EEST