mozaic_cc_switch

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mozaic_cc_switch [2020/01/10 04:42]
_ki created
mozaic_cc_switch [2020/01/10 05:03]
_ki Updated modificated script
Line 1: Line 1:
 ====== Mozaic: CC-Switch ====== ====== Mozaic: CC-Switch ======
 +
 +
 +===== Original =====
  
 by mbncp ( [[https://forum.audiob.us/discussion/comment/656597#Comment_656597|Link to thread]] ) by mbncp ( [[https://forum.audiob.us/discussion/comment/656597#Comment_656597|Link to thread]] )
Line 47: Line 50:
   TrigState[LastPad] = not TrigState[LastPad]   TrigState[LastPad] = not TrigState[LastPad]
   SendMIDICC LastPad, OutCC, CCVal[TrigState[LastPad]]   SendMIDICC LastPad, OutCC, CCVal[TrigState[LastPad]]
 +  TrigReset[LastPad] = 1
 +  Call @UpdateGUI
 +@End 
 +
 +@UpdateGUI
 +  for n = 0 to 15
 +     LatchPad n, TrigState[n]
 +  endfor 
 +@End
 +</code>
 +
 +
 +===== Modification =====
 +
 +Per pad
 +  * Channel
 +  * CC
 +  * Value for on and off state
 +all defined directly in the script code
 +
 +<code>
 +// CC-Switch  (Mozaic v1.03) mod by -ki
 +// main functionality by mbncp @ audiobus forum
 +
 +// Allows the use of a Controller to act like a switch 
 +// Usefull with controllers that return to their initial position once you release them
 +// The state is stored for each midi channel
 +// Off course you can also use the pads 
 +
 +@OnLoad
 +  // Adjust to your needs
 +  TrigCC = 64         // Incoming CC to make it act like a switch
 +  CCValRange = 15       // CC input value tolerance, for a knob use 64
 +
 +  //              A list of off/on CC values send, two numbers per pad
 +  CCVal[ 0] = [0,127,  0,127,   0,127,  0,127] // CC Values for pads 0.. 3
 +  CCVal[ 8] = [0,127,  0,127,   0,127,  0,127] //               pads 4.. 7
 +  CCVal[16] = [0,127,  0,127,   0,127,  0,127] //               pad  8..11
 +  CCVal[24] = [0,127,  0,127,   0,127,  0,127] //               pad 12..15
 +
 +  OutCC[0] = [10,11,12,13,14,15,16,17] // CCs for upper row
 +  OutCC[8] = [40,41,42,43,44,45,46,47] // CCs for lower row
 +  
 +  OutCH[0] = [0,0,0,0,0,0,0,0] // Output channel (0..15) for upper row
 +  OutCH[8] = [0,0,0,0,0,0,0,0] // Output channel (0..15) for lower row
 +
 +  //    
 +  FillArray TrigState, 0,16 // keep state of all channels
 +  FillArray TrigReset, 1,16
 +  SetShortName {Switch}
 +  LabelPads {CC Switch}
 +  LabelKnobs { }
 +  for k = 0 to 3
 +    LabelKnob k,{ }
 +    SetKnobValue k,0
 +  endfor
 +  
 +  ShowLayout 2
 +  for n = 0 to 15
 +    LabelPad n, {CC },OutCC[n], {  -----------   },{ch},OutCH[n]+1
 +   endfor 
 +  Call @UpdateGUI
 +@End
 +
 +@OnMidiInput
 +  If MIDICommand = 0xB0 And MIDIByte2 = TrigCC
 +    If MidiByte3 > (127 - CCValRange) And TrigReset[MIDIChannel]
 +      TrigState[MIDIChannel] = not TrigState[MIDIChannel]
 +      idx = MIDIChannel * 2 + TrigState[MIDIChannel]
 +      SendMIDICC OutCH[MIDIChannel],  OutCC[MIDIChannel], CCVal[idx]
 +      TrigReset[MIDIChannel] = 0
 +      Call @UpdateGUI
 +    ElseIf MidiByte3 < CCValRange
 +      TrigReset[MIDIChannel] = 1
 +     EndIf
 +  Else
 +    SendMIDIThru
 +  EndIf
 +@End
 +
 +@OnPadUp
 +  TrigState[LastPad] = not TrigState[LastPad]
 +  idx = LastPad * 2 + TrigState[LastPad]
 +  SendMIDICC OutCH[LastPad], OutCC[LastPad], CCVal[idx]
   TrigReset[LastPad] = 1   TrigReset[LastPad] = 1
   Call @UpdateGUI   Call @UpdateGUI
  • mozaic_cc_switch.txt
  • Last modified: 2020/01/10 05:03
  • by _ki