Forum

    • Register
    • Login
    • Search
    • Categories

    getAttributeIndex

    Scripting Forum
    getattribute attribute index identifier parameter
    1
    1
    17
    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.
    • d.healey
      d.healey last edited by d.healey

      I've added a getAttributeIndex() function to all classes that have a getAttributeId() function.

      This will return the index of the attribute with the given name.

      For example, this will return the WetLevel of a simple reverb effect.

      const var SimpleReverb1 = Synth.getEffect("Simple Reverb1");
      Console.print(SimpleReverb1.getAttribute(SimpleReverb1.getAttributeIndex("WetLevel")));
      

      Now why would I do this instead of passing SimpleReverb1.WetLevel? Sometimes you want to have the parameters you are using stored as strings so that you can access attributes programmatically without having to specify every attribute constant manually. This I have found is especially true with effect slots where you don't know in advance which effect a user is going to use.

      It was already possible to do this using getNumAttributes() and getAttributeId() but it required a decent amount of extra work. So I've added this new "convenience" function to make our lives a little more pleasant.

      Pull request - https://github.com/christophhart/HISE/pull/221

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

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

      20
      Online

      741
      Users

      5.4k
      Topics

      50.4k
      Posts