next up previous
Next: A simple sequence recorder Up: TCL script exemples Previous: A simple MIDI channel

A simple MIDI arpegiator

############ TISM TUTORIAL 2 ##########
######  Simple MIDI Arpegiator


###### 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

###### Sequences ############################

setbpm 160

# The arpegiator pattern
set tmp [createseq "arpegiator1" ]

#pattern parameters

# output port 20 
seqchanout $tmp 20  	
# not muted
seqmute $tmp 1     	
# loop on
seqloop $tmp 1     
# quantization 1/16	
quantize $tmp 1 16 	
# pattern length 1/1 (4 beats)
seqrdef $tmp 1 1        
# no default sync
seqdefaultsync $tmp 0 0 
# begin & end marks 
beginmarksec $tmp 0 0
endmarksec $tmp 16 0   

#pattern messages

addevtsec $tmp 0 0 0 144 0 0 0 
addevtsec $tmp 2 0 0 144 0 4 0 
addevtsec $tmp 4 0 0 144 0 7 0 
addevtsec $tmp 6 0 0 144 0 12 0 
addevtsec $tmp 8 0 0 144 0 16 0 
addevtsec $tmp 10 0 0 144 0 19 0 
addevtsec $tmp 12 0 0 144 0 24 0 

#save seq id
setv arpg $tmp

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


# What to do when receive Note On message on port 0 
# mask : 0 144
# We save the note number and velocity to transpose the pattern
# and we start the sequence

set a [createctrl 0 0 144]  
setscript1 0 $a {setv basenote [getm 3]; setv velo [getm 4]; startsync [getv arpg];}

#define controller to transpose pattern (on port 20)
# redirect to port 0 (midi output), change pitch and velocity

set a [createctrl 0 20]  
setscript1 0 $a { setm 0 0; setm 3 [expr [getm 3] + [getv basenote]]; setm 4 [getv velo]}


################ Default value ######
# first active group 
setcgroup 0
# second active group 
setcgroup2 1



TISM manual