Do I not understand the setLoadingCallback?
-
@Lindon Oh I just had a look through your Console output above. It could be what you're seeing is due to the loading callback running in an asynchronous background thread, so there is a lag between the values you're seeing and the actual state of the instrument.
-
@d-healey yes precisely...so I need a callback that CORRECTLY tells me when the loading thread has actually finished - and I think that setLoadingCallback isnt doing that.
Perhaps it is telling me the truth - everything IS finished...but sadly when I assume this - and start setting the start and end positions for samples - it fails
-
@Lindon I think it is correct, because it's asynchronous it will always be behind, never ahead, so if it says loading has finished then loading must have finished.
@Christoph-Hart Any insight?
-
yes @Christoph-Hart any insights gratefully received.
-
@Lindon hmmm... it seems that the setPostCallback gets executed after all of these - perhaps I could use that...
-
@Lindon nope now this is executing BEFORE not after - wow nothing in here is consistent.
-
@Lindon Were you able to make any progress here? I'm having the same issue - and without the callback, everything fails, because my scripts begin processing the sample map before it's loaded. :(
-
@clevername27 said in Do I not understand the setLoadingCallback?:
@Lindon Were you able to make any progress here? I'm having the same issue - and without the callback, everything fails, because my scripts begin processing the sample map before it's loaded. :(
Well I think I got this to work - the product is out there - so I will try and take a look if I get time otherwise Christoph is you man here...
-
@Lindon Thanks - likewise appreciated.
-
@clevername27 getPreloadProgress() repeats itself from 0 to 1 and it doesn't return a sample map name, that's getPreloadMessage().
Panel's getLoadingCallback will return 1 of its preloading. While it will return 0 with the preload not yet finished (but rather at 90-something percent), you can query whether the preload has finished with a timer and if (getPreloadMessage() == ""). Start the timer in the loading callback with if (isPreloading == true)
-
@aaronventure Thank you!
-
@aaronventure On second thought, I can't follow what you're saying here. Could you pls explain it to me like I'm 5?? :)
-
@clevername27 what have you tried so far?
-
@aaronventure Mostly sacrificing my collection of rare Creed memorabilia.
Appreciated - I'm not sure this is granular enough for me to answer your question. There are so many variables here that I don't how to proceed.…
-
@clevername27 the panel's loading callback should, on 1,start the timer. The timer should run at 500ms intervals, checking whether the preload message is an empty string. That way you know the preload is finished (because it can only get started with the preload start, and can only return an empty string if the preload is finished) as the panel callback doesn't properly return a 0 on preload finished, but rather blows its load a bit too soon.
The callback starts the timer, the timer checks for preload finished by fishing for an empty string.
-
@aaronventure Thank you - I think I understand. You're saying that with:
setLoadingCallback(function(isPreloading)
…isPreloading gets set to 1 before preloading is actually complete?
The context here is that the Samplemap is being loaded from a saved state when the plugin starts up. After the Samplemap is loaded, I need to do something - but it's always too early.
-
Oops, a bit late to the party but what's the problem with
Panel.setLoadingCallback(function(isPreloading) { if(!isPreloading) doTheStuffWithSampleMaps(); });
no timers or preload message hacks necessary, the
isPreloading
will guarantee that the samples are loaded). That's how I'm using it and it never failed me so far... -
Ah nevermind, I looked at the first post.
The loading callback is being executed every time when the sample loading callback picks up its work and finishes it, but it might be possible that this will happen multiple times if you load many sample maps as each of those is a single job.
It's therefore not 100% precise but I guess that was OK for me because I
- didn't rely on it for doing actual logic
- didn't use it in projects which loaded many samples at once
Now the proper solution for this (and I think that was requested by @gorangrooves last year) is to add a event type to the broadcaster that attaches to the event notifications of individual samplemaps - they get notified when a sample map was loaded, a new sample is added and a sample property is changed. This way you can write that logic in the place where it belongs and not a callback that was supposed to hide a loading progress bar and is working overtime since 2016...
-
@Christoph-Hart https://forum.hise.audio/post/76283
This is the primary issue.
It's returning 0 before the reloading finishes so if you have a percentage bar that you're refreshing, it stops just shy of 100%. The solution is to check the reload message string with a timer for the bar refresh and set it to 100% when it detects an empty string.
-
@aaronventure the primary issue is that this callback does not have a precise execution order.
I've added the
attachToSampleMap()
function here:https://docs.hise.dev/scripting/scripting-api/broadcaster/index.html#attachtosamplemap
Remind me in two days to update the broadcaster wizard...