#!/bin/bash
#
# \file        YoSeqJack
# \library     Home/Audio
# \author      Chris Ahlstrom
# \date        2016-03-21
# \update      2016-03-21
# \version     $Revision$
# \license     $XPC_SUITE_GPL_LICENSE$
#
#     This script provides a way to set up yoshimi and seq24/sequencer64
#     to run on ALSA MIDI (and audio).
#
#     It requires some configuration specific to the user's setup.
 
YoseqStatus="on"
DoHelp="no"

# This line is meant for starting from the Sequencer64 project root.
# The commented lines support the installed versions:
#
# Sequencer=/usr/bin/$Seq
# Sequencer=/usr/local/bin/$Seq

Seq="sequencer64"
Sequencer="./Sequencer64/$Seq"
Options="-m --bus 5"

# The installed version of Yoshimi.

Yoshi="/usr/local/bin/yoshimi"

# Process the simple script options:

if [ $# -ge 1 ] ; then

   while [ "$1" != "" ] ; do

      case "$1" in

         start | on)
            YoseqStatus="on"
            ;;

         stop | off)
            YoseqStatus="off"
            ;;

         help)
            DoHelp="yes"
            ;;

      esac
      shift
   done
fi

if [ "$DoHelp" == "yes" ] ; then

cat << E_O_F

Usage: YoSeqAlsa [options]

Starts or stops sequencer64 and yoshimi for usage with ALSA.
You will need to edit some macros in this script to make changes
to match your system.

Options:

   stop, off   Stop sequencer64 and yoshimi instances.
   start, on   Start sequencer64 and yoshimi.  This is the default action.
   help        Show this text.

Sequencer64 is started as JACK Master.  Yoshimi is started with JACK audio and
JACK MIDI.  QJackCtrl is started, but you still have to make the connections
between Yoshimi and JACK audio, and between a2jmidid's sequencer64 Through port
to the Yoshimi input.

E_O_F

elif [ "$YoseqStatus" == "off" ] ; then

   killall $Seq > /dev/null
   killall yoshimi > /dev/null
   echo "$Seq and Yoshimi stopped."

else

   echo "Starting $Seq and Yoshimi.  Connections rely on passing the option"
   echo "'$Buss' to $Seq."
   $Sequencer -A &
   sleep 1
   $Yoshi -a -A

fi

# vim: ft=sh
