Loading Bar
-
Hi! Just wondering if anyone knows of a way to make a loading bar function within a set range, say 0 - 1 whilst say a sample is loading in to the VST, is this even possible?
i've seen some set to timers and built one of those myself, but when i link it up to the loading callback it just counts until the file is finished loading, giving me values of 60 or 140% complete.
Here's my code if anyone's interested :)
//PROGRESS PANEL const var pnlProgress = Content.getComponent("pnlProgress"); pnlProgress.setValue(0); //PAINT ROUTINE pnlProgress.setPaintRoutine(function(g) { g.fillAll(C); var a = [this.getWidth() / 2 - 400 / 2, this.getHeight() / 2 - 20 / 2, 400, 20]; g.setColour(0x005995C9); g.fillRoundedRectangle(a, 5); var v = this.getValue() / 10; g.setColour(Colours.white); g.fillRoundedRectangle([a[0], a[1], a[2] * v , a[3]], 5); v < 0.1 ? g.setColour(Colours.transparentWhite) : g.setColour(Colours.black); g.drawAlignedText(v * 100 + "%", a, "centred"); }); var preloading; pnlProgress.setTimerCallback(function() { var v = (this.getValueNormalized()+1); Console.print(v); this.setValue(v); this.repaint(); }); pnlProgress.setLoadingCallback(function(isPreloading) { if(isPreloading ){ preloading = 1; Console.print(preloading); pnlProgress.startTimer(200); }else{ preloading = 0; Console.print(preloading); pnlProgress.setValue(0); pnlProgress.stopTimer(); } });
Please help!
-
-
@d-healey Thanks! this is great but it still has the same issue, it doesn't get to 100% each time, is there no way to normalise this and have each sample make the bar hit 100% once it's finished loading?
-
Maybe you've found a bug, as far as I know
Engine.getPreloadProgress()
should always return a value between 0 and 1.