Page 1 of 2
Change CC number via scirpt?
Posted: 09 Dec 2011 22:39
by cliffman
I would like to change the CC number assigned to a Fader dynamically, is such a thing possible?
The CC number on the MIDI properties does not appear to be mutable.
Re: Change CC number via scirpt?
Posted: 09 Dec 2011 23:10
by mbncp
AFAIK you can't change directly the midi settings but you can send the CC yourself in an On Expression script.
Select your fader, add a script, give the function some smart name (like OnChangeX)
Select On Expression from the list and type x in the following single line text box
Then below in the code text area, enter this:
ctlout(0,myCC,x*127,1); // 0 is the port, myCC the CC you want to send, x*127 if you want values between 0 and 127 and 1 is the channel
myCC can be a variable that you set using a menu or another fader or whatever actually.
If you want feedback you'll have to handle it as well.
Re: Change CC number via scirpt?
Posted: 09 Dec 2011 23:48
by cliffman
Thanks, seems cumbersome but doable. It would be nice to be able to change MIDI channel on the fly as well......
Re: Change CC number via scirpt?
Posted: 09 Dec 2011 23:51
by j5k
I agree. I actually just came here to ask if you can change the midi channel via script. That would be quite cool for something I'm working on atm.
Re: Change CC number via scirpt?
Posted: 10 Dec 2011 00:13
by mbncp
When you handle the midi out yourself you can can do anything you want, using a different port, message type , channel.
if you have 4 faders , one for the port, one to select a cc, one to select a channel and the 4th one to output the midi then you would have
ctlout(fPort.x*7, fCC.x*127, x*127, fChan.x*15+1);
Changing channel may be tricky in some situations, like sending notes were you have to send the note off to the correct channel, or you may want to reset a pitch wheel before switching channel, ....
Re: Change CC number via scirpt?
Posted: 10 Dec 2011 14:43
by j5k
Hopefully this is still on topic here. It would be handy if there was an event triggered right before midi is sent out. Just like onMidi but would be called onMidiOut or something.
A useful example would be a drum pad. This is completely pseudo code but hopefully gets the point across:
OnMidiOut(midi_args) :
If(useChannel2) {
midi_args.channel =2;
}
MidiOut(midi_args);
Thoughts?
Re: Change CC number via scirpt?
Posted: 10 Dec 2011 19:34
by armatronix
+1 I could use an onMidiOut function, or the ability to internally loop-back MIDI that gets sent out so you could use onMidi.
Re: Change CC number via scirpt?
Posted: 10 Dec 2011 20:35
by mbncp
Why not but that would create a problem with midi feedback, so this should probably be a port option for the control and if this special midi out is used then it's a special midi in function that should handle feedback.
Re: Change CC number via scirpt?
Posted: 11 Dec 2011 12:45
by mat
Hey,
there is also another way than "ctlout"...maybe less cryptic.
Create Custom MIDI
- click on that Midisymbol at the bottom of the right side (beneath Interface, variable etc...)
- make sure the object targets fit to your defined Midi targets on your Lemur.
- select as message "B0 - Control Change"
- select as value your Fader ("Fader.x"), triggered by "any".
- for controller or midichannel you can fill in anything, e.g. another object, variable or script or type in directly.
Example - Menu for choosing Midichannel: create menu with 16 options, numbered 1-16, fill in "LemurMenu.selection+1" in Custom Midis "channel"...
For Controller I would suggest 2 menus, combined as "(menu1*10)+menu2" .....11*10+3=113
That way you can easily control channel and controllernumber of an output.
There is one problem with this (but same with ctlout): Midifeedback does not work this way. Bidirectional midi only works for direct routing.
Hope that helps
Enjoy
mat
Re: Change CC number via scirpt?
Posted: 11 Dec 2011 14:02
by mbncp
Hey that's cool, at some point I was wondering what this custom MIDI was for but then forgot about it.
That's an elegant way to handle it and easier than scripting.
Feedback is not always needed but in case, you just need an array that keeps track of the individual CC number * channel used for each control, and refresh the control(s) on CC and/or channel change, and update the array on incoming MIDI.