Home › Forums › General › Programming › Quick question re: methodName (modulator, newValue)
- This topic has 9 replies, 2 voices, and was last updated 12 years, 1 month ago by LilCthulhu.
-
AuthorPosts
-
March 16, 2012 at 3:13 pm #541
Hi,
I’ve started implementing a new device panels, I’m a professional software developer, I just don’t have all the exp re: Lua ” title=”Wink” /> I will have few questions regarding the API and would like to hear from you guys ” title=”Wink” /> I’m planning to release this pannel ASAP and the IDE is going well…
The first question is : when you create a new method associated to a modulator, you get the following method definition:
methodName (modulator, newValue)
I’ve got no issue with newValue, however I tried "using" the modulator value as a modulator object (the same way you would get one by getting the modulator using it’s name, etc)… but I want that method to be associated with multiple modulator AND each time I access the modulator variable, I get an error… maybe I’m not doing it right… and console printing the type of the modulator returns a userdata and not a modulator object… Any ideas ?
Chris
March 16, 2012 at 5:35 pm #3812You can assign the same method for any number of modulators bu selecting it as a property for each modulator. The modulator variable is an object and you access it or modify it by its methods. Most of the stuff is done by getting or setting its properties. There are some examples in the dos directory of your ctrlr installation. What exactly are you trying to do in that method? Ill try to give you an example once I know what are you trying to achieve.
March 16, 2012 at 6:48 pm #3813Basically, I want some lua method to be responsible for sending sysex message to my keyboard instead of using the modulator sysex block.
The reason I prefer this approach is that by changing one method, I can alter the way sysex are sent and received from the keyboard and it’s far easier to edit ” title=”Wink” /> I’m planing on using the custom modulator group value (or the modulator’s ui group custom index) (GV) + custom modulator index (MI) as an the address of the sysex msg and newValue (NV) the new value…
GV+MI would be the address in two hex char… for example
GV = h52, MI = h02, NV = h64 … then sysex would be " … 00 54 64 …"
GV = h7F, MI = h05, NV = h62 … then sysex would be " … 01 05 62 …"Upon receiving sysex, I could use the same address scheme to assign value to my modulators since the unique index of each of my modulator would be the direct address of the sysex, for example… upon receiving address 01 05, I would direct the value to modulator index # 132… All other non-sysex object would be in higher indexes not affected…
Then assigning received sysex would simply be a matter of looping through the array and sending the value of the dump to the modulators instead of referencing each modulators…
Basically I’m trying to target both a famous synth from the 90s + it’s rack version (that had more parameters) with the same panel ” title=”Wink” />
I don’t know if it makes sense but I know it does for me ” title=”Wink” />
March 16, 2012 at 6:51 pm #3814So when I get the modulator variable in the method. I expect to write somehting like this ( I don’t know the real lui api yet so this is pseudo code)
address = modulator.CustomModulatorGroupValue + modulator.CustumModulatorIndex
sendSysex("F7 … … " + address + newValue + checksum + "F0")
The actual sending of sysex could be another "hidden" modulator ” title=”Wink” />
Thanks
March 16, 2012 at 8:19 pm #3815Your code should like this (inside the method)
[code:2ozhzfvq]
address = modulator:getPropertyInt("modulatorCustomIndex") + modulator:getPropertyInt("modulatorCustomIndexGroup")
checksum = 2+2 — or whatever calculation you need to do
midiMessage = CtrlrMidiMessage(string.format ("F7 %.2x %.2x %.2x F0", address, newValue, checksum))
panel:sendLuaMidiMessageNow(midiMessage)
[/code:2ozhzfvq]March 16, 2012 at 8:28 pm #3816THANKS !!! Wow ” title=”Wink” /> Btw, does my thinking make sense ? doing it like that… the other reason I’m doing it like that is that I have around 50+ parameters per tone, and I have 4 tones + 1 other one I need to keep for modifying more than one tone at the same time… so that makes around 200 sysex code + some others… maybe a total of 300-400 possible parameters ” title=”Wink” />.
Of course, I could use only one set of visuals for all 4 tones, but I want the user to be able to see/update each tone independantly and be able to switch from one tone to the other… I could refresh from the keyboard each time a tone is displayed which is what I might do also… I’m not there yet ” title=”Wink” />
March 16, 2012 at 9:12 pm #3817It makes sense though i’d urge you to avoid LUA if not needed, apart from the checksum all the sysex stuff can be done without LUA. If you can tell me how to do the checksum or provied a working code in c/c++ i’ll add that to my collection and everything will be done within Ctrlr without LUA (there is already a checksum sysex modifier for the Roland JP synths, it will be just another one there). Also without lua you will get automatic input matching, the only LUA code you’d need to write would be for the program dump/send for the synths.
March 16, 2012 at 11:02 pm #3818I’ve already tackled a lot of the issues in advance (because your IDE already provide MOST of what we need), was able to figure out the checksum calculation using your Roland checksum just by changing the Z value (don’t know if it suceeded randomly or if it makes sense, but it works so far)… my targets are also Rolands, so it kind of make sense. I suppose the Z value is a mean to determine the array size of hex parameters on which to calculate the checksum… I’ve also figure out the proper way to calculate values ranging from -50 to 50 in the gui but 0-100 in the sysex, etc. So far I’ve been able to figure out mostly everything.
I’ve even managed to modify the xml files directly for majors modifications.. I’ve also sorted the modulators/labels in the xml files by sections… I’ve created multiple panels and will be "merging" them when ready ” title=”Wink” /> I started last sunday and spent a little bit of time on it…
March 16, 2012 at 11:09 pm #3819Try not to change the XMLs manually if you are a developer there is a LUA console that you can use to automatic changes to all modulators with one simple loop. Apart from that do whatever you like ” title=”Smile” /> thats what it’s for let me know if i can help with anything.
The checksum is for the JP series but i imagine roland uses the same algorithm for most of it’s sysex implementation so that might work for a lot of hardware.
March 20, 2012 at 3:44 pm #3820Well, as for the LUA console, I actually did quite a few things there by going through a loop on the modulators, quite handy… I’ve also seen that it can add properties to objects (if you make a mistakes, etc) which can be a good thing or not… n’way. I’ve found that adding 4 sets of modulators for 4 tones was easier by editing the xmls, once the first set was done, it was a matter of find and replace ” title=”Wink” />… I still need to fix all those vstindex ” title=”Wink” /> but it was quick ” title=”Wink” /> Also, I’ve sorted the xmls files so it’s easier to locate an issue that way, I’ve got all my groups with all my labels and afterward my modulator s;)
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.