next up previous
Next: A simple MIDI arpegiator Up: TCL script exemples Previous: TCL script exemples

A simple MIDI channel converter

############ TISM TUTORIAL 1 ##########
######  Simple MIDI Channel converter


###### Input / Output #################

# Alsa MIDI Input (device 0)
# On Tism port 0 (All messages received will begin by 0)

addinprotocol 0 alsamidiraw hw:0,0

# Computer Keyboard Input on Port 1 (messages begin with 1)

# Note : The Terminal window where Tism has been lauch 
# must be FOCUSED to capture keyboard event

addinprotocol 1 key /dev/tty
printtitle test

# Alsa Midi Output (device 0)
# On Tism Port 0 (All messages which begin by 0 will sent)

addoutprotocol 0 alsamidiraw hw:0,0

###### Control ######################

# Create scripts to transform channel number of incoming Midi message
# We assign 1 script in 8 group corresponding to 8 midi channel
# note : we reserve the group 0 for later
# The script consist of changing the third value of message
# The script is applied to every message received on port 0 (mask : 0)

#GROUP 1 -> Midi Channel 0

set a [createctrl 1 0]
setscript1 1 $a "setm 2 0"

#GROUP 2 -> Midi Channel 1

set a [createctrl 2 0]
setscript1 2 $a "setm 2 1"

#GROUP 3 -> Midi Channel 2

set a [createctrl 3 0]
setscript1 3 $a "setm 2 2"

#GROUP 4 -> Midi Channel 3

set a [createctrl 4 0]
setscript1 4 $a "setm 2 3"

#GROUP 5 -> Midi Channel 4

set a [createctrl 5 0]
setscript1 5 $a "setm 2 4"

#GROUP 6 -> Midi Channel 5

set a [createctrl 6 0]
setscript1 6 $a "setm 2 5"

#GROUP 7 -> Midi Channel 6

set a [createctrl 7 0]
setscript1 7 $a "setm 2 6"

#GROUP 8 -> Midi Channel 7

set a [createctrl 8 0]
setscript1 8 $a "setm 2 7"


### Assign to keyboard key script to change 2nd active group
### Changing active group will allow to change midi channel
# numeric key 0 (mask: 1 48)

set a [createctrl 0 1 48]
setscript1 0 $a "setcgroup2 1"

# numeric key 1 (mask: 1 49)

set a [createctrl 0 1 49]
setscript1 0 $a "setcgroup2 2"

# numeric key 2 (mask: 1 50)

set a [createctrl 0 1 50]
setscript1 0 $a "setcgroup2 3"

# numeric key 3 (mask: 1 51)

set a [createctrl 0 1 51]
setscript1 0 $a "setcgroup2 4"

# numeric key 4 (mask: 1 52)

set a [createctrl 0 1 52]
setscript1 0 $a "setcgroup2 5"

# numeric key 5 (mask: 1 53)

set a [createctrl 0 1 53]
setscript1 0 $a "setcgroup2 6"

# numeric key 6 (mask: 1 54)

set a [createctrl 0 1 54]
setscript1 0 $a "setcgroup2 7"

# numeric key 7 (mask: 1 55)

set a [createctrl 0 1 55]
setscript1 0 $a "setcgroup2 8"

################ Default value ######
# first active group : group 0 (key)
setcgroup 0

# first active group : group 1 (Midi channel set to 0)
setcgroup2 1



TISM manual