Next/Pre Preset & Label what am I doing wrong?
-
My goal is to display the name of the current preset in a label and to be able to choose the preset via buttons. The two buttons are MouseCallbacks of two Panels and not two buttons.
// Preset Browser const var lblPreset = Content.getComponent("lblPreset"); inline function UpdatePresetLabel() { // no preset if (Engine.getCurrentUserPresetName() == "" || Engine.getCurrentUserPresetName() == "init") { lblPreset.set("text", "init"); } else { //if any other preset is loaded lblPreset.set("text", Engine.getCurrentUserPresetName()); } }; // Pre << const var pnlPre = Content.getComponent("pnlPre"); const var svgPre = Content.createSVG("/*base64 svg code*/."); pnlPre.setPaintRoutine(function(g) { g.setColour(Colours.white); g.drawSVG(svgPre, this.getLocalBounds(0), 1); }); pnlPre.setMouseCallback(function(event) { if (event.clicked && !event.mouseUp) { Engine.loadPreviousUserPreset(true); UpdatePresetLabel(); } }); // Next >> const var pnlNext = Content.getComponent("pnlNext"); const var svgNext = Content.createSVG("/*base64 svg code*/."); pnlNext.setPaintRoutine(function(g) { g.setColour(Colours.white); g.drawSVG(svgNext, this.getLocalBounds(0), 1); }); pnlNext.setMouseCallback(function(event) { if (event.clicked && !event.mouseUp) { Engine.loadNextUserPreset(true); UpdatePresetLabel(); } });
this is a snippet:
HiseSnippet 2174.3ocsXssbhibFV3wLYvS1SUsWmRwUxVLkcoAAXvr6NSrNg4LByAiII6VBoFj.Q2XoFvxYmp1KxCv9HjWg7FjGobWtbR2RbPXyX60UspJiq9+P++0+mzuZUGjNv0E4vDIVKuo.lH+9nM8fXSISMKHSQYlHedzpZtXfCa.IQuoZtt.ClHQdw4TBQhsOi+y+8uHpYqA0AaHwvzAYoCpXMwBugp5YksrsyqY.ZYMIjzoOqnNBJgrQyH34EQSvLUSer1PPMMpX6EkIxKULrvHmlXMLvkIx9hHCullnEv.46X4Z02FPWvyzjrQAjyirMnHlRkQxzx1Pc041kgrKpa7BuHvK70QqZYXsl9FuwW5yfciFg8GQ1aa38hsfG+mBd6.RQBAo8CfzWEsoti0T7FNT775nEgjfy.MhaOLTBjkYue3UQk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pzZ+mP6+MkS+73PkS+K7YL2+KtIeqOxXlsFd6K.fdqGKYPRr25qtoeYMIvi8BeqH+JtUfDO3sB7Tg3WEU0BqataLt2NvH4kF+Vfwk2kxmEUYv.fNdC.2OZ9tO2KN4QLevjiCqpgcrncvIkaMIMvzADqCIM4co8H2i9Rpf0Inqodfl.ng+hORdVxjmtNxRl7qXxLQS2A8i5AicPuslW4SgfIn+EUEKZU5ZV96OswDKCqeTWe6s5dJl74pXpmqhoetJdxyUwLOWEy9bU7zGWQ5c6ILCilDT1vvTUUw+0cQhn.oSa3msx7+AfFyRnI
-
@Mighty23 said in Next/Pre Preset & Label what am I doing wrong?:
lblPreset
why not just put lblPreset in your presets?
-
@Lindon Hi, sorry but I can't understand what you're referring to.
-
@Mighty23 you want lblPreset to show the name of the preset - just set saveInPreset to true for your label, and you dont need to do any "setting" at all...
-
@Lindon This solution does not work, changing the saveInPreset of the label does not change the result. I tried to activate the breakpoints for writing in the label and for the next/pre functions and apparently it is not "stopped". So I think the error is in the code and not in HISE settings.
-
@Mighty23 What Lindon is suggesting is you write the name of each preset in the label before you save the preset. Then when you restore the preset the label will already have the correct name.
-
@Mighty23 said in Next/Pre Preset & Label what am I doing wrong?:
@Lindon This solution does not work, changing the saveInPreset of the label does not change the result. I tried to activate the breakpoints for writing in the label and for the next/pre functions and apparently it is not "stopped". So I think the error is in the code and not in HISE settings.
What David said, and it does work - its worked for a number of years for me.
-
@d-healey Are you suggesting me to load all the strings of "*.preset" in a vector? Anyway I solved it with a handler, the problem of the next/prev bottuns (panels) that do not react remains.
solution for the label
const var lblPreset = Content.getComponent("lblPreset"); lblPreset.set("text", "init"); reg currentPreset; // Preset Handler const uph = Engine.createUserPresetHandler(); uph.setPostCallback(function(presetFile) { currentPreset = presetFile; lblPreset.set("text", presetFile.toString(presetFile.NoExtension)); });
2nd part
When I put breakpoint in the if condition, I never get a break.pnlNext.setMouseCallback(function(event) { if (event.clicked && !event.mouseUp) { Engine.loadNextUserPreset(true); } });
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rQLOymblv7TBWwhtMQPHPVb3wwqmPH4ICjWi2Vle.PTHYGHY6L6RpuyGOeczvcwGNzYEFURODUadHpJtn3V1e.U+qiF.GAGzJRpHlQlg3e7YRWHWpzWkh4QDybYKjJWpGPLoKE96wN6ueVTZJuyo606nsDH3gwH34+HKMI2k6jHudglegqtkbICh2bpFi0rcOnh+ckbNs4zTetOZLIDi.0ORzgtIIKoWU3GY4St2nRFFm1E2.fjK6cZYR.a.9iHSQaIxgDan2fLrrsHqBYVa.DPNj41QS4ldyCBDTvmxuqf12RWWugPAPDA+I+CIRxk9AeW9+X+jt+K99ntkKtDolm8wlsd3xS8ydqBP1MnUpZFFDt4S0tN.MG8IBZNAm.SMKPPCjy134CkbfC8PI6hzORZ7ObzVrW9DNy3v1peYVnsU+CbQlGeAXxUuQFd1Z3iuON8QH1JfPrO5RvzK5RV3waB+HE+e6R5OUH9MQUsv5SNMFO6DXjbh4mCLt8oM9pnxiGCzwG.3KipL3yy6XvDTEoYCMxsnIK1QIa25PRcoCHdGRR9SqkIxYzpNBZmj1lFA5.fF9M9OjusB4osirUH+NgLy0zcP+rdPsJzGO4U98PvDz+cihEsAsMK+iKQYtkg0Oqqe7P8HCS8bML8y0vLOWCu54ZX1mqg4dtFl+W2P5SsUxCilGrsggogpr+wcQhHCoEi3yVY9ujoM1aB
-
@Mighty23 said in Next/Pre Preset & Label what am I doing wrong?:
Are you suggesting me to load all the strings of "*.preset" in a vector
Not at all.
Set the text of your label to "Preset 1" (or whatever your first preset is called) then save the preset.
Now load your second preset and set the label's text to "Preset 2" and save the preset.
Do the same for the reset of your presets.Make sure the label is set to saveInPreset=enabled.
Now when you load a preset the label will restore its saved value too.
The only problem with this is it doesn't work for presets made by the user - but this was Lindon's idea so he can provide the solution to that if needed :beaming_face_with_smiling_eyes:
-
@d-healey said in Next/Pre Preset & Label what am I doing wrong?:
The only problem with this is it doesn't work for presets made by the user
Ok I think I understand and it's not a problem for this implementation. Thanks.