simple sequencer

Home Forums General Programming simple sequencer

Tagged: 

Viewing 20 posts - 1 through 20 (of 163 total)
  • Author
    Posts
  • #73522
    human fly
    Participant
      • Topics: 124
      • Replies: 1070
      • Total: 1194
      • ★★★★

      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.
      #73595
      human fly
      Participant
        • Topics: 124
        • Replies: 1070
        • Total: 1194
        • ★★★★

        (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.

        #73601
        human fly
        Participant
          • Topics: 124
          • Replies: 1070
          • Total: 1194
          • ★★★★

          this 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.
          #73609
          dnaldoog
          Participant
            • Topics: 4
            • Replies: 480
            • Total: 484
            • ★★

            That’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, " "))
            

            https://www.lua.org/cgi-bin/demo

            #73610
            human fly
            Participant
              • Topics: 124
              • Replies: 1070
              • Total: 1194
              • ★★★★

              ?!
              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 ??

              #73612
              dnaldoog
              Participant
                • Topics: 4
                • Replies: 480
                • Total: 484
                • ★★

                Yes, while loops can be lethal!

                #73613
                human fly
                Participant
                  • Topics: 124
                  • Replies: 1070
                  • Total: 1194
                  • ★★★★

                  myLittleSequencer (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.

                  #73619
                  dnaldoog
                  Participant
                    • Topics: 4
                    • Replies: 480
                    • Total: 484
                    • ★★

                    Does 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
                    
                    #73630
                    human fly
                    Participant
                      • Topics: 124
                      • Replies: 1070
                      • Total: 1194
                      • ★★★★

                      i 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.

                      #73631
                      human fly
                      Participant
                        • Topics: 124
                        • Replies: 1070
                        • Total: 1194
                        • ★★★★

                        well, 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)

                        #73635
                        dnaldoog
                        Participant
                          • Topics: 4
                          • Replies: 480
                          • Total: 484
                          • ★★

                          I 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!

                          #73636
                          human fly
                          Participant
                            • Topics: 124
                            • Replies: 1070
                            • Total: 1194
                            • ★★★★

                            indeed. 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.

                            #73637
                            dnaldoog
                            Participant
                              • Topics: 4
                              • Replies: 480
                              • Total: 484
                              • ★★

                              Heavy reading!

                              #73638
                              human fly
                              Participant
                                • Topics: 124
                                • Replies: 1070
                                • Total: 1194
                                • ★★★★

                                yeah…
                                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 nil

                                i’m going to ponder that but right now i’m tidying the thing up a
                                bit and backing up to a cutdown new version.

                                #73639
                                dnaldoog
                                Participant
                                  • Topics: 4
                                  • Replies: 480
                                  • Total: 484
                                  • ★★

                                  What 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.

                                  #73640
                                  human fly
                                  Participant
                                    • Topics: 124
                                    • Replies: 1070
                                    • Total: 1194
                                    • ★★★★

                                    that’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
                                    #73641
                                    human fly
                                    Participant
                                      • Topics: 124
                                      • Replies: 1070
                                      • Total: 1194
                                      • ★★★★

                                      think 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.

                                      #73642
                                      dnaldoog
                                      Participant
                                        • Topics: 4
                                        • Replies: 480
                                        • Total: 484
                                        • ★★

                                        That 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.

                                        #73643
                                        human fly
                                        Participant
                                          • Topics: 124
                                          • Replies: 1070
                                          • Total: 1194
                                          • ★★★★

                                          indeed, 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 🙂

                                          #73644
                                          human fly
                                          Participant
                                            • Topics: 124
                                            • Replies: 1070
                                            • Total: 1194
                                            • ★★★★

                                            would 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.

                                          Viewing 20 posts - 1 through 20 (of 163 total)
                                          • The forum ‘Programming’ is closed to new topics and replies.
                                          There is currently 0 users and 33 guests online
                                          No users are currently active
                                          Forum Statistics
                                          Threads: 2,495, Posts: 17,374, Members: 77,605
                                          Most users ever online was 12 on January 22, 2019 3:47 pm
                                          Ctrlr