Forum
    • Categories
    • Register
    • Login

    setAttribute() from array string problem.

    Scheduled Pinned Locked Moved Scripting
    6 Posts 2 Posters 395 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • CyberGenC
      CyberGen
      last edited by

      I am trying to set a knob callback to setAttribute() from an array that has been populated by combining two other arrays. But it doesn't want to accept the attribute name. Apparently because it's a string. For example: Env1.Attack. But it works fine if I just manually type in the same thing.

      Can you help me figure out what the problem is?

      // Processor names array						
      const EnvName = ["Env_1.", "Env_2.", "Env_3."];
      
      // Attribute names array			
      const ATR = ["Attack", "Decay", "Sustain", "Release"];
      
      // Combined processor and attrbute array
      const Combined = [[],[],[]];
      
      	for (a in ATR) Combined[0].push(EnvName[0] + a);
      	for (a in ATR) Combined[1].push(EnvName[1] + a);
      	for (a in ATR) Combined[2].push(EnvName[2] + a);
      
      // Knob1 Callback	
      inline function onKnob1Control(component, value)
      {
      	Envelopes[0].setAttribute(Combined[0][0], value);
      };
      Content.getComponent("Knob1").setControlCallback(onKnob1Control);
      
      
      HiseSnippet 1527.3oc6ZEtaaaCDlJ1bc1qMscXan6eDA6GtXAow1YcCnXnNwIY0nwstwocCHnnfQhNlHxjpRTY0Xn.8m6wX+dOE6QX.6EX.6EXuAajTRVTNNNNN0EN.QvHPj79N9wiGu6jTZ4ysIAAbefUg856Q.VWG1tOSzsdWLkAZrIv5NvlgtBZqDIQ04LgO2ErQeObP.wAXYk6GTRaUHOPe8uObCrKlYSR6B.dAmZS1g1iJR6sUsGScc2F6P1i1yP50p0vlypyc4gRlkCtJvCaeD9PxSvJwV.Br9nsbnBteaAVPB.V42f6zucW9Oyhj+Ez.5AtDUixf1REE081bWGEiU8Bp2k55LXcE..VvVo1ibQ1iOC1j5jt5SsK2RO.JEgo8vZgrzKWF5U1jdqZPuQPIKCJkOhR2F111m5IRGQwmOA1fIH9cvRytIUhjErv6xCU6bDlXk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r4C68eNL1kGuwFNgND2.FsHQ5ipmaug7Sl2v3OOMoNuKlv0ncj4axdcn1s3xfc8lvXG1KEF1EgwmktLXZGakH4lsUhjIf6sNs.tUl1.taP83tX+Sshpqh8Nii8NyKV3hFuclSvKVL1YN8tvwU+.rCewhkdY8ojxDZL9SC7ovVb29QA+1l5JHQu34BvnFi6Ii.fs8IuNjvrSsV+5eU6YlltrgatSsmEhcMstc+8ZwQTunYENinS4mPeiu.NXQgliefgpW8.CWkz5pjVWkzZd50OpROflqeEoeILNaCREke9lqKBe17MAuAT+tIQQuxx4O984l7Ck7fae.44t7PAkcXSrLO7aj4ZdRXu17PeahjiLFwU84xrVP8YghZuppshDsILGci+SdEOXYUaq3AKmL3Gj4nG11m+J63+eAjYM+XcOx0MS+utQAXSUaT4S9Qq5Qcnux1NqpNAvJSKvpSKv0lVfeyzB79SKvucZA9cmMP0Koe8PAuWTLF.nYqszejQKqsXpCO5iIf+GfWK4J+
      
      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @CyberGen
        last edited by

        @CyberGen those words "attack", "decay", etc. mean nothing to setAttribute. The attribute needs to be a number. You can get the number using the predefined constants such as myEnvReference.Attack

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        CyberGenC 1 Reply Last reply Reply Quote 1
        • CyberGenC
          CyberGen @David Healey
          last edited by CyberGen

          @d-healey said in setAttribute() from array string problem.:

          You can get the number using the predefined constants such as myEnvReference.Attack

          That is what the combined array does. It puts that constant together. In this case Env1.Attack. But still doesn't accept it. I suppose I could change the array to populate with the numbers instead of the constat. I've gotten so used to using the constant that I didn't think about that.

          David HealeyD 2 Replies Last reply Reply Quote 0
          • David HealeyD
            David Healey @CyberGen
            last edited by

            @CyberGen said in setAttribute() from array string problem.:

            That is what the combined array does.

            It doesn't do what you think it does, I'll post an example when I'm at my computer soon

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            1 Reply Last reply Reply Quote 0
            • David HealeyD
              David Healey @CyberGen
              last edited by David Healey

              @CyberGen So as a simple test you can use Console.print(trace(Combined));. You'll see it outputs strings, not numbers.

              This is how I did it using the constants - https://codeberg.org/LibreWave/RhapsodyBoilerplate/src/branch/main/modules/AhdsrController.js

              Free HISE Bootcamp Full Course for beginners.
              YouTube Channel - Public HISE tutorials
              My Patreon - HISE tutorials

              CyberGenC 1 Reply Last reply Reply Quote 1
              • CyberGenC
                CyberGen @David Healey
                last edited by

                @d-healey I see. I'll try to adapt your way to my project. Thank you.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post

                34

                Online

                2.1k

                Users

                13.0k

                Topics

                113.0k

                Posts