Change CC number via scirpt?

Discuss Lemur and share techniques.
kraftf
Regular
Posts: 124
Joined: 14 Dec 2011 06:36

Re: Change CC number via scirpt?

Post by kraftf »

mbncp wrote:
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.
Can you explain that a bit more with an eample?
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post by mbncp »

kraftf wrote:
mbncp wrote:
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.
Can you explain that a bit more with an eample?
If we use more than one cc and/or channel for a single fader then we need to store these values so when we switch cc/channel we can reflect their actual values.
Also in case these values are changed on feedback we need to store them as well.

For this we need a variable that stores the value for each cc/channel pair.
Then an on expression script to store the changes we make in lemur
and an On Midi script to store the values on feedback change.
Then we need another on expression function for the control that makes the cc channel selection, so we can update our fader.

If we have only different cc's or channels then we need a simple array:
example using 4 ccs, we create a variable:
myFaderValues = {0,0,0,0}
We access the correct item with something like that:
index = currentCC - lowestCC;
myFaderValues[index] = value;

In case we use different cc and channels, example 4 CC and 2 channels our variable would be like this
myFaderValues = { {0,0,0,0} , {0,0,0,0} }
in this case we access the correct value this way:
index = (currentChannel - lowestChannel - 1) * (currentCC - lowestCC);
myFaderValues[index] = value;

Then all we need to do is to get or set values from that array in the different script and update the fader when needed (external midi in or cc/channel change).

On request I could make a real example when I'm back to my machine.
kraftf
Regular
Posts: 124
Joined: 14 Dec 2011 06:36

Re: Change CC number via scirpt?

Post by kraftf »

mbncp wrote:
kraftf wrote:
mbncp wrote:
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.
Can you explain that a bit more with an eample?
If we use more than one cc and/or channel for a single fader then we need to store these values so when we switch cc/channel we can reflect their actual values.
Also in case these values are changed on feedback we need to store them as well.

For this we need a variable that stores the value for each cc/channel pair.
Then an on expression script to store the changes we make in lemur
and an On Midi script to store the values on feedback change.
Then we need another on expression function for the control that makes the cc channel selection, so we can update our fader.

If we have only different cc's or channels then we need a simple array:
example using 4 ccs, we create a variable:
myFaderValues = {0,0,0,0}
We access the correct item with something like that:
index = currentCC - lowestCC;
myFaderValues[index] = value;

In case we use different cc and channels, example 4 CC and 2 channels our variable would be like this
myFaderValues = { {0,0,0,0} , {0,0,0,0} }
in this case we access the correct value this way:
index = (currentChannel - lowestChannel - 1) * (currentCC - lowestCC);
myFaderValues[index] = value;

Then all we need to do is to get or set values from that array in the different script and update the fader when needed (external midi in or cc/channel change).

On request I could make a real example when I'm back to my machine.
Yes that's exactly what I; trying to do but I can't make it yet.
I have a multislider that sends 8 different CCs in one channel with a custom midi message.
I've created an array called midiwatch={0,0,0,0,0,0,0,0}.
Now I've made a script called trackCC to respond to On Midi. In the arguments I select control numbers 8 to 15 on channel 1.

And now what?????I I don't know how to handle the incoming midi CCs. How sould I reference the cc value, the midi channel?????There is no documentation about it.
God the manual is incomlete for a newcomer.
So to get back to my problem:
I've put inside the script this code

midiwatch[x]=x;
Is the x valid?
Does x mean the incoming array from midi ?
How would you define currectCC and lowest CC?From midi_Args?
Please enlighten me. There is nothing inside the manual how to track incoming midi,
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post by mbncp »

I just made a script that makes it pretty easy to use multiple object that can use multiple cc with feedback, but all object must share the same amount of CCs.
Let's say you have controls for volume, pan, mute, solo, ... but only one of them. With this script you can access any number of tracks (or whatever) with these single objects.

I'm done but I need to do some testing first and it's getting late ... Posting soon.
mbncp
Regular
Posts: 87
Joined: 08 Dec 2011 07:25

Re: Change CC number via scirpt?

Post by mbncp »

multiCC.jzml.zip
Project example using multiple CC
(2.7 KiB) Downloaded 203 times
So this project let's you use multiple object that can deal with different cc. There is a switch in radio mode that selects the cc index.
When adding, removing object make sure to update the TODO section found in the OnLoad script of the multiCC object.
To add a control, you can just alt+drag/drop an existing one and update the array.
If you create a new control make sure to add a call and index variable (expression) and an OnChange script with execution set to On Expression x with this single line of code:
setexpression(call, 'Trigger', {index, x});

Note that I haven't used custom midi, as scripting is already involved it's easier this way.
You could use a menu or whatever to switch the cc index, make sure that this control sends the new index to the multiCC object:
multiCC.OnIndexChange(somevalue);

You can have multiple multiCC objects in a project, just make sure to update me = in the todo section
me = multiCC2;
And avoid using the same objects, cc-channels combo or you''ll go into troubles ;)

Btw, if you click on the multiCC object (a pad actually), this just calls OnLoad and all variable are initialized. I noticed that sometime this is needed as the OnLoad function doesn't get always called.
Post Reply