Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| mozaic_cc_switch [2020/01/10 04:42] – created _ki | mozaic_cc_switch [2020/01/10 05:03] (current) – Updated modificated script _ki | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Mozaic: CC-Switch ====== | ====== Mozaic: CC-Switch ====== | ||
| + | |||
| + | |||
| + | ===== Original ===== | ||
| by mbncp ( [[https:// | by mbncp ( [[https:// | ||
| 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 | ||
| + | | ||
| + | endfor | ||
| + | @End | ||
| + | </ | ||
| + | |||
| + | |||
| + | ===== Modification ===== | ||
| + | |||
| + | Per pad | ||
| + | * Channel | ||
| + | * CC | ||
| + | * Value for on and off state | ||
| + | all defined directly in the script code | ||
| + | |||
| + | < | ||
| + | // CC-Switch | ||
| + | // 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, | ||
| + | CCVal[ 8] = [0, | ||
| + | CCVal[16] = [0, | ||
| + | CCVal[24] = [0, | ||
| + | |||
| + | OutCC[0] = [10, | ||
| + | OutCC[8] = [40, | ||
| + | | ||
| + | OutCH[0] = [0, | ||
| + | OutCH[8] = [0, | ||
| + | |||
| + | // | ||
| + | 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], { ----------- | ||
| + | | ||
| + | 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], | ||
| + | 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], | ||
| TrigReset[LastPad] = 1 | TrigReset[LastPad] = 1 | ||
| Call @UpdateGUI | Call @UpdateGUI | ||