Great!
So, in your example, I was able to isolate the part of the code that controls the CC Sender slider.
portNum = PORT_1
midiChannel = 1
prefix = " "
function sendRevLevel(valueObject,value)
ccNum = valueObject:getMessage():getParameterNumber()
midi.sendControlChange(portNum,midiChannel,ccNum,127-value)
midi.sendControlChange(portNum,midiChannel,ccNum+2,value)
midi.sendControlChange(portNum,midiChannel,ccNum+5,value % 16)
end
I changed some values, and got the results I expected, so so far so good.
-
I understan what the portNum and midiChannel do: they define the devices to which this LUA function will send respective MIDI CC. Do I understand it correctly tht āmidiChannelā is not a standard predefined command, but just a name used inside this specific LUA script, and could be ChannelNumber or any other word? Same for portNum?
-
What exactly is prefix = " " for?
-
Do I understand it correctly, that this string:
ccNum = valueObject:getMessage():getParameterNumber()
is reading the PARAMETER field in a faderās settings? And if so - how does it know which fader to ālisten toā? From which fader to read this value?
I tried to copy the CC Sender fader in your excellent preset and paste it on the same page, then change the number in its PARAMETER field to differ from the original. Both encoders were sending programmed CCs. How do I tell E1 what encoder (what virtual CC value) to listen to?
@kiwigrass , thank you for additional hints in the LUA script, things are starting to make much more sense than before!
The preset commands were very useful! Is there a similar LUA function to send MIDI messages when calling a page within a preset?
prefix = āā was there for another example. If you are building up a string, sometimes you may want to display more than 0-127 (or whatever). The formatter functions are where that would be used. I made a quick adjustment (hope it didnāt break things, my E1 isnāt connected). Turn the polarity or octave control to see prefix used. Again, the name is not great, but you get the idea.
yes - midiChan, portNum and all that are local names I used for those things. Much easier when the script gets big to change it in 1 place (or have the user able to change it with another control) instead of looking through everything and hoping you changed them all correctly.
If you notice,
ccNum = valueObject:getMessage():getParameterNumber() is inside a function called sendRevLevel (yet another leftover name - didnāt have time yesterday to make all this pretty).
and more importantly, when you look at all the controls you see in the function column for the one control the name sendRevLevel. So that control will call that function and that function will read that controlās parameter number and use that as the CC number.
In the old days, if you copied a control it kept the same parameter number and you had to manually edit it to something different. You can see below each control there is a value box and next to is is virtual #16. That tells you the control is virtual and has the parameter number of 16 assigned to it.
If the controls have different numbers, the function (in this case sendRevLevel) grabs the number from the controller when it changes.
The beauty of this is that you only need 1 function to do something and it will āaskā the control for itās parameter number each time.
1 Like
There sure is! The lua extension guide has all the relevant info. You can tell the E1 to go to specific page (maybe use a momentary button, or a list if you want to select from several pages) and on entering the page to do stuff. Lua extension | Electra One Documentation
I use this function a lot:
pages.onChange(newPageId, oldPageId)
A callback function that runs automatically when the user switches to a different page. The function is called only if Page change notifications have been subscribed to.
For example:
events.subscribe(PAGES)
function pages.onChange(newPageId, oldPageId)
print ("old: " .. oldPageId)
print (ānew:ā .. newPageId)
end
You could condition what to do if the newPageId is 1, or 2, or 3 etc. See my previous example for the if x then y logic.
You can use this function to change the currently displayed page
pages.display(pageId)
where pageId is a numeric identifier of the Page (1 .. 12).
But again, the lua extension guide is your best friend.
1 Like
The Lua extension guide is my go to reference for sure. However, for ānew to Luaā folks it can be frustrating.
Experienced programmers know they need some particular function, so we scan the guide for the syntax.
New users want to do something, but they donāt know what they are looking for so scanning the guide is very hit or miss.
Thatās why small, specific example presets are so useful. It gives the framework for a task. Once they understand the simple and can start modifying it, then the guide becomes essential.
2 Likes
Agree. As someone who came to this with limited programming experience the lua guide was very useful though IMO. If I wanted to do something when I change a page I would look at the guide for things in the pages and page section. And then ask your advice when my code didnāt didnāt work as expected. So my suggestion is a blended approach - examples and the guide. After 4 years I still use that approach. The guide contains examples of some of the functions use which is also very helpful.
1 Like
Thank you all so much!
First, by using parts of the code from your examples, I was already able to achieve a lot of what I wanted to achieve, so this is a great start!
Second, I will definitely study the LUA Extensions guide. I agree, itās not the easiest topic to digest for someone unititiated, but I will do my homework first, and then, if I need expert advice - I know where I can find it. What a great community here, canāt say enough how grateful I am to your assistance!
Hi! Me again ))
Those two examples that you kindly provided to me, were really invaluable!
Spent a couple of evenings reading the LUA extension guide and exchanging some mutual accusations with Google AI ))), but after those couple of evenings I learned how to:
- Target a specific control on a page
- Listen to and actually use the capacitive touch events (I managed to toggle a pad touching the control!))) Was very proud of myself!)
- Send multiple commands from the same control
- Change its color depending on the value
- Display custom text overlay for value ranges
This 0.00001% of E1 capabilities already gave me like 500% more convenience, customizability and usability compared to any other MIDI controller I owned.
Once again, thanks for your help and for pointing the right direction for me! I am sure Iāll come back with some more questions, but for the time being I will focus on making a couple of presets myself, and see how it goes.
1 Like
great to hear about your progress. Thatās the way this community has been built.
New folks come in, ask questions, learn, and then start helping others.
Itās one of the finest examples of how a user forum is supposed to work that I have ever seen.
1 Like
OK, dear community, with your excellent help and some torturing of Google AI, I created a preset to control Kinotone Ribbons - an incredibly deep pedal with so many features that mastering them all without a strong visual help can be really hard.
This is where E1 came in so handy!
I will post a link to this preset (it is far from being finished, but it does not crash, which is areadly great ))) to ask a couple of technical questions the AI failed miserably to help me with. Iād be very grateful if someone could share some thoughts or point me in the right direction.
My first question is as follows. I managed to trigger a toggle pad with a capacitive touch of one of the encoders. It works very nicely, but my script (or shall I say the AI-proposed script that finally worked) has one problem: the capacitive touch action triggers the pad toggle action even if the row in which this pad is located is not currently selected. In other words, even if I twist the encoder to control a fader elsewhere on the page (or even on a different page), the pad is toggled.
Is there a way to somehow isolate the capacitive touch triggering to only when the control is a) on a current page, and b) in the currently selected ārowā?
The control ID that is being toggled by capacitive touch in my scrip is #8, and the encoder ID is also 8 - by pure coincidence!) (second from the left in the lower row of encoders).
I have a gut feeling that my function that triggers the pad toggle is a bit too global, but I am not sure how to make it more local.
Thank you in advance!