Home › Forums › General › Programming › getName
- This topic has 8 replies, 3 voices, and was last updated 6 years, 2 months ago by human fly.
-
AuthorPosts
-
February 17, 2018 at 8:34 am #81933
if you try to getName() on a specified modulator,
Ctrlr crashes, ie:local pitch = panel:getModulatorByName("2ndpitch")):getName()
so what workaround could i use?
i have modulators called:
‘2ndPitch’, ‘3rdPitch’, ‘4thPitch’
‘2ndLevel’, ‘3rdLevel’, ‘4thLevel’ etc.this is unusual because the number is usually at the end,
but i want to keep it as it is on the device, and get just
the first character with string.sub.adding the modulators to a table is tricky too, because i
want to use string.sub to identify them, using range 4,8
(ie: 5 characters, starting at 4th character)any ideas? thanks.
February 17, 2018 at 11:17 pm #81957I’m confused. Why do you need to get the name. You already have it in the getModulatorByName parameter.
Why don’t you just go string.sub(“2ndPitch”,1)
Your statement basically says “give me the name of the modulator with the name 2ndPitch”
The Puppeteer
http://godlike.com.auFebruary 18, 2018 at 8:25 am #81960well, yeah, except i want to ‘get’ the name, to
do something with it – ie: use part of the name
to identify several modulators (without using a
custom group, or VST index etc.)
dnaldoog had pointed out that the ‘visible name’ can
be used instead.i tried this:
local tbl_simul={} for i=2,4 do spitch= panel:getComponent("simpitch"..i):getProperty("componentVisibleName") sub=tonumber(string.sub(spitch,1,1)) table.insert(tbl_simul,sub) end
and test it with:
local simul = panel:getComponent("simul"):getValue() --(the selector) for i,v in ipairs(tbl_simul) do if tbl_simul<=simul then console(String("select="..tbl_simul)) end end
note i changed the modulator name here – tried numbers are at the end, to see
if it’s easier, so now it’s called simpitch2,..3,..4 – but Visible Name remains as before, ie: 2nd Pitch, 3rd, 4th
(sorry if that’s confusing, it wasn’t for preview yet)and: found that i had to define 3rd variable too, for the ‘sub’,
so it’sspitch,1,1
(ie: get 1st position, for 1 character)
– otherwise you get the rest of the string, to the end.this is as far as i got yesterday. i can return the pitch modulators,
and still have to get it to do level and pan.
have not yet worked out what i’m going to do with them yet.
ie: maybe setVisible – depends on the UI layout *that emerges* 🙂(these are individual voice parameters for the Yamaha RX7 drum pads,
so i have to decide whether to have a set of modulators for each of
the (24 pads x5 kits) – painful – or perhaps just one set of controls
that somehow combines with the currently selected pad and kit -???-
…
however, i still have to figure out how the RX7 really allocates
sounds, because it actually relates via Key Assign, and the 96? midi notes.
so you define a Voice, and this can have multiple assignations in
different kits.. meaning that if you edit the core Voice, it will
change it in all the kits. so i need to have a little think about that)February 18, 2018 at 5:09 pm #81961lol i’m the one that’s confused, i get confused all the time
with this stuff – mainly i forget things i’ve already learnt
while i’m trying to master new stuff 🙂i’ve got another example of this now, where i want to get a
modulator and change one of its component properties. it’s an
array of 24 buttons. now, i put them all in a table, so i have
this table, ‘tbl_pads’, and now i want to get at them, but of
course, if i print my table to console, i only get back the
Ctrlr Object IDs … d*mn… i’m really writing spaghetti code
now:i have 2 sets of buttons: one of 24 for the Pads, and one of 5,
for the Kits. the idea is that when i change Kit, the highlight
colour of the current Pad button switches to the Kit colour.so Kit select also has to find the current Pad and change the
highlight colour there too. i’m 80+% there with it. i can get
the pad number, as per table [ i ], but i need the modulator
name so that i can change its component property.so that’s why i’m trying to get the name like that.
hopefully you’re going to suggest something slick that i’m
not thinking of. (and i’ll post an example panel on the RX7
topic if i can get it working – possibly a useful UI thing)
(i seem to be more focused on getting little UI button things
working that actually getting sysex dump/loads to work, but hey)February 18, 2018 at 6:11 pm #81962success :p
terribly roundabout way of going about it, but i’m
chuffed i bodged it in. so here’s the raw junk:
(i go at it with a hammer if it don’t fit, so…)here are the ‘kits’, first part of the method:
function kitSelect(mod,value) -- This stops issues during panel bootup if panel:getRestoreState() or panel:getProgramState() then return end -- ------------------------------------------------------------ tbl_kcolourA ={"FF1291DF","FF1291DF","FF1291DF","FF1291DF","FF1291DF"} tbl_kcolourB ={"FF00FF00","FFFF9100","FFEAFF00","FF00FAFA","FFFF72F4"} -- ------------------------------------------------------------ tbl_kits={} --kit buttons as table for i=1,5 do kit=panel:getModulatorByName("keydata"..i-1)--[nb:kit number is offset]-- table.insert(tbl_kits,kit) --console(String("keydata="..i)) end -- ------------------------------------------------------------ --identify kit clicked local sName= L(mod:getName()) --console(String("kit="..sName)) local sub=tonumber(string.sub(sName,-1)+1) --console(String("sub="..sub-1)) -- ------------------------------------------------------------ for i,v in ipairs(tbl_kits) do if i ~= sub then colourA = tbl_kcolourA v:getComponent():setProperty("uiButtonTextColourOff",colourA, false) else colourB = tbl_kcolourB tbl_kits[ sub ]:getComponent():setProperty("uiButtonTextColourOff",colourB, false) end end
then i find the highlighted button in the set of 24 pads, and change
its colour to match the kit, with a subfunction:-- ------------------------------------------------------------ function pcolour() local tbl_pads={} --initialize same table name local tbl_padcolour={} --new button colour table --button table for i=1,24 do pad=panel:getModulatorByName("pad"..i) --collect objects table.insert(tbl_pads,pad) end for i,v in ipairs(tbl_pads) do local colour=tbl_pads:getComponent():getProperty("uiButtonTextColourOff") table.insert(tbl_padcolour,colour) end for i,v in ipairs(tbl_padcolour) do if v~="FF1291DF" then local select= i console(String("selected="..select))--[yessssss: current pad]-- pname= tbl_pads[ select ]--:getComponent():getProperty("componentVisibleName") end end -- ------------------------------------------------------------ --console(String("pname="..pname)) pname:getComponent():setProperty("uiButtonTextColourOff",colourB,false) -- ------------------------------------------------------------ end -- ------------------------------------------------------------ pcolour() -- ------------------------------------------------------------ end
hope this displays ok.
February 18, 2018 at 6:24 pm #81965current version of this panel is here if you want to
check out how it works out so far:February 20, 2018 at 12:36 pm #81972solved: this is doing what i needed:
function simul() -- This variable stops index issues during panel bootup if panel:getRestoreState() == true or panel:getProgramState() == true then return end -- ------------------------------------------------------------ local simul = panel:getComponent("simul"):getValue() local tbl_simul={} for i=2,4 do local spitch = panel:getComponent("simpitch"..i) table.insert(tbl_simul,spitch) local slevel = panel:getComponent("simlevel"..i) table.insert(tbl_simul,slevel) local span = panel:getComponent("simpan"..i) table.insert(tbl_simul,span) end -- for i,v in ipairs(tbl_simul) do local vname=tbl_simul:getProperty("componentVisibleName") local sub=tonumber(string.sub(vname,1,1)) if sub<=simul then tbl_simul[ i ]:setProperty("componentVisibility",1,false) else tbl_simul[ i ]:setProperty("componentVisibility",0,false) end end end
was a good way of finding out differences between ctrlr objects,
modulators, components, and properties 🙂February 25, 2018 at 4:57 pm #82458To come back to your original question (you always tend to divert and explain a lot fo things not related to the main topic 😉 ), I’m using this in my Pro2 panel quite often.
It works fine if you do as described in this piece of code:
`OnOff_OnChange = function(–[[ CtrlrModulator –]] mod, –[[ number –]] value, –[[ number –]] source)— No action while loading a program or if the panel is in bootstrap or program states
if bLoadingProgram or not isPanelReady() then
return
endsName= L(mod:getName())
if sName == “BankAutoSave” then
— Do this
end
if sName == “MidiSysexEnable” then
— Do that
end
if string.sub(sName,1, 5) == “Delay” and string.sub(sName,-4) == “Sync” then
— Do that
end
end
‘February 25, 2018 at 9:50 pm #82459thanks for summarising it well. that pretty much covers it.
unless you can think of other applications.( well, it’s true that my topics meander a little as my
learning curve evolves 🙂 ) -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.