Change CC number via scirpt?

Discuss Lemur and share techniques.
cliffman
Newbie
Posts: 11
Joined: 09 Dec 2011 22:34

Change CC number via scirpt?

Post 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.
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post 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.
cliffman
Newbie
Posts: 11
Joined: 09 Dec 2011 22:34

Re: Change CC number via scirpt?

Post by cliffman »

Thanks, seems cumbersome but doable. It would be nice to be able to change MIDI channel on the fly as well......
j5k
Newbie
Posts: 15
Joined: 09 Dec 2011 16:01

Re: Change CC number via scirpt?

Post 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.
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post 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, ....
j5k
Newbie
Posts: 15
Joined: 09 Dec 2011 16:01

Re: Change CC number via scirpt?

Post 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?
armatronix
Newbie
Posts: 18
Joined: 08 Dec 2011 02:00

Re: Change CC number via scirpt?

Post 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.
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post 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.
mat
Regular
Posts: 124
Joined: 08 Dec 2011 09:21
Location: Germany
Contact:

Re: Change CC number via scirpt?

Post 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
Lemur modules and sequencer: http://music-interface.com
Setup: Win7professional 32bit, Intel Core 2 Duo @ 2,66 GHz.,Tascam US-144MKII, Ableton Live 8.4,
Arturia Analog Lab., Max/Msp, Maxforlive, Lemur Legacy + Ipad, Akai MPK61, Doepfer Pocket Control
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post 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.
Post Reply