HISE Logo Forum
    • Categories
    • Register
    • Login

    Programmatically Assign Macro Connections?

    Scheduled Pinned Locked Moved Scripting
    4 Posts 2 Posters 136 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.
    • ?
      A Former User
      last edited by A Former User

      Is this possible yet? I remember posting about it a few years ago and couldn't find a solution.

      There's MacroHandler.setMacroDataFromObject but I'm not sure how the JSON is supposed to look.

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @A Former User
        last edited by

        @iamlamprey This will show you how the object should look

        Link Preview Image
        HISE | Scripting |

        favicon

        (docs.hise.audio)

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

        ? 1 Reply Last reply Reply Quote 1
        • ?
          A Former User @d.healey
          last edited by

          @d-healey Ah it's in the ScriptingObjects::ScriptedMacroHandler::setFromCallbackArg function and called from the parent function, my eyes hurt

          ? 1 Reply Last reply Reply Quote 0
          • ?
            A Former User @A Former User
            last edited by

            Okay for anyone else wanting to do programmatic macro assignment for GUI elements:

            // First you need to setup some stuff: 
            
            const mh = Engine.createMacroHandler();
            Engine.setFrontendMacros(["a", "b", "c", "d", "e", "f", "g", "h"]);
            reg obj; // this will be what we pass to the function as an object
            
            // To see the full JSON object: 
            
            inline function getObject(component, value)
            {
            	// This button fetches our existing Macro connections object
            	obj = mh.getMacroDataObject();
            	
            	Console.print(obj); // Insert a breakpoint here and inspect the ScriptWatchTable "obj" element.
            };
            
            Content.getComponent("Button1").setControlCallback(getObject);
            

            The object looks like this:

            {      
                    "MacroIndex": 0, // zero-based macro index
            	"Processor": "Interface", // the script processor we're working in (usually "Interface")
            	"Attribute": "Knob1", // the name of the UI control
            	"FullStart": 0.0, // the UI control's "min" value
            	"FullEnd": 127.0, // the UI control's "max" value
            	"Inverted": false, //  invert the connection
            	"Interval": 0.0, // no idea
            	"Skew": 1.0, // skew
            	"Start": 0.0, // the macro control's "min"
            	"End": 127.0 // the macro control's "max"  
            }
            

            Finally to assign your own custom macro stuff:

            inline function assignMacro(componentName, index, fMin, fMax, min, max)
            {
            	local obj = {
            		"MacroIndex" : index,
            		"Processor" : "Interface",
            		"Attribute" : componentName,
            		"FullStart" : fMin,
            		"FullEnd" : fMax,
            		"Start" : min,
            		"End" : max
            	}
            
            	mh.setMacroDataFromObject(obj);
            }
            

            NOTE: This will likely crash and brick your project if you do it INSIDE HISE. Compile it / export it to Rhapsody before trying to use the actual assignment function.

            If you do brick your project, open the Preset.xml file and delete all the data in the Macro section

            Eg:

            <controlled_parameter id="Interface" parameter="155" parameter_name="knbFilterCutoff"
                                        min="20.0" max="20000.0" low="20.0" high="20000.0" skew="0.266319563348789"
                                        step="0.01" inverted="0" readonly="0" converter="37.nT6K8CBGgC..VEFa0U1Pu4lckIGckIG.ADPXiQWZ1UF.ADf..."/>
            
            1 Reply Last reply Reply Quote 0
            • First post
              Last post

            30

            Online

            1.8k

            Users

            12.1k

            Topics

            105.6k

            Posts