Forum

    • Register
    • Login
    • Search
    • Categories

    setAttribute function questions

    General Questions
    2
    3
    47
    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.
    • marcLab
      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.healey
        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

        marcLab 1 Reply Last reply Reply Quote 2
        • marcLab
          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

          11
          Online

          983
          Users

          6.6k
          Topics

          60.8k
          Posts