Home › Forums › General › Programming › simple sequencer
Tagged: sequencer
- This topic has 162 replies, 3 voices, and was last updated 6 years, 2 months ago by human fly.
-
AuthorPosts
-
November 14, 2017 at 8:20 am #73522
revisiting an idea i was working on previously. realised i’d
uploaded it as a *.panel (with no led images) rather than a
*.bpanelz – so here it is again, with new ‘label leds’ as well,
and i will ditch the images next.looking to optimize this a lot, and develop it into something
viable.
see file below > (hope this has drafted correctly..file seems
smaller than the *.panel > 62kb vs 260kb …??)Attachments:
You must be logged in to view attached files.November 20, 2017 at 10:38 pm #73595(at the great risk of being irritating 😉 …)
LEDs: here’s is how i am displaying sequence progress,
‘longhand’ (working):function backupSeqLEDs1() if count == 1 then ledtext1:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext1:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 2 then ledtext2:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext2:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 3 then ledtext3:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext3:setProperty("uiLabelTextColour", "FF0E2B01", false) end etc... if count == 15 then ledtext15:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext15:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 16 then ledtext16:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext16:setProperty("uiLabelTextColour", "FF0E2B01", false) end end
and this is what i’m trying to optimize it (but doesn’t work):
function seqLEDs() for i = 1,16 do local led = L(panel:getComponent("ledtext"..i)) if count == i then led:setProperty("uiLabelTextColour", "FF67EF00", false) else led:setProperty("uiLabelTextColour", "FF0E2B01", false) end end end
callBack error:
Namewhat: global Name: L Error message: No matching overload found, candidates: std::string L(String const&)
it is crashing the ‘runstop’ method that calls ‘seqLEDs()’.
first attempt, tbh.November 21, 2017 at 9:33 am #73601this is starting too look like something now.
have not resolved that issue for iterating the ‘verbose’ code,
but i’ve got leds running with start and end point and direction.
(method listing needs tidying up a bit, fair bit of junk in there)
see panel below 😉*edit* : there is, in fact, a problem with this: ‘runstop’ crashes
on load-up. trying to fix that now. but if you recompile it, it
will/should run. problem with declaration (??)
>>Attachments:
You must be logged in to view attached files.November 21, 2017 at 2:09 pm #73609That’s great Human Fly, but I don’t think you need that break statement in the while loop, because if a >= b the while loop is never entered anyway.
t={} a=0 b=32 while( a < b) do --[ print("value of a:", a) --] --console(String("value of a:"..a)) a=a+1 --if( a > b ) --then --[ terminate the loop using break statement --] --break --end --[ put all returns into table --] table.insert(t,a) --[ concatenate to a single string with spaces --] end print(table.concat(t, " "))
November 21, 2017 at 3:37 pm #73610?!
ace ! i never knew about that online compiler 🙂dunno about that ‘break’ – at that point i was getting
anxious about ‘while’ sending Ctrlr on endless loops
and crashing.i see: you are talking about the Loops topic.
i haven’t got ‘while’ in this sequencer panel.hey it looks like we’re getting a lot of spam today !!
american football commentary ??November 21, 2017 at 4:41 pm #73612Yes, while loops can be lethal!
November 21, 2017 at 6:31 pm #73613myLittleSequencer (tm :p ) is definitely having some strange issues
on startup. this time it managed to find a ‘count’ (not nil return,
crash of ‘runstop() ), maybe in one of the junk methods, and it was
jumping around like it was nuts, at high speed.maybe i should sideline bi-directional flow for the time being, while
i sort out some optimisation, and work out how to do ‘XOR’ with the
Gate buttons – i can do this, but not in condensed form – i don’t know
if an iteration is the right thing to do here, because it just spits
it all out in one go.why am i doing this? > i’ve done a lot of this kind of thing in
synthedit, where problem solving is visually oriented.
-faster, more creative in many ways –
but it involves huge amounts of repetition and time if you can’t code
your own modules, and at some point, my computer of the time
just couldn’t handle it anymore. nor could i … had to bail out
before i reached an objective that was within sight, very frustrating.
(so i’ve still got a few little things to add..)could you have a look at ‘gateXOR_All()’, see if you can suggest a
way of condensing that? going to have another crack at it now,
didn’t have much luck the other day.November 22, 2017 at 2:09 am #73619Does this work?
function gateXOR_All() ---- single function for all XOR leds for i=1,16 do _G["gate"..i]=panel:getModulatorByName("gate"..i):getValue() _G["buttonSTEP"..i]= panel:getModulatorByName("buttonSTEP"..i):getValue() _G["ledtext"..i] = panel:getModulatorByName("ledtext"..i):getComponent() end -- loop for i=1,16 do if _G["gate"..i] ~= _G["buttonSTEP"..i ] then _G["ledtext"..i]:setProperty("uiLabelTextColour", "FF67EF00", false) else _G["ledtext"..i]:setProperty("uiLabelTextColour", "FF0E2B01", false) end end console("gateXOR_All() fired") end --function
November 22, 2017 at 10:29 am #73630i will try that.
what is ‘_G[…]’ ?although i have tried something similar – but i might have
done it wrong. a few days ago, earlier in the project, but
no significant difference with those items.will this not plop it all out in one go? or will it just
run the whole thing at each step/event? (s’pose so, if
it is call via the runcallback).was wondering also about building them into tables.
(will have to try this this evening)ps: oh yeah: my attempt was with 3 separate loops, i,j,k,
significantly different.November 22, 2017 at 12:57 pm #73631well, it is definitely not NOT working …
the code is being read ok, and the leds are a’flashing ..
so it’s promising. but ‘on’ gates are not keeping the
leds in the correct state at the moment. will have to
inspect more closely later.
(just gave a quick test)November 23, 2017 at 2:21 am #73635I read up about _G[], but gee it’s a bit complex, but I think essentially it allows the creation of a variable name at runtime which is added to the list of global variables. Something like that!
November 23, 2017 at 7:42 am #73636indeed. it looks easier to understand in its form
(once you look at it a bit) than it does through an
explanation like this >https://stackoverflow.com/questions/35910099/how-special-is-the-global-variable-g
!!
edit: just realised:
sorry: forget to say that ‘buttonSTEP’s are no longer being used.
that is now ‘count’ – i was using those before, to simulate the
count.November 23, 2017 at 8:17 am #73637Heavy reading!
November 23, 2017 at 8:53 am #73638yeah…
re: the panel – i need to tidy it up a bit and get rid of all
the old stuff. essentially, XOR led action stopped working a
while back, once i switched to driving the LEDs with ‘count’
addressing seqLEDs() -*forgot to point that out woops*-but XOR was working by comparing the step button (now renamed ‘gate’)
with what i was calling ‘buttonSTEP’ – and XOR is basically: ‘~=’
(buttonSTEPs depended on a count1_16 fader, that i have also removed)so now instead, i have ‘count’, which is a virtual concept, since it
has no ‘object’ on screen. it’s a global variable. and is returning nil
on startup, with ‘runstop()’, which depends on it – via ‘seqLEDs()’,
maybe? (LOL, need to tidying this up/cut it down)meaning that it will/should be: (gate..i) ~= (count..i) = (ledstate..i)
(that isn’t code – just a visual representation)(as you can see, seqLEDs() is also ‘longform’ and could be iterated)
but (this morning’s question): *how do i get hold of ‘count’* ?
1/ at startup
2/ as a variable, so that it is always ‘known’? eg: not nili’m going to ponder that but right now i’m tidying the thing up a
bit and backing up to a cutdown new version.November 23, 2017 at 10:59 am #73639What I do is create hidden sliders and use them to store ‘global’ variables. That solves question \2, but I don’t know how to keep a value at start-up
\1.On the JD-990 if you hide the top panel, you’ll see about 20 hidden sliders. I found that to be a better solution than creating global variables in Lua. I must have been having a problem somewhere that made me do that, but an example could be when you do a sysex dump and there are some values you don’t need to assign to a uiSlider; you can send them to a hidden slider rather than doing many “if value = n then ignore else assign to slider” statements. Hope this makes sense.
November 23, 2017 at 11:09 am #73640that’s a good idea for my D-110 panel, for the ‘wave/bank’
parameter, which, for interface purposes, i’ve split into
sqr/saw select, and pcmBank select. could resolve the possible
VST index issues there … will have a think about that.i suppose another way to describe my issue is to just
talk about the seqLEDs method, which goes:function seqLEDs() if count == 1 then ledtext1:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext1:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 2 then ledtext2:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext2:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 3 then ledtext3:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext3:setProperty("uiLabelTextColour", "FF0E2B01", false) end etc... if count == 15 then ledtext15:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext15:setProperty("uiLabelTextColour", "FF0E2B01", false) end if count == 16 then ledtext16:setProperty("uiLabelTextColour", "FF67EF00", false) else ledtext16:setProperty("uiLabelTextColour", "FF0E2B01", false) end end
so it refers to ‘count’.
i also have: (this is the method that crashes on start)
function runStop(timerId) runstop = panel:getModulatorByName("runstop"):getValue() -- -------------------------------------------- function leftRight() count=count+1 if count > last then count = start end end -- -------------------------------------------- function rightLeft() count=count-1 if count < last then count = start end end -- --------------------------------------------- --local count = 0 -- tried this -- if runstop == 1 then console(String("count start")) panel:getComponent("label_runstop"):setPropertyString("uiLabelText","run") local base = 60000 local bpm = panel:getModulatorByName("tempo"):getValue() millisec = base/bpm/4 --start timer timer:setCallback (1, runCallback) timer:startTimer(1, millisec) elseif runstop == 0 then console(String("count stop")) panel:getComponent("label_runstop"):setPropertyString("uiLabelText","stop") --stop timer timer:stopTimer(1) --reset() -- count=1 -- tried this... -- if leftRight()==true then count = start elseif rightLeft()==true then count = last end panel:getComponent("label_count"):setPropertyString("uiLabelText",""..count) seqLEDs() end end
November 23, 2017 at 11:16 am #73641think i somehow need to make a variable that represents
count. or maybe just have a table ? would that not be
the simple solution ?the strange thing is that sometimes the crashing method
DOES run on startup, and produces mad jittering led display.
so it finds something *sometimes*. weird.November 23, 2017 at 11:28 am #73642That looks like you are testing the function leftRight() for a boolean value but the function doesn’t have a return statement, so this will either throw an error or return something meaningless
if leftRight()==true
.November 23, 2017 at 3:39 pm #73643indeed, it seems to fix it if i disable those boolean
arguments. those are there to determine the reset
points, wherever the startpoint is, whether it is
before the end -left>right direction – or after the end -right>left-so i’ll have to find a new way to do that.
got rid of the startup crash anyway 🙂November 23, 2017 at 3:44 pm #73644would be nice to have the tempo vary in realtime.
maybe a function to update thef milliseconds division argument.
tried that as a function, but startTimer() didn’t like just having
the function name there, so that too has to have ‘return’ in it,
perhaps. -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.