Home › Forums › General › Programming › Help Tried to index memoryblocks..
- This topic has 6 replies, 3 voices, and was last updated 10 years, 8 months ago by zeoka.
-
AuthorPosts
-
August 13, 2013 at 5:21 pm #11902
Hi i try to index many memoryblocks to have multiple usages with them
( in this case a button to send a midi message)
– i’ ve a method with sound = print(..
that gives error : At line[-1]: [C] No such operator defined– and other method with sound = …
that gives error : At line[-1]: [C] std::exception:’unable to make cast’i think i’m near but a thing is not correct
please if anyone see…..It’s seems lua editor has a problem with long lines because i can’t see the end of memoryblocs in Bank2()….. may be it is the exception ?
The script was made in TXT file and pasted in Bank2 because i couldn’t in lua- This topic was modified 10 years, 8 months ago by zeoka.
- This topic was modified 10 years, 8 months ago by zeoka.
- This topic was modified 10 years, 8 months ago by zeoka.
Attachments:
You must be logged in to view attached files.August 13, 2013 at 7:48 pm #11923Ok i get it
mytable = function(mod, value) send2mem = panel:getModulatorByName("modulator-2") sndmp = send2mem:getValue() ptchslct = panel:getModulatorByName("modulator-1"):getValue() Bank2() if sndmp == 1 then bk2 = factory2001[ptchslct + 1] -- just a text panel:getLabelComponent("modulator-3"):setText (bk2:toHexString(1)) -- the midi m = CtrlrMidiMessage(bk2:toHexString(1)) panel:sendMidiMessageNow(m) end end
but
i send a full midi message with f0 and f7
and i need to remove the six first bytes of my messages to replace by variables
so my question is how to add variables at the begining of “bk2” data ?
tried :
bk2full = f0,(bk2),f7
or
bk2full = string.format(f0%sf7,bk2)
m = CtrlrMidiMessage(bk2full:toHexString(1))I really can’t figure how to rebuild data….
August 14, 2013 at 4:01 am #11938I get it
mytable = function(mod, value) send2mem = panel:getModulatorByName("modulator-2") sndmp = send2mem:getValue() ptchslct = panel:getModulatorByName("modulator-1"):getValue() byte = {} byte[1] = 240 byte[2] = 62 byte[3] = 16 byte[4] = 0 byte[5] = panel:getModulatorByName("modulator-4"):getValue() byte[6] = panel:getModulatorByName("modulator-5"):getValue() byte[7] = panel:getModulatorByName("modulator-6"):getValue() syx = MemoryBlock (byte) Bank2() --trigger btn if sndmp == 1 then bk2 = factory2001[ptchslct + 1] fullmsg = MemoryBlock(string.format("%s %s", syx:toHexString(1),bk2:toHexString(1))) -- just a temp text to see panel:getLabelComponent("modulator-3"):setText(string.format("%s %s", syx:toHexString(1),bk2:toHexString(1))) -- the midi m = CtrlrMidiMessage(fullmsg:toHexString(1)) panel:sendMidiMessageNow(m) end end
I ve just copied formula used for text info into a new memoryblock..
a entire day for that
August 14, 2013 at 7:12 pm #11951…
a entire day for that
yeah those are rough days but they’re usually followed with a lot of things falling into place faster than you had planned… hopefully that’s what you’re experiencing now 🙂
Stupid question: I notice when you convert to a hex string you’re adding a 1 between the parenthesis.. what’s the difference between:
(blah:toHexString()) and (blah:toHexString(1))? I don’t think I’ve ever put anything within the “()” when converting like that.Monstrum Media | Music, Sound & Software Design, Chicago / San Francisco listen
August 14, 2013 at 7:23 pm #11952It’s a grouping parameter, 1 means one-byte then space, 2 means 2 bytes then space etc.
August 14, 2013 at 9:15 pm #11954Yes
Without : this is for a byte
and with : this is for user dataI start to like LUA tables i will use them more…
for receive patch ,save mod to custom Library , send patch properly to synth when ctrlr snapshots changemsepsis wrote :
yeah those are rough days but they’re usually followed with a lot of things falling into place faster than you had planned… hopefully that’s what you’re experiencing now 🙂
Yeah next step is draw and all mouse actions but i have to do a lot before- This reply was modified 10 years, 8 months ago by zeoka.
August 15, 2013 at 12:27 pm #11979Hi this is an simple example to have an index variable :
bufftype = panel:getModulatorByName(“modulator-5”):getValue()
typval = ptchtype:getValue()
if typval == 0 then
if bufftype == 0 then byte[6] = 48
elseif bufftype == 1 then byte[6] = 64
elseif bufftype == 2 then byte[6] = 65
elseif bufftype == 3 then byte[6] = 66 end
elseif typval >= 1 then
if bufftype <= 1 then byte[6] = (bufftype *32) + 32 end end end this is the byte 6 of "syx" memoryblock seen above.This script is added to the script above , instead of previous line + to the attached mod The cool thing with tables :it's they can be used several times for multiple purposes. EX in theory the same table can receive a patch from a device and from a file or ctrlr snapshots- This reply was modified 10 years, 8 months ago by zeoka.
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.