Can I manually trigger a Callback function?
-
@Lindon thanks. trying to figure out what you did there. I can see the loading function changed, makes sense.and the buttons simply need to be assigned a radio group, correct?
-
@Morphoice correct - you probably want to do something on "empty" - like load an empty sample map, but for this I just jumped out of the callback so the sampler would keep its currently loaded sample
-
@Lindon said in Can I manually trigger a Callback function?:
what problems are these?
It's been a while since I used it, the only I remember is if you want the option to have no buttons pressed then the radio group won't work. I thought there was some issue with restoring their state from presets too but I might be misremembering.
Since I'm usually writing callbacks for them anyway though it's not really any extra work to add a couple more lines to get radio group behaviour.
-
@Lindon @d-healey gotcha! seems to work like a charm, and it suddenly is successfully wirtten and recalled to/from a preset. that might - if I'm not overlooking anything - solve all my problems at once.
only thing I'd love to have is actually hearing the selected sample on selection but if I use the sample loading callback it would trigger upon preset restore aswell
-
@d-healey said in Can I manually trigger a Callback function?:
@Lindon said in Can I manually trigger a Callback function?:
what problems are these?
It's been a while since I used it, the only I remember is if you want the option to have no buttons pressed then the radio group won't work. I thought there was some issue with restoring their state from presets too but I might be misremembering.
Correct about the no-buttons-pressed option, never had an issue with them restoring state in 8 years of using them....slightly frightened now...
Since I'm usually writing callbacks for them anyway though it's not really any extra work to add a couple more lines to get radio group behaviour.
Your call....
-
@Lindon said in Can I manually trigger a Callback function?:
slightly frightened now...
It's more likely me misremembering some issue I ran into years ago.
-
@Lindon said in Can I manually trigger a Callback function?:
you probably want to do something on "empty"
they'll all be occupado in the end, I just wanted to focus on the functionality before I create all the sample maps and proceed to sample all my hardware drum machines
-
@Morphoice said in Can I manually trigger a Callback function?:
@Lindon @d-healey gotcha! seems to work like a charm, and it suddenly is successfully wirtten and recalled to/from a preset. that might - if I'm not overlooking anything - solve all my problems at once.
only thing I'd love to have is actually hearing the selected sample on selection but if I use the sample loading callback it would trigger upon preset restore aswell
I dont really understand what you are saying in this last bit - you select a button and it loads that map - isnt that what you want?
-
@Lindon said in Can I manually trigger a Callback function?:
you select a button and it loads that map - isnt that what you want?
yes. I was just thinking an audible preview of the sample after it's loaded might add some comfort for the user if they switch through the available samples
-
@Lindon I tried firing a note after the sample is loaded successfully but the problem was this would not work when the button is clicked but fire on recalling a preset, and there we wouldn't need it,
-
@Morphoice so use the preset manager to set a "loading a preset" flag , and uncheck once the preset is loaded...
In your buttons check to see if this flag is set - if not then it really is a user pressing the button(not a preset loading) - so you can play a demo note...
https://docs.hise.dev/scripting/scripting-api/userpresethandler/index.html
you want setPreCallback (to set the flag ON)
and setPostcallback (to turn the flag OFF) -
@d-healey I'm glad I'm not the only benefiting away from from the mess I caused. Unless you want all buttons off radio groups seem to be fine to use.
-
@Lindon aye! the playing never worked on the button press though. only ever on the preset load. I'll have to revisit the way I fired the note
-
@Lindon this was the way I did it before
Bass.asSampler().loadSampleMap(bassMaps[bassProms.indexOf(control)]); Bass.setLoadingCallback(Synth.playNote(36,127));
and that only seems to fire on preset loading, not on the actual button use
-
@Morphoice You can…
-
Call it by function name (pass in the component as the first argument).
-
If you want the callback after a component value change, call onChanged(). Except if it's during onInit. That won't work.
-
Register the callback for use with a broadcaster. Then, trigger the broadcaster manually.
-