Forum
    • Categories
    • Register
    • Login

    Saving MIDI CC assignments in user presets?

    Scheduled Pinned Locked Moved Scripting
    26 Posts 3 Posters 125 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.
    • David HealeyD
      David Healey @dannytaurus
      last edited by

      @dannytaurus load them in the post load callback

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

      dannytaurusD 1 Reply Last reply Reply Quote 0
      • dannytaurusD
        dannytaurus @David Healey
        last edited by

        @David-Healey Unless you prevent saving/loading the CC data to presets, you're always doing more than you should have to.

        Without the preprocessor:

        1. Launch the plugin - load the CC mappings from separate file
        2. Load a preset - in post load callback you need to reassign CC mappings because they're overwritten by the load
        3. Assign some CC mappings - automatically save the new mappings to separate file here
        4. Save the preset - the CC mappings save with the preset, so maybe do a post save callback to remove the data
        5. Load the next preset, etc.

        With the preprocessor:

        1. Launch the plugin - load the CC mappings from separate file
        2. Load a preset - nothing to do
        3. Assign some CC mappings - automatically save the new mappings to separate file here
        4. Save the preset - nothing to do
        5. Load the next preset, etc.

        Meat Beats: https://meatbeats.com
        Klippr Video: https://klippr.video

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

          @dannytaurus said in Saving MIDI CC assignments in user presets?:

          Save the preset - the CC mappings save with the preset, so maybe do a post save callback to remove the data

          You don't need to do anything here because you're already loading the CCs from the file.

          So your preprocessor removes step 2 the rest is the same.

          I think AppConfig.h is autogenerated when you save the juicer file so probably shouldn't be tracked by git - I could be wrong.

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

          dannytaurusD 2 Replies Last reply Reply Quote 0
          • dannytaurusD
            dannytaurus @David Healey
            last edited by dannytaurus

            @David-Healey said in Saving MIDI CC assignments in user presets?:

            Save the preset - the CC mappings save with the preset, so maybe do a post save callback to remove the data

            You don't need to do anything here because you're already loading the CCs from the file.

            That's true, but if you leave the CC mappings in the preset file then it becomes lies on disk.

            Likely to be confusing to someone looking at the preset XML.

            Agree on the AppConfig.h, Claude forced it into the commit, I'll remove it.

            Meat Beats: https://meatbeats.com
            Klippr Video: https://klippr.video

            1 Reply Last reply Reply Quote 1
            • dannytaurusD
              dannytaurus @David Healey
              last edited by

              @David-Healey Claude also found another case to consider - plugin launch.

              Looking at it now.

              Meat Beats: https://meatbeats.com
              Klippr Video: https://klippr.video

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

                @dannytaurus said in Saving MIDI CC assignments in user presets?:

                Launch the plugin - load the CC mappings from separate file

                Handled here, no?

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

                dannytaurusD 2 Replies Last reply Reply Quote 0
                • dannytaurusD
                  dannytaurus @David Healey
                  last edited by

                  @David-Healey Maybe, yes.

                  Meat Beats: https://meatbeats.com
                  Klippr Video: https://klippr.video

                  ustkU 1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @dannytaurus
                    last edited by

                    @dannytaurus @David-Healey Can't the CC mapping simply be removed from the preset using the handler? Isn't the custom preset intended for this purpose in the first place? Never tried myself that being said...

                    Hise made me an F5 dude, any other app just suffers...

                    dannytaurusD 1 Reply Last reply Reply Quote 0
                    • dannytaurusD
                      dannytaurus @David Healey
                      last edited by

                      @David-Healey Apparently not.

                      There are 3 HISE restore points that run after onInit, so it still needs handling.

                      From Claude:

                      Fresh instance in a DAW: FrontendProcessor::restorePlugin runs compileAllScripts() (your onInit applies the file) and then restores the
                      MidiAutomation node from the embedded project state (FrontEndProcessor.cpp:458). The export always writes that node — even when empty, exportAsValueTree adds it unconditionally — so a fresh instance immediately clears the mappings you just loaded. Your file-load is defeated before the user ever touches the plugin.

                      Reopening a session: the host calls setStateInformation at some point after instantiation (host-dependent timing), and FrontEndProcessor.cpp:576 restores the session's stale mapping copy over whatever onInit applied.

                      In the editor: every project load stashes the project XML's <MidiAutomation/> and applies it after script compilation (MainController.cpp:562/577)
                      — same wipe while you're developing.

                      Meat Beats: https://meatbeats.com
                      Klippr Video: https://klippr.video

                      1 Reply Last reply Reply Quote 0
                      • dannytaurusD
                        dannytaurus @ustk
                        last edited by

                        @ustk Not sure. To be honest, I just want all the 'CC data in presets' code out of my fork.

                        Might just drop the preprocessor and remove it all directly.

                        I can't see a situation where I would ever want CC data in the presets. So a preprocessor is only useful for backwards compatibility, which I don't have any of 😜

                        Meat Beats: https://meatbeats.com
                        Klippr Video: https://klippr.video

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

                          I think this is what the custom user preset model is for: https://docs.hise.dev/scripting/scripting-api/userpresethandler/index.html#setusecustomuserpresetmodel

                          Haven't tried it myself.

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

                          ustkU 2 Replies Last reply Reply Quote 1
                          • ustkU
                            ustk @David Healey
                            last edited by

                            @David-Healey Lol

                            @ustk said in Saving MIDI CC assignments in user presets?:

                            @dannytaurus @David-Healey Can't the CC mapping simply be removed from the preset using the handler? Isn't the custom preset intended for this purpose in the first place? Never tried myself that being said...

                            Just checked and the answer is no, you can't manage what is written... But Claude came with a neat solution:

                            // (processBeforeLoading, unpackComplexData)
                            uph.setEnableUserPresetPreprocessing(true, false);
                            
                            uph.setPreCallback(function(presetData)
                            {
                                // presetData is a JS object; MidiAutomation is a top-level property.
                                // Emptying it means applyJSON rebuilds an empty <MidiAutomation> node,
                                // so the incoming preset never overwrites the current CC assignments.
                                presetData.MidiAutomation = {}; // or just rewrite what you already saved
                            });
                            

                            Hise made me an F5 dude, any other app just suffers...

                            1 Reply Last reply Reply Quote 2
                            • ustkU
                              ustk @David Healey
                              last edited by

                              @David-Healey @David-Healey So the working solution is

                              const var currentAutomationState = {"ChildId": "Controller", "Children": []};
                              
                              const var mah = Engine.createMidiAutomationHandler();
                              
                              mah.setUpdateCallback(function()
                              {
                              	currentAutomationState.Children = this.getAutomationDataObject();
                              });
                              
                              
                              
                              const var uph = Engine.createUserPresetHandler();
                              
                              uph.setEnableUserPresetPreprocessing(true, false);
                              
                              uph.setPreCallback(function(presetData)
                              {
                                  presetData.MidiAutomation = currentAutomationState;
                              });
                              

                              The automation state is saved in the instance but you can just save it in a file if you wish so.
                              I'd prefer not in my case, because if you load multiple instances of the plugin, they'll all react to the same CC...

                              Hise made me an F5 dude, any other app just suffers...

                              David HealeyD dannytaurusD 3 Replies Last reply Reply Quote 1
                              • David HealeyD
                                David Healey @ustk
                                last edited by

                                @ustk said in Saving MIDI CC assignments in user presets?:

                                const var currentAutomationState = {"ChildId": "Controller", "Children": []};

                                Does this store MPE and Macro assignments too?

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

                                ustkU 2 Replies Last reply Reply Quote 0
                                • ustkU
                                  ustk @David Healey
                                  last edited by ustk

                                  @David-Healey Apparently macro yes, but MPE šŸ¤·ā™‚
                                  Here's the automation data object:

                                  [
                                    {
                                      "Controller": 6,
                                      "Channel": -1,
                                      "Processor": "Interface",
                                      "MacroIndex": -1,
                                      "Start": 0.0,
                                      "End": 1.0,
                                      "FullStart": 0.0,
                                      "FullEnd": 1.0,
                                      "Skew": 3.106283926937945,
                                      "Interval": 0.0,
                                      "Converter": "37.nT6K8CBGgC..VEFa0U1Pu4lckIGckIG.ADPXiQWZ1UF.ADf...",
                                      "Attribute": "HiBoostBWKnb",
                                      "Inverted": false
                                    }
                                  ]
                                  

                                  Hise made me an F5 dude, any other app just suffers...

                                  1 Reply Last reply Reply Quote 0
                                  • ustkU
                                    ustk @David Healey
                                    last edited by ustk

                                    @David-Healey Just tested with my seaboard and yes, it works for MPE that have been MIDI learnt (Since it's just MIDI in the end...)

                                    Hise made me an F5 dude, any other app just suffers...

                                    1 Reply Last reply Reply Quote 1
                                    • dannytaurusD
                                      dannytaurus @ustk
                                      last edited by dannytaurus

                                      @ustk said in Saving MIDI CC assignments in user presets?:

                                      I'd prefer not in my case, because if you load multiple instances of the plugin, they'll all react to the same CC...

                                      That's a very interesting point!

                                      EDIT: actually, maybe it's fine. The DAW will only send MIDI CC to the active plugin, right?

                                      Meat Beats: https://meatbeats.com
                                      Klippr Video: https://klippr.video

                                      ustkU 1 Reply Last reply Reply Quote 0
                                      • ustkU
                                        ustk @dannytaurus
                                        last edited by

                                        @dannytaurus If by inactive you mean hidden UI, then Midi is still reaching them

                                        Hise made me an F5 dude, any other app just suffers...

                                        dannytaurusD 1 Reply Last reply Reply Quote 0
                                        • dannytaurusD
                                          dannytaurus @ustk
                                          last edited by dannytaurus

                                          @ustk A DAW will only route incoming live controller messages to the active or record-armed track(s), surely?

                                          So if I have 3 different synths all set to respond to mod wheel > filter, then only the active one will respond when I turn the mod wheel, right?

                                          Regardless of whether the synth UI is visible or hidden. It's based on active tracks, right?

                                          The other 2 'unselected', 'inactive', 'not record-armed' synths won't respond to live controller data

                                          Otherwise there would be chaos! Unless that's what you wanted, and armed ALL tracks for record! 😜

                                          Meat Beats: https://meatbeats.com
                                          Klippr Video: https://klippr.video

                                          ustkU 1 Reply Last reply Reply Quote 0
                                          • ustkU
                                            ustk @dannytaurus
                                            last edited by ustk

                                            @dannytaurus Oh yes absolutely, active in the sense of "armed track", then 100% yes šŸ‘

                                            Hise made me an F5 dude, any other app just suffers...

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

                                            13

                                            Online

                                            2.4k

                                            Users

                                            13.8k

                                            Topics

                                            120.5k

                                            Posts