HISE Logo Forum
    • Categories
    • Register
    • Login

    Callback when preset saved??

    Scheduled Pinned Locked Moved Scripting
    preset browsercallbacksave
    22 Posts 4 Posters 1.5k 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.
    • d.healeyD
      d.healey
      last edited by

      Is there any way to perform an action after a preset has been edited or created through the preset browser?

      I have the name of the current preset displayed on my UI and I want to update it when a new preset is added or an existing one renamed.

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

      1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by

        I'm using a timer to catch updates that happen when using the preset browser. A dedicated function would probably work more efficiently.
        Could this be a job for the broadcaster system?

        Dan Korneff - Producer / Mixer / Audio Nerd

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

          @Dan-Korneff I was thinking that a broadcaster might be the answer, but I don't think there is a suitable one available so would require some work by Christoph.

          Another idea (which I don't yet see a problem with) is it could just trigger the existing post callback.

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

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

            I added this at the end of the save preset function so that it triggers the post callback and it works nicely here

            chain->getMainController()->getUserPresetHandler().postPresetLoad();

            @Christoph-Hart Any reason why I shouldn't do this?

            I've also fixed the bug where renaming a preset deselects it :)

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

            Christoph HartC 1 Reply Last reply Reply Quote 2
            • Christoph HartC
              Christoph Hart @d.healey
              last edited by

              @d-healey yes the name of the function suggests that it happens after a preset load which might be used for all kinds of things, so running this after you saved a preset is very irritating.

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

                @Christoph-Hart Should I look at adding a presetSaved callback or do you think a broadcaster based solution would be better?

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

                Christoph HartC 1 Reply Last reply Reply Quote 0
                • Christoph HartC
                  Christoph Hart @d.healey
                  last edited by

                  @d-healey I would add a UserPresetHandler.setPostPresetSaveCallback(onPresetSaveCallback) function.

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

                    @Christoph-Hart Thanks, I'll give it a go

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

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

                      @Christoph-Hart I've started implementing it on a separate branch but when I'm compiling I'm getting an error that I haven't been able to figure out as it seems unrelated to anything I've touched.

                      In file included from ../../../../../HISE/hi_components/hi_components.cpp:42,
                      from ../../JuceLibraryCode/include_hi_components.cpp:9:
                      ../../../../../HISE/hi_components/plugin_components/PresetBrowser.cpp: In constructor โ€˜hise::PresetBrowser::PresetBrowser(hise::MainController*, int, int)โ€™:
                      ../../../../../HISE/hi_components/plugin_components/PresetBrowser.cpp:531:57: error: invalid new-expression of abstract class type โ€˜hise::TagListโ€™
                      531 | addAndMakeVisible(tagList = new TagList(mc, this));

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

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

                        @Christoph-Hart Any tips? This C++ stuff is not my comfort zone :)

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

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

                          Ha I've done it! I need to do a little clean up then I'll make a pull request.

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

                          Dan KorneffD 1 Reply Last reply Reply Quote 1
                          • Dan KorneffD
                            Dan Korneff @d.healey
                            last edited by

                            @d-healey you should make videos of your debugging journeys for Patreon.

                            Dan Korneff - Producer / Mixer / Audio Nerd

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

                              @Dan-Korneff I'll have a think and see if I can come up with a way of showing that in an interesting way. A lot of it is me in bed or in the shower just thinking things over until I realise where to target my effort.

                              Then at the computer I'm just reading a lot through the existing code and trying to figure out which bits to copy/paste and where I need to add new stuff. Then I compile and test, then do that some more. It's quite tedious.

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

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

                                Dang, I I haven't quite done it. I'm hitting an infinite loop now that ends in a segfault..

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

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

                                  @Christoph-Hart I've got it triggering my callback when a new preset is added.

                                  But when clicking the save button in the preset browser I've hit a snag.

                                  In the function void PresetBrowser::ModalWindow::buttonClicked(Button* b)

                                  I'm calling my callback caller after the replace action completes

                                  getMainController()->getUserPresetHandler().postPresetSave();

                                  But this goes into an infinite loop and I don't know why.

                                  This is the caller (it's the same as your changed caller, I just altered the name of the listener).

                                  void MainController::UserPresetHandler::postPresetSave()
                                  {
                                  	auto f = [](Dispatchable* obj)
                                  	{
                                  		auto uph = static_cast<UserPresetHandler*>(obj);
                                  		auto mc_ = uph->mc;
                                  		ignoreUnused(mc_);
                                  		jassert_dispatched_message_thread(mc_);
                                  
                                  		ScopedLock sl(uph->listeners.getLock());
                                  
                                  		for (auto l : uph->listeners)
                                  		{
                                  			uph->mc->checkAndAbortMessageThreadOperation();
                                  
                                  			if (l != nullptr)
                                  				l->presetSaved(uph->currentlyLoadedFile);
                                  		}
                                  
                                  		return Status::OK;
                                  	};
                                  
                                  	mc->getLockFreeDispatcher().callOnMessageThreadAfterSuspension(this, f);
                                  }
                                  

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

                                  1 Reply Last reply Reply Quote 0
                                  • Dan KorneffD
                                    Dan Korneff @d.healey
                                    last edited by

                                    @d-healey said in Callback when preset saved??:

                                    A lot of it is me in bed or in the shower just thinking things over until I realise where to target my effort.

                                    Awesome! You can do Patreon AND OnlyFans content. ๐Ÿ˜„๐Ÿ˜„๐Ÿ˜„๐Ÿ˜„

                                    Dan Korneff - Producer / Mixer / Audio Nerd

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

                                      Bump bump

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

                                      ustkU 1 Reply Last reply Reply Quote 0
                                      • ustkU
                                        ustk @d.healey
                                        last edited by ustk

                                        @d-healey Why don't you call your method from saveUserPresetInternal ?

                                        Can't help pressing F5 in the forum...

                                        Christoph HartC 1 Reply Last reply Reply Quote 0
                                        • Christoph HartC
                                          Christoph Hart @ustk
                                          last edited by

                                          I've added that function.

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

                                            @Christoph-Hart Woohoo! Thanks!

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

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

                                            49

                                            Online

                                            1.7k

                                            Users

                                            11.7k

                                            Topics

                                            102.2k

                                            Posts