How to make a parameters Randomiser button?

Home Forums General Programming How to make a parameters Randomiser button?

Tagged: 

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #71526
    deadwing
    Participant
      • Topics: 1
      • Replies: 0
      • Total: 1

      Hi

      I just discovered Ctrl and got a couple of panels for my synths (Streichfett and Ju 06), and I want now to do one of my own with an added function: RANDOM button.

      What I want is a way to get all the parameters available in my panel and randomise them, is that possible and most of all how?

      A simple example for two parameters will be enough to then go on on my own and extend it 🙂

      Thanks!

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

        i am also looking at how to have a random generator.
        i found the following in a matrix1000 panel:
        (this is my own adaptation, and i don’t know if it is
        working optimally yet)

        random=function()
        	-- This stops issues during panel bootup
        	if panel:getRestoreState() or panel:getProgramState() then return end
        --
        	math.randomseed(Time.getMillisecondCounterHiRes())
        
        	modul	= panel:getModulatorByName("hexlist")
        	rnd	= math.random(0,15)
        
        	modul:setModulatorValue(rnd,false,false,false) 
        	end

        ok, so that is my own hack of what i saw, and should return
        something between 0 and 15 for the ‘hexlist’ modulator.
        but it is behaving weirdly: sometimes it just acts as an
        up-counter/incrementor, and at others seems to be not
        random enough. i think it is something to do with the
        timing interval of the seed. Possemo says something
        about it here:

        os.time() in milliseconds?

        in other words, the ‘seeding’ is too slow to give
        random results. i don’t fully understand it yet,
        but i have messed around with seed and random
        modules in synthedit – and seen that if it is not
        done right, you do not get random, you can get repeating
        patterns.

        nb:(if Possemo is reading) interested in how you are
        getting parameters by ‘group ownership’ rather than
        byName, with repetition for each item. i have not
        reproduced that successfully yet.(different context etc.)

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

          ok, so i just tried Possemo’s suggestion, and it
          seems to be working much better. like this:

          random=function()
          	-- This stops issues during panel bootup
          	if panel:getRestoreState() or panel:getProgramState() 
                  then return end
          -- basic randomizer
          	local t=os.time()
          	local c=os.clock()
          
          	math.randomseed(t*c)
          
          	modul	= panel:getModulatorByName("hexlist")
          	rnd	= math.random(0,15)
          
          	modul:setModulatorValue(rnd,false,false,false) 
          	end

          thanks Possemo ! (what’s the principle behind t*c ?)

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

            umm, yeah, so that works – but i then tried to make it
            random a row of 12 selectors but they all come up with
            the same value 🙂

            so i suppose i need it to iterate in some way, getting
            a new clock or time value for each item to be randomized.
            i’ll have to have another look at the method i got this
            from.

            any suggestions ?

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

              he.he.he. (NOT as above)
              have figured this out (thanks to that panel+Possemo)
              can now specify a group of modulators to randomize,
              by customGroup and uiGroup …so that they all return
              different values this time 🙂

              here’s what it looks like:

              randomGroup=function()
              -- randomize a group by custom index group
              
              	-- This stops issues during panel bootup
              	if panel:getRestoreState() or panel:getProgramState() then return end
              
              	randomGroup = panel:getModulator("randomGroup"):getValue()
              
              -- random seeder
              	local t=os.time()
              	local c=os.clock()
              	math.randomseed(t*c)
              	--math.randomseed(Time.getMillisecondCounterHiRes())
              
              	if randomGroup~=nil then
              
              -- custom group items to randomize
              
              		for k=1,12 do --all mods in selected customGroup,12 items
              
              		modul=panel:getModulatorWithProperty("modulatorCustomIndex",k)
              		group=modul:getComponent():getProperty("componentGroupName")
              
              			if group=="grp_values" --selected by uiGroup
              			then
              
              			rnd=math.random(0,15) --value range to random
              			modul:setModulatorValue(rnd,false,false,false)
              			end
              		end
              	end
              end
              #72250
              human fly
              Participant
                • Topics: 124
                • Replies: 1070
                • Total: 1194
                • ★★★★

                taking this a bit further: i would now like to go back
                to the sort of thing this originated with (it is a
                simplified version, so i could get my head round how it
                worked), *wHERe*: Possemo had a neat setup where various
                groups of modulators could be randomized separately:

                ie: oscillator parameter group, envelope param’ group, etc.

                but in this case i want to randomize an envelope that is
                on a uiTabs, not in a group. so instead of ‘componentGroupName’,
                i tried ‘componentTabName’ – and yes, it works. so that’s cool.
                but now i want to split it up more, because i have several tabs,
                with a different envelope on each tab, and of course, i want to
                be able to get at them separately.

                looking at ‘Utility’, i can see the properties:
                ‘modulatorCustomNameGroup’ and ‘modulatorCustomIndexGroup’, and
                thought i could try to use those to ‘get’ the envelope modulators.

                but these are ‘modulator’ properties, not ‘component’ properties.
                ‘group’ is a component property. i have not yet been able to get
                it to work – the method crashed, and it seems i’m missing variables.
                so i have to figure out what needs to come after the ‘custom’
                parameter: if it’s a string or a boolean, etc.

                if i can do this, i don’t need the modulators to be contained
                within a uiGroup (allowing a more freedom with the layout).
                i can have randomization of tab0 in one custom group, tab1 in
                another, tab2 in another, etc.

                anyone know what the correct expression is for this?

                i want to change from:
                group=modul:getComponent():getProperty("componentTabName")
                to something like:
                group=modul:getComponent():getProperty("modulatorCustomNameGroup")
                but i think it should perhaps be:
                getModulatorWithProperty("modulatorCustomNameGroup",???)

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

                  no joy yet..
                  tried something else (below) and got this message:

                  At line [-1]: [C]
                  What: C
                  Namewhat: method
                  Name: getModulatorWithProperty
                  Error message: No matching overload found, candidates:
                  CtrlrModulator* getModulatorWithProperty(CtrlrPanel&,String const&,String const&)
                  CtrlrModulator* getModulatorWithProperty(CtrlrPanel&,String const&,int)

                  i don’t know what this type of error message indicates:
                  line -1, what and namewhat. looks like heavier errors that
                  method syntax problems.

                  what i’ve tried:

                  	modul	=panel:getModulatorWithProperty("modulatorCustomIndex",k)
                  		--group=modul:getComponent():getProperty("componentTabName")
                  	group	=panel:getModulatorWithProperty("modulatorCustomNameGroup",0)
                  
                  			if group=="custom_pitchEG"
                  			then etc.

                  eg: i tried to use the property, with custom group number, and
                  invoked the group name below, which sort of made sense 🙂 but
                  it doesn’t work. i got it to not crash, but it doesn’t do anything.
                  so i’m missing something.
                  ?

                Viewing 7 posts - 1 through 7 (of 7 total)
                • The forum ‘Programming’ is closed to new topics and replies.
                There is currently 0 users and 66 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