A way to make preset up and down buttons? (SOLVED)
-
@ulrik said in A way to make preset up and down buttons?:
you've forgotten to declare the cmb
Ah. I did wonder why that wasn't there. I just copied and pasted the code exactly as it was to test it quick. My bad.
@ulrik said in A way to make preset up and down buttons?:
check this BasicSynth example:
I just check this example but it doesn't include preset up and down buttons. I found one in the music box tutorial but that looks as if its all json stuff which I don't really understand :( It json even still being used?
I was hoping to just make 2 buttons and add them into my existing projects and somehow link them to the preset browser to switch previous to next.
I'm wondering if these parts below from the customUserPresets tutorial can be picked apart and applied somehow? I can see in there that a list can be created automatically from the user presets, but they're loaded into a viewport then. Trying to work out a way.....
// This gets a list of all available user presets const var list = Engine.getUserPresetList(); /** removes the directory names from the path. */ inline function getPresetName(relativePath) { local l = relativePath.split("/"); if(l.length == 3) return l[2]; return ""; } const var prettyList = []; prettyList.reserve(list.length); // Copy the preset names without the paths into a new array for(i in list) prettyList.push(getPresetName(i)); // Load the pretty names into a viewport list const var PresetListSelector = Content.getComponent("PresetListSelector"); PresetListSelector.set("items", prettyList.join("\n")); inline function onPresetListSelectorControl(component, value) { // Grab the preset name from the array and load it. Engine.loadUserPreset(list[value]); }; PresetListSelector.setControlCallback(onPresetListSelectorControl);
-
Just add two buttons and put the loadNextPreset and loadPreviousPreset functions in their respective callbacks.
-
@SteveRiggs what Dave says...
like this(ish) where I have a button called myPresetName to display the preset name:
const var myPresetName = Content.getComponent("myPresetName"); inline function onNextUserPresetControl(component, value) { //next preset. Engine.loadNextUserPreset(false); myPresetName.set("text", Engine.getCurrentUserPresetName()); }; Content.getComponent("NextUserPreset").setControlCallback(onNextUserPresetControl); inline function onPrevUserPresetControl(component, value) { //prev preset Engine.loadPreviousUserPreset(false) ; myPresetName.set("text", Engine.getCurrentUserPresetName()); }; Content.getComponent("PrevUserPreset").setControlCallback(onPrevUserPresetControl);
-
Cheers fellas. I just tried this way but HISE instantly crashes as soon as I hit compile.
Content.getComponent("NextBtn").setControlCallback(onNextBtnControl); inline function onNextBtnControl(component, value) { Engine.loadNextUserPreset(false); }; Content.getComponent("PrevBtn").setControlCallback(onPrevBtnControl); inline function onPrevBtnControl(component, value) { Engine.loadPreviousUserPreset(false); };
-
@Lindon The same crash happens as soon as I hit compile on your code as well
-
Snippet here but it wont let me compile it. HISE just closes as soon as I push compile :(
HiseSnippet 1052.3ocsV0saaaCElxIbc1sdcEX6dgbkCVVfTh+IccC00+MXzkTiYmhdWAsDsMQjHMnnRhQQ.5dS1ixta2tGk8FrcnjrkbhsmgwhtRjmy2ge7vuygrmT3PCBDRjQ9AylRQFOC2eFWMo4DBii51BY7c3dR50lWPuUYB+EPUlWN0jvcMaItga1HToD7.yAs6O.0X1TRP.0EYXr2OqCfQ98QQe+8qaP7HbGZ5THz6ELG5uv7YpzY6U+sLOuNDW5.leFuKWuqif2T3IBAxtG1BMk3bEYL8Bh1sbXjwWz1koDx9JhhFfL1ugvcV+I.Ii8+8r.1POpdfMpODn3o6H7b0LVOKp4Dlmau4Ik.DDkdoon8hSQeC9blKaw7oopuNxfYJhr4Cibahd1Yom01SOiLza+X58BbeGIapJ0hlaOE2kqnxQD3HHKsh8Ek6aygaJ.O3pi8IWQ6HgAKPTppk0QlUrrN7UEKTrvbGGSUME9SEbXPoCzJjFJ9AGdbfddtRJ7ZR77FBmSkD7DyIFN7UEJv3dLN0bTH2QwDby66SIm4A+HyqIdgzCK7oBl5u17w.xi8DDWMjKCnxXoYoQDu.JD76f3uFdpkyafmIl2HOW1mshmZHLQXvJ4Z1TfPQeGujND4KbWAy6aZznUZKgJdT4JMqqkjaBXIdn+PpLyFHxQPTsrpEudUa1hJm3LeFGE7tbl5cSo70okQIGWfpduDVA+ohzzeUhltuGykJQLP59D7a4hg1nHBmzm3y+Tg+70n0ANtUUD373jivkfG+sUvSTpq.9kcaQTDcoYx9A1iSoRESm9LZAp.GZbgZdbKZvUJwTHKuPeB++etkuMcAeS8YoCpTGkINOUkzsJNNc.UnhwGOfAGW5n8b7zHcXCo3FPTlMpkyD0OOn9MLW0jES7G+V8IT13IoMs+qaqmrWi2XOG2aoHOb7791OCW1tpUsxurR0yPLE0OigSNqV0Z0rO6zLFNI1xKA.111UPQoVieG+ohPA1AZ4Uex0z3SlC9ASkLjdzBSQsNkqwntXJ3AypE6I2n8vvQtVHApouGZIiWDpYaneDlSKV3NT1igmrEhvzTec1xGnKm5gyh6k5Q+XcVv4BeXoHxYyKs1tUetFNypK+eX0e3MRv8hB2POhZ4KK0uPHw.zKZoakz27vCXpYYeAwixMnaKceAtGS4LY07M2J3KzA3wluIuGoHt8nQTGUJY2G24CO9O9.8qhPcGkyIJICDQXnPnOTz5PAlv4TO88EF4zsTiGaoGqyL8ob2nA+C7kXzVO1Hwn8biHehiT7Qm3dx5W77kQy.bhG8vu73y0iMWbQ.FacrExGdH1GcbzohuG39pwbxNf4zc.S4c.Skc.S0c.Ssc.yYaDi9MvuITI7iKSfI50NtusQaNATYQJRz+Ry8jIL
-
@SteveRiggs said in A way to make preset up and down buttons?:
> inline function onNextBtnControl(component, value) > { > Engine.loadNextUserPreset(false); > };
Why have you set it to false, it should be set to true if you want it to load next or previous preset I think.
-
@ulrik please read the documentation.....BEFORE you comment (yeah I know I do that too sometimes - silly me)
false here is (bool stayInDirectory) not do or not do....
-
@ulrik That parameter determines if it stays within the folder when loading the next/previous preset.
-
@d-healey ha! beat you to it.
-
@SteveRiggs That snippet won't even load for me, HISE crashes instantly.
-
@Lindon said in A way to make preset up and down buttons?:
@d-healey ha! beat you to it.
I'm glad it makes you so happy :)
-
@SteveRiggs <-- your snippet is crashing HISE so something else is broken bad in there.
-- oh look Dave beat me to it <rats>
-
@d-healey yeah I'm a trivial person really....
Sorry ---getting us off topic....its been a long day...
-
My guess is that saveInPreset is not false for the button so that loading a user preset triggers the callback again and you get an endless loop.
-
@Lindon sorry, I was to fast and stupid...🤭
-
@d-healey thank you, I think I should stay out of this kind of discussions...🤭
-
@Christoph-Hart That's got it! Good guess. It seems to be working now. Cheers dude!
@d-healey @Lindon @ulrik Thanks yet again for all your help. Got there in the end :)
I'll put the new working example snippet here incase anyone else needs it in future....
HiseSnippet 1204.3ocsW0sbZbCEVqsUSXSnoYl9.ngqfotNK9+TGOACF2xDaLiAm16xH1U.Z7hDiVs1lIimI8MouF8tdWuMOJ8Mn8ncWfEaL1CS8dERmezmNmi9NGZnjtrf.oBYko0vALj0KwMGJz8pzixEnZGhr9AbCE6RRc10ZB7q.llb9.BU3QNTdkfTNTqkh.RqpMagJOb.MHf4grrV9mMNvJyJnnu+48ko9TgKaxVHzGkbW1w79b8jcaT5Cbe+indrV79ozdyR0bkhJReYH.1kwNnAT2KncY0oF0VBir9lpdbsT0TS0r.j0JkkdCa1C.Yr9ejGva6yLKJhZBNJd6ij9dFDa1EUoG22qwnfR.B7RiIgnkiCQeO9DtGe79SBUeWj.xDKRGOrVZdvqXZ3473gmUJ3sRL7dMtoqhOPOQhAau.WSnYpNTHEjFVw5hV5OWFWQBZHzq0mdA6HErXrE421wYUxVNNE1KqcV6QJ1koqH6OPJfE4yYpPJqE4JrVfYegVI8qP88aC4o7RQh3DAE1y1lK74BFoSnvUykBxs0Iu6HmuJ4RpeHqf8msIluphtfkq4KodFSNOfohKMy2g5Gv.meC3+6Amlx44fyDwyEmSqyiBmFS3xvfYhUSP8Mugz7WN8WIUN+rypVuEowYUaVsEo9AmTkTqN4.xwGTt5w1vif.MbLJxwz1L+hj8Iy9ZFKN2ru.ePHaW7gfOuCIexMv35PkBzYB9MO7xWfr+9jb4JDeegu4CFSHOeNMjyxsJIWMAWa.nwNFDKVDm7f.LoXX1tLJNbeUBoCRE1KcYpTyNUj2DmxXeiM41h5zYlxRbkOSMSwF9N07LLuHrealJUVJRQ3g+zLK36mYIMwmabDIkhRgIib5.l393aPIgQCySBp.U0Q7NeaBuSSetGSg3.8xyvQwPTDfS3x+x91+86QmW6PplNxMfGgSY.So4lKf0gvaEWVLcVF7grfKzxAvEablCtyO3gd8jlGGTZ3jEaUBkxOuPmvoG6mif2pZtnaKNDvLd6U3AQESkUxqfJqzdcyTd8KsJcE2S2a7F+0uWpGi2s2jVae85RI203K1qvMlxys6Np61KwaVbamc17sas8tHtl0Okf02cms2Ymh6tQJAqGK4sfAEKVbKTTn05OveNK7hJmIA2jdIKtSctehnUgrUGKJpAi5dDZJmCtytlxsj9920czKkJ.Zlt0SIrdnAsg8irYir12fRmFd1zoyXuGk.xfSXaSE5KwmNgNcnGxE2JzidWo.HBTSDGwM88drGdRKozGt5+0CGGe3YSN7HRtny943XBuTG8WGl9neWICGHxxFeLi5QbbfWr2cb.XnDoWnOUO8jJlwyRD.jLSMRfosuHfqGld7smjwWdrv803FbsauYi2klAdAhkmZ7lLLXVb0NcXt5IfcE7Q+1S+jenyjgFhpSnZEGpPvv6ql.WfKCPhP.sSg8rVxPYGu1wr1DYZxDdQK9W3KQXQyZqDgEGID0m5pjexMln2Lt4yi1AvjHZp6L3SLqIiY3wXm0bP8gof+jqqIT7i.1msMqu.1rwBXylKfMas.1r8BXyNKfM6NWaL+AjCB0x9wOSfMZTMtcfUUAEpxhpHQ+Gc+O3bC
-
-
@ulrik honestly mate no one can be quite as stupid as me at times....keeep.contibuting please.