Open main menu

CDOT Wiki β

Launch Recording Session

#!/bin/bash

# session.bash
#
# Author: Murray Saul
# Date: May 15, 2010
#
# Purpose: To automatically launch Ubuntu Studio applications (First, Jack audio server, then other applications
#          and also make automatic connections with Jack...


                                                             # Plays "Initiating startup sequence" to give an
                                                             # audio indicator script is starting...
                                                             # (Can download any clip from the Internet)

# Determine client number

clientNum1=$(aconnect -i | grep client | grep TASCAM | cut -d" " -f2 | tr -d ":")




# Using Zenity (dialog box constructor) to graphically prompt user for type of session (default: "Recording Studio")...
# Dialog box times out automatically after 10 seconds with default...

apps=$(zenity --height 510 --width 200 --timeout=30 --text "Roger that...\n\nPlease select Recording Applications\nthat you want to use:\n" --list --checklist --column "Session Type" --column "Description" TRUE "Jack" TRUE "Qsynth_Piano" TRUE "Hammond_B3" FALSE "Vox" FALSE "Rhodes_Piano" FALSE "Rhodes_Bass" FALSE "Mini_Moog" FALSE "Prophet5" FALSE "Odessey" TRUE "Hydrogen" FALSE "Ninjam_Server" FALSE "Ninjam_Client" FALSE "Ardour" FALSE "Rakarrack" TRUE "Audacity")


set $(echo $apps | sed "s/|/ /g") # Replace pipe "|" with space, and store as positional parameters

basePort=129      # Starting basePort number to connect via ALSA Jack is 129
bristolCount=0
bristolString=

for x                              # Run loop for each positional parameter to launch application
do
  if [ "$x" = "Jack" ]            # Launch Jack Audio Server (start server), wait 3 seconds...
  then
    /usr/bin/qjackctl -s &
    sleep 3
  fi

  if [ "$x" = "Hydrogen" ]  # Start Hydrogen Drum machines - Automatically patches in Jack
  then
    /usr/bin/hydrogen -display  &      # I have 3 monitors - runs Hydrogen in second screen
    sleep 5                                # (other 2 screens are virtual)...
    ((basePort++))                      # Increase basePort value by 1 for next connection...
  fi





  if [ "$x" = "Ardour" ]    # Start Ardour Digial Audio Workstation - Automatically patches in Jack
  then
    /usr/bin/ardour2  &
    sleep 5
  fi


  if [ "$x" = "Qsynth_Piano" ]    # Launch Qsynth and wait a few seconds...
  then                            
    /usr/bin/qsynth -g 6 &
    sleep 4
    aconnect $clientNum1:0 $basePort:0           # Automatically patch ALSA Tascam US122 port (20) to Qsynth port
    ((basePort++))                      # Increase basePort value by 1 for next connection...
  fi

  if [ "$x" = "Hammond_B3" ]      # Launch Bristol (B3 Organ) Keyboard - Midi Channel 4, wait 2 seconds
  then
    /usr/bin/startBristol -b3 -channel 3 -gain 3 -jack -midi seq -geom 600x350+0+0 &
    sleep 2
    aconnect $clientNum1:0 $basePort:0           # Automatically patch ALSA Tascam US122 port (20) to Bristol port
    sleep 2
    jack_connect bristol${bristolString}:out_left system:playback_1     # Patch AUDIO Bristol to system - left channel
    jack_connect bristol${bristolString}:out_right system:playback_2    #   "     "      "     "    "   - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
  fi

  if [ "$x" = "Vox" ]             # Launch Bristol (Vox Organ) Keyboard - Midi Channel 5, wait 2 seconds
  then
    /usr/bin/startBristol -vox -channel 4 -gain 3 -jack -midi seq -geom 600x165+607+0 & -vox -channel 5 -gain 3 -jack -midi seq   &
    sleep 2
    aconnect $clientNum1:0 $basePort:0           # Automatically patch ALSA Tascam US122 port (20) to Bristol port
    sleep 2
    jack_connect bristol${bristolString}:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol${bristolString}:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
  fi

  if [ "$x" = "Rhodes_Piano" ]    # Launch Bristol (Rhodes Piano) Keyboard - Midi Channel 6
  then
    /usr/bin/startBristol -rhodes -channel 5 -gain 3 -jack -midi seq -geom 600x165+607+185 &
    sleep 2
    aconnect $clientNum1:0 $basePort:0           # Automatically patch ALSA Tascam US122 port (20) to Bristol port
    sleep 2
    jack_connect bristol${bristolString}:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol${bristolString}:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
  fi

   if [ "$x" = "Rhodes_Bass" ]          # Automatically patch ALSA Tascam US122 Port (20) to Bristol port
   then
     /usr/bin/startBristol -rhodesbass -channel 7 -gain 3 -jack   &
     sleep 2
     aconnect $clientNum:0 $basePort:0
     sleep 2
    jack_connect bristol$bristolString:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol$bristolString:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
   fi

   if [ "$x" = "Mini_Moog" ]            # Automatically patch ALSA Tascam US122 Port (20) to Bristol port
   then
     /usr/bin/startBristol -mini -channel 8 -gain 3 -jack   &
     sleep 2
     aconnect $clientNum:0 $basePort:0
     sleep 2
    jack_connect bristol$bristolString:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol$bristolString:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
   fi


   if [ "$x" = "Prophet5" ]            # Automatically patch ALSA Tascam US122 Port (20) to Bristol port
   then
     /usr/bin/startBristol -pro5 -channel 9 -gain 3 -jack   &
     sleep 2
     aconnect $clientNum:0 $basePort:0
     sleep 2
    jack_connect bristol$bristolString:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol$bristolString:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
   fi



   if [ "$x" = "Odessey" ]            # Automatically patch ALSA Tascam US122 Port (20) to Bristol port
   then
     /usr/bin/startBristol -explorer -channel 10  -jack   &
     sleep 2
     aconnect $clientNum:0 $basePort:0
     sleep 2
    jack_connect bristol$bristolString:out_left system:playback_1   # Patch AUDIO Bristol to system - left channel
    jack_connect bristol$bristolString:out_right system:playback_2  # Patch AUDIO Bristol to system - right channel
    ((basePort+=2))                      # Increase basePort value by 2 for next connection...
    ((bristolCount++))
    bristolString="-0$bristolCount"
   fi

  if [ "$x" = "Rakarrack" ]  # Start Rakarrack Effects Processor (Guitar) - Automatically patches in Jack
  then
    /usr/bin/rakarrack  &
  fi

   if [ "$x" = "Audacity" ]  # Start Audacity Recorder - Automatically patches in Jack
   then
      sleep 5
      (/usr/bin/audacity &)
   fi
done

    sleep 5
zenity --info --text "All applications have been launched...\n\nEnjoy your recording session...\n\nHave a Nice Day...                 :)  " --timeout=5