UserPresetHandler.setPreCallback does not work properly
-
I had to refactor the logic for a few controls to avoid some weird behaviors when loading presets, so I need add backwards compatibility for older presets and session. I've used
setPreCallback
successfully before, but it only works in very specific occasions, and the callback doesn't seem to function properly.In this case, I need to invert the value of a slider (0-1) from older presets, but this code does not work:
const var up = Engine.createUserPresetHandler(); up.setPreCallback(function(data) { for (d in data.Content) { if (d.id == "cornerA_Sample_Start") { d.value = 1 - Engine.doubleToString(d.value, 3); } } });
I've also tried every other permutation like
d.value = 1 - d.value
and for some reason it will never update the value of the slider if you try to do any math with it. In fact, you can't evenConsole.print()
anything if you put it after an assignment liked.value = 1 - d.value
, so it seems like the callback function aborts completely.Note: If I use a hardcoded value like
d.value = 0.5
it will work, but I need to be able to do logic on previous controls..@Christoph-Hart Any ideas why this callback would function this way?
-
@Casey-Kolb Can you reproduce it with a minimal example?
It might be possible that a script error is not propagated to the console in this callback so if you do something wrong you won't get notified, but there is nothing special for this callback that would prevent doing dynamic things. If you use
Control.print(d.value)
before the assignment, what does it say? -
@Christoph-Hart Let me try to do a minimal snippet. If you print
Console.print(d.value)
before the assignment it will work, but not after. -
@Casey-Kolb Did you call this function
UserPresetHandler.setEnableUserPresetPreprocessing(bool processBeforeLoading, bool shouldUnpackComplexData)
? -
@d-healey Yup!
-
@Christoph-Hart Here's a really simple snippet where it will only ever print "Before Assignment" and not "After Assignment" if you try to modify the preset value:
HiseSnippet 1249.3ocsV0saaaCElxIJq1saccn6dAicgCfqgcSW2vJBR7ucFsI0KNsa.ECcLhT1bQhTfjJItEAXWz62dRFvdBFv.1CxdC1c6xrCkjsjSbSSLP4Ex97K+NjmygmARgKUoDRjUw8mDRQV2xd3Dtdb6wXFG0uCx5F1CjTEUiZMIDqTTBxxZkGajZUbUT75e2pE1GycoYrPnWHXtzmxBX5LtC19ILe+dXBceVPNsev18cE71BeQDfjUrqiBwtGhGQ2EaTqfMxZstDlVHGpwZpBzokfLY3Xww7D8eASwNvmZHZfFBNJgMp8XlOYvznTgPVqN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PPh7w54mMvLDTp.Cfy+fr4QWHWTOIOntFCLT+RGX3pBw6XOfocGuXLVXAXDZw9g.ioiY8w1c87nt5L.tpcueXYmo58r86IhL8y2ACW8PhfMzAXHzS0kB6NmS8Ul11ELORkPW2PaNAFR4jXhyfUpvFFZqTgMlJDR5bkhW4l7zlYPtaDyAvDOdt0h16Xncl8llsc8Z0MI5rW45ZB+60.gVrM2eIrYikvlGrD17kKgMObIr4qVBa95K0Fy37MizhfjxAfwftwurZYkLYabVH5+Aejij8.
-
@Casey-Kolb
I wonder if it's becauseContent
is a keyword.Oh I know what the problem is. Do
Console.print(trace(data))
and see if you can spot the issue.If you give up and just want the answer:
HiseSnippet 1206.3ocsV0saaaCElxIpq1cacEXO.DF6Ba.WW6lttgEDD+Sr2LZSpWTZ2.5FJXjns4hDo.EURcKBvvPue6UYOR61c0taWlcnnrjbhSWmwptvI77cNjemCO+vwRgKMJRHQVkOZdHEY8g1Ny4pY8mQXbzn8PV2zdrjFQUndyCIQQTOjk0FesF0p7lnju+Z2dDeB2klKBgdlf4ReLKfoxkNtyiX99CIdziXAEz9AcF4J38E9hXfIaX2BERbOgLkd.QqVIaj0MF3wTBoihnnQHqM6I7l6LSbF2n+yXQri8o5EsQNvFYDOT36oYrVJp+Llu23EdbDB1kw49+FF++Ss2m4wxjmGG9jD.btEEiGVkVldarD8ZWjdsJPuUPIqBTZSCktisiqjEpxQz74V1i3JpbBAB6EohQWTo9kr6K.M3plAjSnCkvhLKp8vVsZfgepuckJPnORgOkHwwg3cvC3SYbZSWIE7kmFQkl6+ugv87oxZZKhCaBRFvIfOkqA7anghL9zZJYLsAV+atEfF8I99GCWt0lDycULAulGQQpieckxUJOQHw07vLNVKrYJ+qWo7qqfS+XS.MZx7v6rCt5i3hiaWsdFHrIK9Wv1HgOsYnjwU0p1iB6ME2E31Td.roUAVkorWySI9wTv4aiuKNjHinC8EDUsTf5aiu28xzhEgIXGErwSwame3q3T6NAh2W5PWn54UL+dd8sWDJvB9ABE8I7Z0qniGfJWFZxjUhoiTRgex8yJf0Uax2lg03wAGSkMvF2cghPJ3x401WedcwxNWyEWAEE7Qbl5IgT90ULhRus00.orBTUkTA7woU.N9LOpDwfD8OvN4xGkP3zNI3e3W+ycQOczdPxyhsA1Q3TBoRES6.V6QOE5KYJrJauGM5DkHDZwzWDDJ35y25VpzNAlCMIS.tqOhANp9nuscQQsQuLuQ1m0Yd1hN+TmyXdpYYBv+RmYT1zY4MDwxNobzPnam1qsmTbFTVgNd5hdhkuAn9eqsgonA4R+8K9sKVV58SUN4KIRT5Mkr0EPU02GNjSo8hUJAu5WkTc1XAxfWFR3QPZQT2HXqhCzZLg3GkqRR6T4pMWmdFck8DxdLpuDTtXHgF7W.qcqLi554s5i3PJGlGrZr8n9T00fMjbpPBQH8PlhXoLaD30dzdBI3aK4xGDGXBDZxuUhHy5uSeudHjBH.fmmTH2p4VW5qw+Q4f3eL4LdLKR0E59lEaROgFq5OYVYX1ghyFS77fby2U6bnDo6rdDYOQL2S6oO2.rOzvzDgtLRdNzkQVDouBZky0E3YkX1+q004EU+72VnnBVDongNrWsnnuye7p2rK5pSMg40BuXehZ4g35WtjB.o5KM4TOcDRETyK9xl+2lr+tRw6XOlobmsZNVZEbD5z89fiouG5irGLYB0UkSvMsG98ued7C5PQrts59DX3Jj.XCEfNPKMWJb5bN0WOAxpjdVgYcK8ZcDvgx8RVbA7kB1Vu1JEr8BPT.wUJdgqYBi9EW2LQBvIdxiMKauudMNazhscqlsPAvi+dgqq18uKL9Z01b+0vlsVCadvZXymuF17v0vluXMr4Keq1ne2c2XkHvTN.BFOHYvlkk4InIYgn+gx7122
-
@d-healey Oh yes I had tried
doubleToString
in the example above for that very reason, and that didn't work. I wasn't even aware ofparseFloat
in HISE haha. I knew the string must have something to do with it but couldn't find a way to convert it without the function aborting. Nice one! -
@Christoph-Hart Back in business! Working now with
parseFloat
-
Oh yes I had tried doubleToString
That does the opposite.
I wasn't even aware of parseFloat
Was only added a few weeks ago.
-
@d-healey said in UserPresetHandler.setPreCallback does not work properly:
Oh yes I had tried doubleToString
That does the opposite.
My brain is fried...how did I miss that?
Edit: I actually tried
Math.round
first and that didn't work. -
@Casey-Kolb I think these t-shirts are going to sell out fast!
-
@d-healey but it creates a special bound between us all, doesn't it?