Callback when preset saved??
-
@Christoph-Hart Should I look at adding a presetSaved callback or do you think a broadcaster based solution would be better?
-
@d-healey I would add a UserPresetHandler.setPostPresetSaveCallback(onPresetSaveCallback) function.
-
@Christoph-Hart Thanks, I'll give it a go
-
@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)); -
@Christoph-Hart Any tips? This C++ stuff is not my comfort zone :)
-
Ha I've done it! I need to do a little clean up then I'll make a pull request.
-
@d-healey you should make videos of your debugging journeys for Patreon.
-
@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.
-
Dang, I I haven't quite done it. I'm hitting an infinite loop now that ends in a segfault..
-
@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); }
-
@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.
-
Bump bump
-
@d-healey Why don't you call your method from
saveUserPresetInternal
? -
I've added that function.
-
@Christoph-Hart Woohoo! Thanks!
-
Getting a build error:
../../../../../HISE/hi_backend/../hi_modules/../hi_scripting/../hi_sampler/../hi_components/../hi_dsp/../hi_core/hi_core/MainControllerHelpers.h:116:53: error: no matching function for call to ‘hise::MidiControllerAutomationHandler::clear()’ 116 | void resetUserPresetState() override { clear(); }
-
Ah I see the problem. Do we want to
sendNotification
here?