HISE Logo Forum
    • Categories
    • Register
    • Login

    Do I not understand the setLoadingCallback?

    Scheduled Pinned Locked Moved General Questions
    45 Posts 5 Posters 3.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • LindonL
      Lindon
      last edited by

      The setLoadingCallback seems to fire sometimes BEFORE all the loading has happened. I understood this to get called once all the loading has happened....

      Here's the situation:

      I have 16 samplers, all loading at the same time, they do so using a pretty simple callback in the text name of the sample map like this:

      inline function onSampleNameControl(component, value)
      {
      	//Load the Sample..
      	local pos = theSampleMapNames.indexOf(component);
      	if(theSamplers[pos].getCurrentSampleMapId() != component.get("text"))
      	{
      		Console.print("..........................Loading Sampler " + pos + " - a sample map called..." + component.get("text"));
      
      		theSamplers[pos].loadSampleMap(component.get("text"));
      		Console.print("..........................progress for the loading is:" + (Engine.getPreloadProgress() * 100) + "%");
      	}
      };
      

      So I think the above should write out the number of each sampler being loaded

      I also have a setLoadingCallback like this :

      CirclePanel.setLoadingCallback(function(isPreloading)
      {
      	if(!isPreloading)
      	{
      	        // so all the samplers should now be loaded.. 
      	        Console.print("#### Preload has ended ######");
      	        Console.print("progress for the loading is:" + (Engine.getPreloadProgress() * 100) + "%");
      	        // every sampler should now be loaded....
      	        
      	        for(lseg = 0; lseg<segmentData.length;lseg++)
      	        {
      		        Console.print("For sampler " + lseg);
      		        Console.print("     ----- the index is:" + segmentData[lseg].NoteInScale);
      		        Console.print("     ----- the start is:" + segmentData[lseg].SampleStart);
      		        Console.print("     ----- the   end is:" + segmentData[lseg].SampleEnd);   
      	        }
      	        
      	        //sampleLoadTimer.startTimer(1000);
              //};
          }else{
      	    Console.print("Starting to load something.....");
      	};   
      }
      

      So once we reach the point where everyone is loaded I should see a nice list of Sampler details...BUT...

      I'm getting this in the Console:

      Interface: Starting to load something.....
      Interface: ..........................Loading Sampler 0 - a sample map called...Catchy Ocean_All I wanna
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface: ..........................Loading Sampler 1 - a sample map called...Catchy Ocean_Badly
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface: ..........................Loading Sampler 2 - a sample map called...Catchy Ocean_close to me
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface: ..........................Loading Sampler 3 - a sample map called...Catchy Ocean_day dreamin
      Interface: #### Preload has ended ######
      Interface: progress for the loading is:0.0%
      Interface: For sampler 0
      Interface:      ----- the index is:0.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:58218
      Interface: For sampler 1
      Interface:      ----- the index is:1.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:132300
      Interface: For sampler 2
      Interface:      ----- the index is:0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:22050
      Interface: For sampler 3
      Interface:      ----- the index is:0.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:132300
      Interface: For sampler 4
      Interface:      ----- the index is:1.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:132300
      Interface: For sampler 5
      Interface:      ----- the index is:0.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:132300
      Interface: For sampler 6
      Interface:      ----- the index is:0.0
      Interface:      ----- the start is:0
      Interface:      ----- the   end is:132300
      Interface: For sampler 7
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the index is:0.0
      Interface: ..........................Loading Sampler 4 - a sample map called...Catchy Ocean_hold you so tight
      Interface:      ----- the start is:0
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the   end is:132300
      Interface: ..........................Loading Sampler 5 - a sample map called...Catchy Ocean_houhou
      Interface: For sampler 8
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the index is:0.0
      Interface: ..........................Loading Sampler 6 - a sample map called...Catchy Ocean_I like the way I feel
      Interface:      ----- the start is:0
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the   end is:132300
      Interface: ..........................Loading Sampler 7 - a sample map called...Catchy Ocean_I want you so
      Interface: For sampler 9
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the index is:0.0
      Interface: ..........................Loading Sampler 8 - a sample map called...Catchy Ocean_just leavin
      Interface:      ----- the start is:0
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the   end is:132300
      Interface: ..........................Loading Sampler 9 - a sample map called...Catchy Ocean_Me Up
      Interface: For sampler 10
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the index is:1.0
      Interface: ..........................Loading Sampler 10 - a sample map called...Catchy Ocean_Out of time
      Interface:      ----- the start is:0
      Interface: ..........................progress for the loading is:91.66666666666666%
      Interface:      ----- the   end is:132300
      
      

      As you can see it loads the first 4 Samplers (0 to 3) just fine - but then the setLoadingCallback kicks in - when it clearly shouldn't as theres more Samplers to load

      What am I doing wrong?

      HISE Development for hire.
      www.channelrobot.com

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @Lindon
        last edited by d.healey

        @Lindon The loading callback triggers twice, when loading starts and when loading ends.

        Link Preview Image
        HISE | Scripting | ScriptPanel

        The ScriptPanel API methods

        favicon

        (docs.hise.audio)

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

        LindonL 1 Reply Last reply Reply Quote 0
        • LindonL
          Lindon @d.healey
          last edited by

          @d-healey precisely - its kicking in When it starts and again BEFORE its ended...

          HISE Development for hire.
          www.channelrobot.com

          d.healeyD 1 Reply Last reply Reply Quote 0
          • d.healeyD
            d.healey @Lindon
            last edited by

            @Lindon I wonder if it retriggers for each sampler.

            Free HISE Bootcamp Full Course for beginners.
            YouTube Channel - Public HISE tutorials
            My Patreon - HISE tutorials

            LindonL 1 Reply Last reply Reply Quote 0
            • LindonL
              Lindon @d.healey
              last edited by

              @d-healey then how in heavens name do I find out when every Sampler has been loaded?

              HISE Development for hire.
              www.channelrobot.com

              d.healeyD 1 Reply Last reply Reply Quote 0
              • d.healeyD
                d.healey @Lindon
                last edited by d.healey

                @Lindon You could do a test, every time it says it's finished preloading you increment a variable, if the variables value == the number of samplers then all samplers are loaded. This test will also tell us if it does retrigger for every sampler or if there is an issue.

                Free HISE Bootcamp Full Course for beginners.
                YouTube Channel - Public HISE tutorials
                My Patreon - HISE tutorials

                LindonL 1 Reply Last reply Reply Quote 0
                • LindonL
                  Lindon @d.healey
                  last edited by Lindon

                  @d-healey nope cant do that - the setLoadCallback only executes once!! - already worked that out...

                  HISE Development for hire.
                  www.channelrobot.com

                  d.healeyD 1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Lindon
                    last edited by d.healey

                    @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.

                    Free HISE Bootcamp Full Course for beginners.
                    YouTube Channel - Public HISE tutorials
                    My Patreon - HISE tutorials

                    LindonL 1 Reply Last reply Reply Quote 0
                    • LindonL
                      Lindon @d.healey
                      last edited by Lindon

                      @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

                      HISE Development for hire.
                      www.channelrobot.com

                      d.healeyD 1 Reply Last reply Reply Quote 0
                      • d.healeyD
                        d.healey @Lindon
                        last edited by d.healey

                        @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?

                        Free HISE Bootcamp Full Course for beginners.
                        YouTube Channel - Public HISE tutorials
                        My Patreon - HISE tutorials

                        LindonL 1 Reply Last reply Reply Quote 0
                        • LindonL
                          Lindon @d.healey
                          last edited by

                          yes @Christoph-Hart any insights gratefully received.

                          HISE Development for hire.
                          www.channelrobot.com

                          LindonL 1 Reply Last reply Reply Quote 0
                          • LindonL
                            Lindon @Lindon
                            last edited by

                            @Lindon hmmm... it seems that the setPostCallback gets executed after all of these - perhaps I could use that...

                            HISE Development for hire.
                            www.channelrobot.com

                            LindonL 1 Reply Last reply Reply Quote 0
                            • LindonL
                              Lindon @Lindon
                              last edited by

                              @Lindon nope now this is executing BEFORE not after - wow nothing in here is consistent.

                              HISE Development for hire.
                              www.channelrobot.com

                              C 1 Reply Last reply Reply Quote 0
                              • C
                                clevername27 @Lindon
                                last edited by

                                @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. :(

                                LindonL 1 Reply Last reply Reply Quote 0
                                • LindonL
                                  Lindon @clevername27
                                  last edited by

                                  @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...

                                  HISE Development for hire.
                                  www.channelrobot.com

                                  C 1 Reply Last reply Reply Quote 0
                                  • C
                                    clevername27 @Lindon
                                    last edited by

                                    @Lindon Thanks - likewise appreciated.

                                    A 1 Reply Last reply Reply Quote 0
                                    • A
                                      aaronventure @clevername27
                                      last edited by aaronventure

                                      @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)

                                      C 2 Replies Last reply Reply Quote 1
                                      • C
                                        clevername27 @aaronventure
                                        last edited by

                                        @aaronventure Thank you!

                                        1 Reply Last reply Reply Quote 0
                                        • C
                                          clevername27 @aaronventure
                                          last edited by

                                          @aaronventure On second thought, I can't follow what you're saying here. Could you pls explain it to me like I'm 5?? :)

                                          A 1 Reply Last reply Reply Quote 0
                                          • A
                                            aaronventure @clevername27
                                            last edited by

                                            @clevername27 what have you tried so far?

                                            C 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            27

                                            Online

                                            2.0k

                                            Users

                                            12.6k

                                            Topics

                                            109.7k

                                            Posts