Home › Forums › General › Using Ctrlr › Demo panel for MIDI receive/transmit routines
- This topic has 70 replies, 4 voices, and was last updated 6 years, 5 months ago by human fly.
-
AuthorPosts
-
October 15, 2017 at 9:56 pm #73211
…meanwhile.. thinking of a way to save parameter values
to presets…(different thing here, another little detour):there’s a method called panelSaveCurrent, and the preset buttons
display which is active with a ‘led’ above it: this is just a
label with a text hyphen, which changes colour for off(dark)/on(orange)(this is to avoid using an imported image, and because Ctrlr doesn’t have
a native LED graphic)so, i was thinking that if ‘save’ checked “uiLabelTextColour” for all
button ‘leds’ to find out which one is ‘on’ ie: colour == FFD28008,
then that will be the preset to be saved ie: at this point, it will
just write the bytes to the corresponding presetData label.anyway, so if i could use something like this:
for i=1,4 do local s=L(panel:getComponent("ledText"..i):getProperty("uiLabelTextColour")) etc. end end
haven’t got it to work yet, but:
if i can get it to send a string, it can also collect the current values,
concatenate them, and send that instead.
well that’s the current idea anyway.October 15, 2017 at 10:25 pm #73212ok, this works: (hehe.. 😀 but i think the 2nd part could get rid of
all the ‘if/elseifs’ with another iteration -couldn’t get it to compile
like that though)for i=1,4 do local s=L(panel:getComponent("ledText"..i):getProperty("uiLabelTextColour")) if s == "FFD28008" then if i == 1 then panel:getComponent("lcd_presetData1"):setPropertyString("uiLabelText","saved1") elseif i == 2 then panel:getComponent("lcd_presetData2"):setPropertyString("uiLabelText","saved2") elseif i == 3 then panel:getComponent("lcd_presetData3"):setPropertyString("uiLabelText","saved3") elseif i == 4 then panel:getComponent("lcd_presetData4"):setPropertyString("uiLabelText","saved4") end end end
Attachments:
You must be logged in to view attached files.October 15, 2017 at 11:08 pm #73214here’s another one… now it can write the parameter
values for current preset selection to corresponding
display – the preset buttons *do not yet retrieve the
data*. that’s the next step, and then it will be
assigning retrieved data to update controls, hopefully.
(the methods need tidying up, now have stuff they don’t
need in the preset methods)Attachments:
You must be logged in to view attached files.October 16, 2017 at 1:37 am #73218It looks like sendMidiMessageNow doesn’t like receiving an empty string
if string.len(memB:toHexString(1)) >0 then panel:sendMidiMessageNow(CtrlrMidiMessage(memB)) end
Maybe the L() function is an alias for
std::string LGlobalFunctions::stringToLua (const String &string) { return (string.toUTF8().getAddress()); }
Looks like it converts the string to utf8.
Regards,
October 16, 2017 at 7:53 am #73225this morning’s installment: preset recall.
preset1 will recall values written to the label(should do!)
see demo panel below.(edit: just saw your reply )
edit2: all presets recall now, and the ‘send’ menu will get the
text from any presetData label to the DataA label at the bottom.
rockin’. 😀Attachments:
You must be logged in to view attached files.October 16, 2017 at 9:27 am #73228It looks like sendMidiMessageNow doesn’t like receiving an empty string
spot on: i commented out the sendMidiMessageNow line and it stopped crashing.
?what is utf8 ? does MIDI use that?
(google…
https://en.wikipedia.org/wiki/UTF-8 )
(this wiki does not enlighten me much…in this context)October 16, 2017 at 10:00 am #73229YEP: that fixed it – thanks again.
and here the ‘recv’ menu recalls values
to parameters/updating controls.Attachments:
You must be logged in to view attached files.October 17, 2017 at 7:39 am #73238quick attempt to add ten name bytes to the ‘preset’.
(see assignValues and saveCurrent)there’s something here to change the ledtext colour,
that i thought was working, but haven’t yet succeeded
in reproducing it with the ‘recv’ button (don’t know
if it would logically need to happen, if one was
recalling data to a different preset)>try the 2nd file, i couldn’t remove the first attachment.
made a quick change with hex string.Attachments:
You must be logged in to view attached files.October 18, 2017 at 8:55 pm #73246latest silly idea: i want to do something like this:
i have an ‘external bank’, a string representing 80 bytes of data,
that i need to retrieve, and split into 4 ‘presets’, with
something like this (this doesn’t work):--convert bank to table tabl_extBank = {} for i=1,80 do local s=L(memB) table.insert(tabl_extBank,s) end --console(tostring(tabl_extBank))
it doesn’t like
local s=L(memB)
-i think it needs to be converted
to a hex string first or something. the plan then is to select
table items in ranges to make new hex strings or strings to
represent the 4 presets in the bank.(any alternative ideas welcome
for this, i’m just progressing step by step. if it compiles, give
it a try, and then move on)here’s the panel:
(btw: found i can getSize() on a memblock so that’s what i’m
using here instead of midi message – what else can we ‘getSize’ on?
what’s the requirement?)Attachments:
You must be logged in to view attached files.October 20, 2017 at 7:23 am #73253*strange*: i have managed to create *new properties in the properties
pane* -??- by using ‘custom index’ to try to define ‘uiSliderThumbColour’
for a group of objects contained on a uiTabs.this now appears as a custom thumb colour, and it still has the original
thumb colour ( and i can’t seem to get rid of the new property…)see file below (is anyone following the topic?)
d*mn. will this cause problems later? do i have to go back to
previous file version?Attachments:
You must be logged in to view attached files.October 20, 2017 at 11:51 am #73256this is what i did:
--custom group items for k=1,10 do modul = panel:getModulatorWithProperty("modulatorCustomIndex",k) tab = modul:getComponent():getProperty("componentTabName") if tab =="tabs_ctrlrPanel" then modul:setProperty("uiSliderThumbColour","FFD28008", false) end end
so this has created a new property that only refers to ‘custom’ items
-and doesn’t do anything to the component on the panel, which still
has its regular “uiSliderThumbColour” property, remaining the colour
it was before. aagh. how do i get rid of the extra property now? 🙂and can you suggest anything as an alternative to what i’ve done to
select all slider components on the tab to change their thumb colour?October 21, 2017 at 11:26 am #73265I did that a few times and wrote a function to clear them.
Is this what you mean? You created a new modulator that is now showing on the panel editor menu (or whatever it is called)?
removeComponentsIcreated=function(NAME) --[[While developing I occasionally accidentally created a component or Modulator -- this code removes that entity--]] --[[ COMPONENTS --]] panel:getModulatorByName(NAME):getComponent():removeProperty("uiSliderThumbColour") --[[ MODULATORS --]] panel:getModulatorByName(NAME):removeProperty("uiSliderThumbColour") end --function
October 21, 2017 at 12:58 pm #73267umm, *nearly*: (i’m a bit worried about deleting an entire property
that i want here ! ) – if you look at the previous panel above, and
click on any fader modulator(component) and scroll down to the
‘custom’ entries, you will see an extra ‘thumb colour’ entry:
it has TWO thumb colour entries ! 🙂 (one is orange, and the other
is with the regular ‘component’ properties, and is blue.so i’ve created a uiSlider property that only refers to the ‘custom’
attributes … pretty weird…
it probably doesn’t matter too much, but may cause some issue somewhere
later – but i guess it’s like a plug that doesn’t have a socket to go into,
so may not matter, but it disturbs my..how to call it.. desire for
organisation? anyway, it’s an ‘anomaly’.maybe it should be removeCustomProperty?
October 21, 2017 at 2:15 pm #73268You created a Modulator called uiSliderThumbColour (orange) , but uiSliderThumbColour is a Component (blue).
You would need to make a backup and try something like this: 🙂
n = panel:getNumModulators() for i=0,n-1 do mod = panel:getModulatorByIndex(i) mod:removeProperty("uiSliderThumbColour") end
October 21, 2017 at 2:28 pm #73269hang on.. i’m struggling to understand that..
what do you mean? i *created a modulator*?
the modulator existed beforehand, but without that property.
i wrote and ran that method, and it created an extra ‘property’,
as far as i can see, on an existing modulator.because i did(whatever it was…)
modul = panel:getModulatorWithProperty("modulatorCustomIndex",k)
it seems to have added the ‘new’ property to the ‘custom’-relevant
properties.i’m not going to pretend i understand ‘custom’: it doesn’t behave
as expected. i just use this normally to ‘get’ a bunch of items
that i want to apply (normally a random) to. and in this case it
was so that i could have the thumb colour change on all faders each
time i switched presets which i thought could look quite cool.meeeeh, but i don’t have any problem going back a version, i didn’t
do that much in between v24 and v25, lost worse stuff before.just thought it was an interesting little glitch. hey it looks like
one could spend a lifetime finding out stuff like this..October 22, 2017 at 7:58 am #73270ker-raazy ! you da man, dnaldoog 😀
congrats, i have fixed it with that. brilliant.i have replaced the line:
modul:setProperty("uiSliderThumbColour","FFD28008", false)
with
modul:removeProperty("uiSliderThumbColour")
and ran it once, and the additional property is no longer there.
nb: this only relates to the
getModulatorWithProperty("modulatorCustomIndex",k)
thing that i did. not something you want to do in everyday use..okay, seems to be back to normal now, and will remove both of
those bits of code, and try to do it another way.>see the v.26 panel here, in the method: ‘panelPreset1’: it is
all commented out now.(you should be able to reproduce it by
using the first part once, then the second part, once, separately)so: what could you suggest to change ‘thumb colour’ on all
10 faders belonging to that uiTabs? bearing in mind that
already have a custom index.(mm: really do not grasp how the ‘custom’ properties work:
had originally assumed that they all related to each other,
but that does not seem to be the case, and now i find out
that it is not necessarily a viable way to ‘tag’ modulators
in order to apply an action to them.. merits a closer look,
detailed explanation.)- This reply was modified 6 years, 6 months ago by human fly.
Attachments:
You must be logged in to view attached files.October 22, 2017 at 2:10 pm #73273Glad it worked for you!
To change the thumb colour on all sliders, you could put them into an array:
_s={"wave","coarse","fine","cutoff","reso","atk","dec","sus","rel","level"} -- some example properties you can change for _,v in pairs(_s) do -- 'v' is each element in the array _s panel:getModulatorByName(v):getComponent():setProperty ("uiSliderRotaryTextColour","FF00FFFF",true) panel:getModulatorByName(v):getComponent():setProperty ("uiSliderRotaryFillColour","FFffFFFF",true) panel:getModulatorByName(v):getComponent():setProperty ("uiSliderThumbColour","FF00FF00",true) panel:getModulatorByName(v):getComponent():setProperty ("uiSliderValueBgColour","FF00FFFF",true) panel:getModulatorByName(v):getComponent():setProperty ("uiSliderValueTextColour","FF000000",true) panel:getModulatorByName(v):getComponent():setProperty ("uiSliderTrackColour","FF000000",true) end
then loop through and change any property you like. There is a full list of constructor?? (property) names in :
- panel -> modulator list -> View -> Visible Columns
..scroll down and you will see all the uiSlider constructors (I don’t know if that’s the right term) – looking down the list, you can see uiSliderThumbColour (you already know the name)
October 22, 2017 at 3:01 pm #73274ok, i will give that a try next.
something else i’m stuck on, is getting my big block of data,
the ‘bank’, which is a text string, and splitting that into
the 4 smaller ‘preset’ strings – i’ve been trying to put it
into a format where i can getRange()
ie: (1,20),(21,40),(41,60),(61,80)so i get this far:
-- Retrieving ext Bank extBank = L(panel:getModulatorByName("lcd_bankDataB"):getComponent():getProperty("uiLabelText")) console("Retreiving external bank : "..extBank) --make a memory block from the string memB = MemoryBlock(extBank) --check size of received dump local size = memB:getSize() console("midiMessageReceived: " .. size .. "bytes") if size == 80 then --bank dump console("bank dump detected!") end
but then it doesn’t like this:
--convert bank to table tabl_extBank = {} for i=1,80 do s=extBank:toHexString(1) table.insert(tabl_extBank,s) end
and tells me toHexString() is a nil value. i was then thinking
of doing getRange() on the table.it also doesn’t like:
preset1Data = L(memB:getRange(1, 20))
(i don’t really know what i can do with L() macros)
October 22, 2017 at 6:40 pm #73276ok, here are your slider thumbs with changing colours.
this is fun, and very useful.little question: you refer to this as an array: it looks
much like a table, using {} brackets. is that just a different
terminology, or to be considered as something distinct from a
table?
(tables have an index?)also, seeing the form you use: _s
why the ‘_’, and how is it that you can use the 2 characters,
‘_’ and ‘s’ separately? does it have to take this form? is it
a syntax form, or just something you are in the habit of using?(or, alternatively, why these characters, and why is ‘s’ used
so often? – in the same way ‘i’ is used for iterations, and i’ve
also seen ‘k’ used, as in the custom index example previously,
which i cribbed from methods i’ve seen.)Attachments:
You must be logged in to view attached files.October 23, 2017 at 2:05 am #73278I don’t know why I used ‘s’ 😕 – using an underscore for arrays is a matter of personal style for me, but I think underscore + capital letter should be avoided in Lua from what I read:
http://www.lua.org/pil/1.3.html You should avoid identifiers starting with an underscore followed by one or more uppercase letters (e.g., _VERSION); they are reserved for special uses in Lua. Usually, I reserve the identifier _ (a single underscore) for a dummy variable.
Maybe I should say table and not array? Maybe table is the more correct term in Lua?
i is commonly used as the index and v as the value in looping though
arraystables. If another counter is needed then j is often used and then k for key in associative arrays or tables, but of course generally variable names should have more descriptive titles. -
AuthorPosts
- The forum ‘Using Ctrlr’ is closed to new topics and replies.