HISE Logo Forum
    • Categories
    • Register
    • Login

    setAttribute function questions

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 249 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.
    • marcLabM
      marcLab
      last edited by marcLab

      Hello! I got a small problem:

      This works ->
      selectedFx.setAttribute(0,value);
      selectedFx.setAttribute(selectedFx.Saturation,value);

      But I want it to be dynamic.

      something like this -> selectedFx.setAttribute(selectedFx.fxParamName,value)

      fxParamName contains a string.
      Console.print(fxParamName);
      Interface: WetAmount (or something else, because dynamic)

      But this doesn't work. It always refers to attribute 0.
      The problem here is that I'm not using all attributes for every effect and I don't want to repeat myself in the callback.

      inline function onfxKnobControl(component, value)
      {
          
          local fxType = cmbFxSlot[index].getItemText();
          local fxParamName = component.get("text").replace("knb_","");
          local selectedFx = Synth.getEffect("fx"+getSelectedFxSlot()+"_"+fxType);
          
          selectedFx.setAttribute(selectedFx.fxParamName,value); 
          //selectedFx.setAttribute(0,value);
      };
      

      Is there a way to make it work?

      1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey
        last edited by d.healey

        Firstly put all of the FX into an object, using the FX's name as the key.

        const myFX = {
            "saturation" : Synth.getEffect(etc, etc.),
            "nextFx" : Synth.getEffect(etc, etc.)
        };
        

        Then make another object, using the fx name as the key, and put all the parameter names in an array.

        const myParams = {
            "saturation" : ["Saturation", "Drive", "Delay"], // Obviously put these in the correct order and use the correct names
            "nextFx" : ["param3", "param2", "param3"]
        };
        

        Now you can access any effect and any of its parameter indexes using a combination of the effect's name, and the parameter's name.

        So for example if you want to set the saturation fx drive parameter (I don't know if it actually has this parameter, this is just a demo).

        myFx.saturation.setAttribute(myParams.saturation.indexOf("Drive"), value);

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        marcLabM 1 Reply Last reply Reply Quote 2
        • marcLabM
          marcLab @d.healey
          last edited by

          @d-healey Yeah! Will try this! Thanks David!

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

          22

          Online

          1.7k

          Users

          11.8k

          Topics

          102.7k

          Posts