Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

S Jagannathan

By: a guest on Feb 17th, 2011  |  syntax: TCL  |  size: 1.19 KB  |  views: 123  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. if {0} {
  2.         control selected drones from midi slider/knob
  3.         copyright (c) 2011 S Jagannathan.
  4.         released under GPL 2.0.
  5. }
  6.  
  7.  
  8. proc assign-drones {cc} { ;# assigns selected drones to midi cc
  9.  
  10.         set sel [get-drone selected] ;# get selected drones
  11.  
  12.         ;# set cc as dronal array variable's index
  13.         ;# and store selected drones & their initial volumes
  14.         global dronal
  15.         set dronal($cc) [list $sel [get-drone volume $sel]]  ;# get-drone is din built in command
  16.  
  17. }
  18.  
  19. proc midi-cc {status cc value} { ;# called when user operates midi controller
  20.  
  21.         global dronal
  22.         foreach ass [array names dronal] {
  23.                 if {$cc eq $ass} { ;# cc matches one of our drones assignments
  24.                         set pair $dronal($ass) ;# get drones & initial volumes for this assignment
  25.                         set drones [lindex $pair 0] ;# get the attached drones
  26.                         set vols [lindex $pair 1] ;# get the initial volumes
  27.  
  28.                         ;# run thru the drones list and assign volume from 0 to initial drone volume based on midi
  29.                         ;# slider position
  30.  
  31.                         for {set i 0; set j [llength $drones]} {$i < $j} {incr i} {
  32.                                 set idrone [lindex $drones $i]
  33.                                 set ivol [lindex $vols $i]
  34.                                 set-drone volume $idrone [getval 0 $ivol $value] ;# set-drone is din built in command
  35.                         }
  36.                 }
  37.         }
  38.  
  39. }