Skip to content

Commit

Permalink
test hub mode with scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cchafe committed Aug 22, 2020
1 parent 11d8b08 commit 58a0194
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 0 deletions.
35 changes: 35 additions & 0 deletions scripts/hubMode/art.sh
@@ -0,0 +1,35 @@
echo calculate audio round trip
rm /tmp/art.dat
$( jack_iodelay > /tmp/art.dat 2>&1 & )
# jack_iodelay &
sleep 1
# jack_connect jack_delay:out jackloop$1.stanford.edu:send_2
# jack_connect jackloop$1.stanford.edu:receive_2 jack_delay:in
jack_disconnect __1:receive_1 __1:send_1
jack_disconnect __1:receive_2 __1:send_2
# jack_disconnect localhost:receive_1 localhost:send_1
# jack_disconnect localhost:receive_2 localhost:send_2
jack_connect jack_delay:out __1:send_1
jack_connect __1:receive_1 jack_delay:in

sleep 8
killall jack_iodelay
sleep 1

killall jacktrip
killall jackd

DEFAULTOUTPUT=-1
AWKOUTPUT=$(grep total /tmp/art.dat | \
awk '{ sum += $3; n++ } END { if (n > 0) print sum / n; }')
printf -v AWKWARDINT %.0f "$AWKOUTPUT"
if (($AWKWARDINT > 0 ))
then
echo $AWKOUTPUT
exit 0
else
echo $DEFAULTOUTPUT
exit 1
fi


50 changes: 50 additions & 0 deletions scripts/hubMode/startJacktripHubClient.sh
@@ -0,0 +1,50 @@
#!/bin/bash
# bash script for jacktrip automation, Chris Chafe
# startJacktripHubClient.sh <FPP>
#
# /home/cc/Desktop/sh/startJacktripHubClient.sh /home/cc/jacktrip/builddir/jacktrip %p

JACKTRIP=$1

### qjackctl start / stop example
## qjackctl Setup : Options : Execute scrpt after Startup
# /home/cc/Desktop/sh/startJacktripHubClient.sh %p
## qjackctl Setup : Options : Execute scrpt on Shutdown
# /home/cc/Desktop/sh/stopJacktrip.sh
## timing of scrpt call means jacktrip is still running and
## an alert will appear for each new server it tries to shutdown
## for both <scripts> do, chmod +x <script>.sh

### manual start example
# ./jacktrip -C jackloop128.stanford.edu

### automatic client start in qjackctl : Setup : Options Execute script after Startup
### examples with line used in qjackctl and corresponding script
## specify full server name
# /home/cc/startJacktrip.sh jackloop128.stanford.edu
# SERVER=localhost

## server name from file
# /home/cc/startJacktrip.sh jackloop1024.stanford.edu
# SERVER=$(cat ../../server.txt)

## composed server name, %p = fpp
# /home/cc/startJacktrip.sh %p


if [ -z "$2" ]
then
SERVER=localhost
else
FPP=$2
SERVER=jackloop$FPP.stanford.edu
fi


echo starting hub client of server running on $SERVER

$( $JACKTRIP -C $SERVER > /dev/null 2>&1 & )




14 changes: 14 additions & 0 deletions scripts/hubMode/startJacktripHubServer.sh
@@ -0,0 +1,14 @@
#!/bin/bash
# bash script for jacktrip automation, Chris Chafe
# startJacktripHubServer.sh <FPP>

JACKTRIP=$1


echo starting $JACKTRIP server

$( $JACKTRIP -S -p1 > /dev/null 2>&1 & )




70 changes: 70 additions & 0 deletions scripts/hubMode/test_hub_mode_server_and_client.sh
@@ -0,0 +1,70 @@
#!/bin/bash
# test_hub_mode_server_and_client.sh
# bash script for automatic testing of jacktrip in hub mode , Chris Chafe
# connects a hub client to a hub server (started with with -p1) on the same host
# prints avg audio RTT after 8 sec, or -1 if fail
# ./test_hub_mode_server_and_client.sh <path-to-executable> <FPP>
# requires 3 helper scripts
# -- startJacktripHubServer.sh
# -- startJacktripHubClient.sh
# -- art.sh
# requires jackd be available on the host
# uses the "dummy" interface, so no audio interface needed
# first does some jackd cleanup
# takes approx. 20 sec to complete

# a passing test prints to the console
# [cc@localhost sh]$ ./test.sh /home/cc/jacktrip/builddir/jacktrip 32
# starting /home/cc/jacktrip/builddir/jacktrip hub mode test at 32 FPP
# starting hub client for server localhost
# calculate audio round trip
# 4

# a failed test prints to the console
# [cc@localhost functionTests]$ ./test.sh ~/jacktrip/builddir/jacktrip 32
# starting /home/cc/jacktrip/builddir/jacktrip hub mode test at 32 FPP
# starting /home/cc/jacktrip/builddir/jacktrip server
# starting hub client of server running on localhost
# calculate audio round trip
# ERROR ..1:send_1 not a valid port
# ERROR ..1:send_2 not a valid port
# ERROR ..1:send_1 not a valid port
# ERROR ..1:receive_1 not a valid port
# jacktrip: no process found
# -1


JACKTRIP=$1

if [ -z "$2" ]
then
FPP=128
else
FPP=$2
fi

# killall jackd
if [ "$(ps -aux | grep -c jackd)" != 1 ]; then killall jackd; fi;
# if jackd is or has been running with another driver
# much experimenation shows it literally takes this long
sleep 17
# to flush old connections before starting the dummy driver

# start jack with dummy driver, or change to an audio interface by switching these lines
$( /usr/bin/jackd -ddummy -r48000 -p$FPP > /dev/null 2>&1 & )
# $( /usr/bin/jackd -dalsa -dhw:A96 -r48000 -p$FPP -n2 > /dev/null 2>&1 & )
# $( /usr/bin/jackd -dalsa -dhw:PCH -r48000 -p$FPP -n2 > /dev/null 2>&1 & )

sleep 1

echo starting $JACKTRIP hub mode test at $FPP FPP

$PWD/startJacktripHubServer.sh $JACKTRIP
sleep 1
$PWD/startJacktripHubClient.sh $JACKTRIP

sleep 1

# start measuring audio RTT
$PWD/art.sh

0 comments on commit 58a0194

Please sign in to comment.