simple sequencer

Home Forums General Programming simple sequencer

Tagged: 

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

      ok, so that’s for the ‘convertToHex’ method.
      i’m thinking of sidelining that now, in favour of the
      ‘extractTable’ method – which keeps the values as decimal.
      (with any hex conversion coming later if needed)

      this is the bit that allow me to do a kind of ‘getRange’
      on table keys: (see problem with it, as described above)

      function extractTables()
      -- --[ extract a range to a new table as integers ]--
      --[ also: --string.format("%.2i", v)	--string.format("%.2d", v) ]--	
      --[ string.format("%d", v)	--string.format("%i", v) ]--
      -- --------------------------
      	local tabl_octv={}
      	for k,v in ipairs(tabl_current) do 
      		if k >=1 and k <=16 then
      		tabl_current[k]=  tonumber(v)
      		table.insert (tabl_octv,tabl_current[k])
      		end
      	end
      
      	local octvconcat = nil
      	octvconcat = table.concat(tabl_octv," ")
      	console(String("octv = "..octvconcat))
      
      	local tabl_semi={}
      	for k,v in ipairs(tabl_current) do 
      		if k >=17 and k <=32 then
      		tabl_current[k]=  tonumber(v)
      		table.insert (tabl_semi,tabl_current[k])
      		end
      	end
      
      	local semiconcat = nil
      	semiconcat = table.concat(tabl_semi," ")
      	console(String("semi = "..semiconcat))
      -- --------------------------
      -- [ etc. for remaining rows ] --
      
      end
      #73891
      dnaldoog
      Participant
        • Topics: 4
        • Replies: 480
        • Total: 484
        • ★★
        
        local tabl_octv={}
        	for k,v in ipairs(tabl_current) do 
        		if k >=1 and k <=16 then
        		tabl_current[k]=  tonumber(v)
        		table.insert (tabl_octv,tabl_current[k])
        		end
        	end
        

        can just be:

        
        
        	local tabl_octv={}
        	for i=1,16 do 
        		table.insert (tabl_octv,tabl_current[ i ])
        		end
        

        I think.

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

          ok, i’ll try that in a minute.
          so i could also do for i = 17,32 / 33,48 / 49,64 / 65,80 ?
          makes sense.. and a lot simpler.

          what is perplexing me is how it’s all been working ok
          with all the values set to their default ‘clear all’ values,
          but then it doesn’t work if the values are anything else.
          i wonder what i’m missing. maybe it is because ‘tabl_current’
          is a global table..
          i’m going to skip/exclude the convert to hex method, and just
          try to do it with decimal tables.

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

            ah that’s interesting:
            if i disable those two functions: convertToHex and splitData,
            i get the individual tables extracted properly each time. so
            that’s where the problem is.

            also wondering if leaving other ‘backup’ methods in there
            could be confusing things – especially is the same table
            name was referred to there, so i’ve deleted those now.

            *edit*
            yep: can confirm that that’s working ! great.

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

              haha: funny thing here is that i’ve gone in circles now 🙂
              build table, extract table, put them all back together again ..
              still: good exercise – have to knock it into shape now.

              as decimal, i have it returning size, as a memory block,
              and once again, the result changes; appears to be dependent
              on ‘number of characters ie: when it counts past 9 to 10,11.

              nb: where i’m getting the last two characters with ‘-2’ (where
              you have -1, for single character extraction of string.sub suffix –
              makes me wonder how it accounts for this. what if the count was
              to 100, and i put -3? have to see about that – not critical here,
              though; seems to be working)

              don’t think size will matter at this point anyway.
              my current task is to condense the ‘writeDest’ where it identifies
              the table/variable to store the data in:
              i’m wondering how to create unique-ly variables with i=1,16 without
              initializing them first – ie: i just give the main name, and try to
              append ‘i’, but have not found a way yet. (returns nil error)

              (this would save repetition of current argument)

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

                I haven’t tested this code, but see comments

                
                function writeDest(--[[[x--]])
                local x = saveDest -- I think it's better to pass a global function like 'saveDest' as a function parameter for future readability
                --e.g. function WriteDest(x)
                _G["tabl_pattern"..x]={} 
                		for k,v in ipairs(tabl_current) do
                		table.insert(_G["tabl_pattern"..x],v) -- <-- you had 'k' here - is that correct?
                -- not 'v' here ?? if tabl_current is a fixed size then no need to use k values
                -- Wouldn't you just do
                --for i=1,16 do
                -- table.insert(_G["tabl_pattern"..x],i)
                -- end
                		end
                	local z = table.concat(_G["tabl_pattern"..x]," ") 
                -- this just needs to be  a string variable I don't see pattconcat anywhere else in the program
                --unless tabl_pattern..x etc is needed elsewhere in the program I don't know why you are introducing it here in this function. I can only see it as 
                --a string as part of tabl_pattbankC={}. Maybe there's a future purpose for it? Must be?
                --
                	panel:getComponent("labl_selectedPattern"):setPropertyString("uiLabelText",tostring(z))
                console("z=\n"..z)
                end
                
                #73898
                human fly
                Participant
                  • Topics: 124
                  • Replies: 1070
                  • Total: 1194
                  • ★★★★

                  great news if i can do _G [ ] on tables.
                  agree for reducing to for i=1,16.

                  so this then creates global tables, doesn’t it, that
                  can be invoked elsewhere? think that’s necessary.
                  don’t think there’s any benefit to sending them into
                  memory blocks if i can do the equivalent of getRange
                  – or strings, as that would be complicated there.
                  like this, tables can be handled just as easily.

                  i will now also try to get the initial click on a pattern
                  button to recall that pattern to the controls.
                  – so there’s a consideration: do i need pre-existing
                  tables created on load with the default parameter settings…
                  yes, probably – but i’ll deal with that when i’ve got this
                  bit working.

                  (coming soon: (‘arithmetic’?) on tables 🙂 ho ho ho – envisage
                  some sort of string.format if i can push to nearest ‘n’ integer?
                  i see it can push to round up/down decimal points – so i’ll have
                  to study some scale tables for that.)

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

                    great. that pretty serious – powerful, being able to create
                    tables on the fly:

                    local x = saveDest 
                    _G["tabl_pattern"..x]={} 

                    this one works:

                    function writeDest()
                    
                    	local x = saveDest 
                    	_G["tabl_pattern"..x]={} 
                    
                    	for k,v in ipairs(tabl_current) do
                    	table.insert(_G["tabl_pattern"..x],v)
                    	end
                    
                    	local z = table.concat(_G["tabl_pattern"..x]," ") 
                    	panel:getComponent("labl_selectedPattern"):setPropertyString("uiLabelText",tostring(z))
                    
                    console("temp pattern = "..z)
                    end

                    ties in with the other methods, updates displays, replaces
                    the previous ‘long’ method completely 🙂

                    the other one just delivers a count 1,2,3,4,5…16

                    waaah. thanks again ! going to play around with it,
                    see what’s next.

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

                      seems that it can do:

                      setPropertyString("uiLabelText",tostring(z))

                      and also:

                      setPropertyString("uiLabelText",z)

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

                        Yes the tostring() function is not necessary, but I added it in anyway.

                        The only reason I use _G[] is to concatenate an iterator 1-16 etc with a string. Without the _G[] you are just concatenating a string

                        
                        array={2,3,5,8,9,0x0A,0xFF}
                        
                        for i,v in ipairs (array) do
                        _G[ "x"..i ]=v
                        end
                        
                        print ("x6=".. x6 )
                        
                        -- without _G[]input:5: unexpected symbol near '"x"'
                        --with _G[] returns 10
                        
                        z={}
                        
                        for i,v in ipairs (array) do
                        z[ i ]=v
                        end
                        
                        print ("z6=" .. z[6] )
                        
                        -- returns 10
                        

                        If you have a series of variables, say tabl_pattern1 to tabl_pattern16 i.e.x1 to x16 I think it’s better to have them in a table tabl_pattern={} i.e. z={}. I could imagine concatenating with _G[] is less efficient than writing to a table.

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

                          interested to see, running a test, that i can’t return the
                          name of the table created with:

                          
                           local tableName = tostring(_G["tabl_pattern"..x])
                          console(String("tableName = "..tableName))

                          that just gives:

                          LUA>> tableName = table: 000001FDCAD38200

                          so i get the table ID – if that’s what that is.

                          (brief thought about how i will be looking at created tables later.
                          indeed i think they will need to exist on startup -*and* be filled
                          with default pattern data.)

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

                            There you are accessing the value of a table by using _G[], but it’s a table (an address location pointing to data contained in each element of the table) hence 000001FDCAD38200, not an element of the table e.g. tabl_pattern[n] etc – “table_pattern”..x is just a string so that’s what you want.

                            
                             local tableName = "tabl_pattern"..x
                            console(String("tableName = "..tableName))
                            
                            #73916
                            human fly
                            Participant
                              • Topics: 124
                              • Replies: 1070
                              • Total: 1194
                              • ★★★★

                              close to being able to recall parameter values to modulators
                              when i select the pattern with the button array.
                              it is working the first couple of times, and then i get an
                              error: ‘number expected, got string’. m-m-m-might be able to
                              suss out why that is.(but where..)

                              at this point, i’m only getting the 1st value in the row, applied
                              to all (ie: octaves row). i’m doing:(sent it into hex again here,
                              because of the error, and in case getByte needs hex – don’t know yet?..)

                              local tabl_hexcurrent={}
                              
                              for k,v in ipairs(_G["tabl_pattern"..sub]) do 
                              (_G["tabl_pattern"..sub])[k]=string.format("%.2X", v)
                              table.insert(tabl_hexcurrent,_G["tabl_pattern"..sub][k])
                              end
                              
                              local thisPatt = table.concat(tabl_hexcurrent," ") 
                              --console("thisPatt = "..thisPatt)
                              thisMemB = MemoryBlock(thisPatt)

                              and then: (this only gets 1 byte, ‘0’ – doesn’t seem to want (0,15) –
                              also had to replace ‘var’ with ‘false’, at ‘false, var, false’)

                              function assignData(programData, var)
                              for i=1,16 do 
                              _G["octv"..i] = panel:getModulatorByName("octv"..i):setModulatorValue(thisMemB:getByte(0), false, false, false)
                              	end
                              end
                              
                              assignData()

                              the function is within the method here while i figure out
                              where it’s producing the error. don’t know if it’s best to
                              have it called externally.

                              somewhere i’m producing a string instead of numbers.
                              nb: startup initializes all ‘tabl_pattern..i’ names with
                              an array of values separated by commas.

                              off to test this more…
                              see zip for version> (bottom of ‘myPattSelect’)

                              Attachments:
                              You must be logged in to view attached files.
                              #73918
                              human fly
                              Participant
                                • Topics: 124
                                • Replies: 1070
                                • Total: 1194
                                • ★★★★

                                (edit:totalrubbish here, ignore)

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

                                  (soz, all that stuff above, yesterday was rubbish)

                                  8-D *”awesome”* … got it working. recycled some stuff
                                  from the earlier save preset project. restoring bytes
                                  remains in longform, but it appears to be recalling
                                  created patterns by clicking on the button array.
                                  hope it still runs. zipped panel below.
                                  (happy xmas y’all )

                                  *edit* – slightly better, with initialized pattern
                                  on start, 2nd zip.

                                  Attachments:
                                  You must be logged in to view attached files.
                                  #73939
                                  human fly
                                  Participant
                                    • Topics: 124
                                    • Replies: 1070
                                    • Total: 1194
                                    • ★★★★

                                    gone back to absolute basics to look at the clock count,
                                    and some other possibilities. here is bar count, and an
                                    attempt at making it wrap round for an out of range count
                                    ie: start at step8 and run for 14 steps :
                                    starting on 8, counting up, it should really jump from
                                    step 16 to step1, and then count to step5, before going
                                    to 8 again – a ‘wrap’ action in the count, allows ‘sliding’
                                    the sequence length around on the 16 step grid.

                                    – – – –
                                    the other thing i’m thinking of, is somehow tying the count
                                    to an array or table (‘field’), using the ‘keys’ for the count,
                                    so that steps can be skipped(removed from the count), and
                                    other manipulations. (not sure what yet…)

                                    need to meditate on that …
                                    lots of possibilities there, i think, if it can be tied to
                                    a table. i think this is ‘key'(sic) to shifting left right,
                                    maybe more than trying ‘wrap’, which doesn’t quite seem to
                                    work here.
                                    mini-panel>

                                    Attachments:
                                    You must be logged in to view attached files.
                                    #73989
                                    human fly
                                    Participant
                                      • Topics: 124
                                      • Replies: 1070
                                      • Total: 1194
                                      • ★★★★

                                      thinking of another way to do the count, and get it
                                      from a table. the best way seems to be a ‘for’ loop,
                                      like this:

                                      function forRange()
                                      local tbl_count3 = {}
                                      local a = panel:getModulatorByName("start"):getValue()
                                      local b = panel:getModulatorByName("end"):getValue()
                                      
                                      for i=a,b,1 do 
                                      --[ put all returns into table --]
                                      	table.insert(tbl_count3,i)
                                      --[ concatenate to a single string with spaces --]
                                      	returnConcat3 = table.concat(tbl_count3, " ")
                                      end
                                      
                                      end

                                      now i think i want ‘count’ to be ‘tbl_count3 [ i ] ‘ somehow (?)
                                      (when i do count = count+1 etc.)

                                      might be on the wrong track …

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

                                        ‘while’ is a disaster again.. locks up Ctrlr..
                                        but i can do this and it prints it ok, i get
                                        the correct ‘steps’ listed, inclusive of start
                                        and end points:

                                        for k,v in ipairs(tbl_count3) do 
                                        
                                        console(String(tbl_count3[k]))
                                        
                                        end

                                        now i need a way to make this the ‘count’ reference,
                                        when i do count=count+1 …

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

                                          can do this …

                                          for k,v in ipairs(tbl_count3) do 
                                          
                                          console(String(tbl_count3[k]))
                                          
                                          	if tonumber(tbl_count3[k]) < b then 
                                          	console(String("add one"))
                                          	--addOne()
                                          	elseif  tonumber(tbl_count3[k]) == b then 
                                          	--returnToStart()
                                          	console(String("return to start"))
                                          	end
                                          
                                          end
                                          #73993
                                          dnaldoog
                                          Participant
                                            • Topics: 4
                                            • Replies: 480
                                            • Total: 484
                                            • ★★

                                            Hi there HF

                                            v is tbl_count3[k]

                                            
                                            for k,v in ipairs(tbl_count3) do 
                                            
                                            console(String(tbl_count3[k]))
                                            
                                            end
                                            

                                            just need to do:

                                            
                                            for _,v in ipairs(tbl_count3) do 
                                            
                                            console(String(v))
                                            
                                            end
                                            
                                          Viewing 20 posts - 61 through 80 (of 163 total)
                                          • The forum ‘Programming’ is closed to new topics and replies.
                                          There is currently 0 users and 120 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