HISE Logo Forum
    • Categories
    • Register
    • Login

    Confusing results from message delay?

    Scheduled Pinned Locked Moved Scripting
    16 Posts 2 Posters 420 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.
    • VirtualVirginV
      VirtualVirgin
      last edited by VirtualVirgin

      Here is a simple test of

      Message.delayEvent(int samplesToDelay)

      A note is played from the GUI keyboard.
      The note on message gets a 2 second delay.
      The console is told to print "delay?".
      A note off is produced with 2 second delay.

      Expected results:
      Pressing a note on the keyboard should make both the note sound and the console print "delay?" at 2 seconds from the note press.
      2 seconds later the note off should silence the note.

      Actual results:
      The note press immediately creates a note off (no delay) as well as prints the "delay?" text. 2 seconds later the note on sounds. 2 seconds after that, a note off is produced which does not close the note on, and the note on hangs.

      Screenshot 2024-11-10 at 8.30.42 PM.png

      I am not sure what to make of these results compared to what I was expecting.
      Why does the delay work in some ways but not in others?
      Why does it not delay the console print?
      Why did it start me with a note off?
      Why does the supplied note off not close the note?

      HiseSnippet 1460.3oc4XstSabDEdVLaT7lzplpnpz9qQn9CS.Ys1g.3jhBWrcBJwAWLgTopnnw6N1dDqmY6riMXEgTUeR5iReD5iRdCnmYVa7tDCgZQRZRs.Ay452NyY9Nm00kBOZTjPhrb1aPHEYcS6FC3pNa0gv3nsKirti89BlGEW4nv.gOUhUzHEi2Fs4fPRTD0GYYk4wZqsxNKx74sOZSR.g6QGKBgLQ4YrtL0Xo0W+orffpDe5drtIrdo021Sv2RDH5AHKisKJj3c.oM84DsYyXidBIpCx5t1ddKUhtZqhq3VrD899K0rXAWRQ2RkVgRtuqWyRTRwVM8bQVWqhOSIjMTD3A.YM6lB+AM5HNjGmf8YQrlAT8hBnFPliEWUD3qeD0RQa0gE3WezVVDBYYWe7FXl3MvaaWi4yNU93Mxuwn.O1ijafVyjFdYRAuBIgmaB3MAHYk.RyFCoaY2vSxBUi0nwyMr2lqnxVD3bJIThsEM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NQUu8QUgGxI5SChpmzTtrQWQOtJU4Qlo5Jcxyjc5Sk8YzCGKah8Yl8+z8Y9LXlsTsByNBiMX59DU38oA.qnAieq8vowGIMcsdMAWD1QvYdIKD1kpjr1soxjXehOPanTv37ikb602kBuzWxh5eb8mAEiDodX9obunv+5uAgIddcG6X3h0WPweYPzm4+mD86J5oeE7ZDnPEdmaaXpoF.+pGc3anoYurlQyQFu1UuNlfk6aVne84gJKnWaMTYgQJ+hIGcIdRwq8hGmSee45FIvdK27sSl0tldMt.xLhWx5nt.y6q87RGp2wwhSqi2aZcboo0w6OsNt7z53JSqiq99cT2XbidJQ2XZADpV8Jl4isrpvIvsJyMPz+.v6lYEG
      

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

      1 Reply Last reply Reply Quote 0
      • VirtualVirginV
        VirtualVirgin
        last edited by VirtualVirgin

        And to further illustrate the problem, why is a benchmark for a 2 second delay reading at 0.005 ms (2 samples)? Clearly some code statements seem to be exempt from the delay.Screenshot 2024-11-10 at 9.52.26 PM.png

        You can listen to my orchestral mockups here:
        https://www.virtualvirgin.net/

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

          @VirtualVirgin Commands always execute in order from top to bottom, unless something alters the flow. The console print is not being delayed, only the message is so it's executed directly after the previous command.

          Same with your benchmark. You're saying start benchmark, delay the event, stop benchmark. Delay the event doesn't pause execution or affect the flow of the current callback.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          VirtualVirginV 1 Reply Last reply Reply Quote 0
          • VirtualVirginV
            VirtualVirgin @d.healey
            last edited by

            @d-healey said in Confusing results from message delay?:

            @VirtualVirgin Commands always execute in order from top to bottom, unless something alters the flow. The console print is not being delayed, only the message is so it's executed directly after the previous command.

            Same with your benchmark. You're saying start benchmark, delay the event, stop benchmark. Delay the event doesn't pause execution or affect the flow of the current callback.

            Why?
            The note on is delayed, so the subsequent lines should not receive that note on that triggers it until 2 seconds later, right?
            If not, why not?

            You can listen to my orchestral mockups here:
            https://www.virtualvirgin.net/

            d.healeyD 1 Reply Last reply Reply Quote 0
            • VirtualVirginV
              VirtualVirgin
              last edited by

              How do I delay or pause the code then?

              When I do this it just ignores the delay (it plays and prints immediately):

              Screenshot 2024-11-10 at 11.26.36 PM.png

              You can listen to my orchestral mockups here:
              https://www.virtualvirgin.net/

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

                @VirtualVirgin said in Confusing results from message delay?:

                The note on is delayed

                I think you're misunderstanding it. The event is delayed, the callback is unaffected.

                You can't pause execution, if you want something to happen after two seconds then you need to use a timer or there is a function which I think is called callAfterDelay

                Libre Wave - Freedom respecting instruments and effects
                My Patreon - HISE tutorials
                YouTube Channel - Public HISE tutorials

                VirtualVirginV 1 Reply Last reply Reply Quote 0
                • VirtualVirginV
                  VirtualVirgin @d.healey
                  last edited by

                  @d-healey said in Confusing results from message delay?:

                  @VirtualVirgin said in Confusing results from message delay?:

                  The note on is delayed

                  I think you're misunderstanding it. The event is delayed, the callback is unaffected.

                  You can't pause execution, if you want something to happen after two seconds then you need to use a timer or there is a function which I think is called callAfterDelay

                  I did see the callAfterDelay when searching for solutions, but it won't be suitable:
                  A) it says here that it is not reliable for real-time
                  B) it is expecting a value of 1ms or higher, but I need to pause/delay in a range starting with 1 sample length

                  Screenshot 2024-11-11 at 3.16.41 PM.png

                  How would I implement a timer on code statements?
                  I need to create a pause window, similar to writing a macro where you leave some time to let the previous step(s) process before proceeding to the next step.

                  You can listen to my orchestral mockups here:
                  https://www.virtualvirgin.net/

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

                    @VirtualVirgin For realtime stuff you need to use the Synth timer.

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    VirtualVirginV 2 Replies Last reply Reply Quote 0
                    • VirtualVirginV
                      VirtualVirgin @d.healey
                      last edited by

                      @d-healey said in Confusing results from message delay?:

                      @VirtualVirgin For realtime stuff you need to use the Synth timer.

                      Ok :)
                      Thanks. Watching now.

                      You can listen to my orchestral mockups here:
                      https://www.virtualvirgin.net/

                      1 Reply Last reply Reply Quote 0
                      • VirtualVirginV
                        VirtualVirgin @d.healey
                        last edited by

                        @d-healey
                        This says
                        "the timer frequency is limited to 40ms":

                        Screenshot 2024-11-11 at 5.36.47 PM.png

                        Is that the lower limit for the timer interval?

                        You can listen to my orchestral mockups here:
                        https://www.virtualvirgin.net/

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

                          @VirtualVirgin Unless my maths is wrong it will actually go down to 4ms.

                          Synth.startTimer(0.004); This is working for me.

                          Libre Wave - Freedom respecting instruments and effects
                          My Patreon - HISE tutorials
                          YouTube Channel - Public HISE tutorials

                          VirtualVirginV 1 Reply Last reply Reply Quote 0
                          • VirtualVirginV
                            VirtualVirgin @d.healey
                            last edited by

                            @d-healey said in Confusing results from message delay?:

                            @VirtualVirgin Unless my maths is wrong it will actually go down to 4ms.

                            Synth.startTimer(0.004); This is working for me.

                            Ah, thanks.
                            This method will not work for me then, as I need to implement delays/pauses starting with a lower limit of 1 sample.
                            I will have to find something else to do that.

                            You can listen to my orchestral mockups here:
                            https://www.virtualvirgin.net/

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

                              @VirtualVirgin What is your end goal?

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              VirtualVirginV 1 Reply Last reply Reply Quote 0
                              • VirtualVirginV
                                VirtualVirgin @d.healey
                                last edited by VirtualVirgin

                                @d-healey said in Confusing results from message delay?:

                                @VirtualVirgin What is your end goal?

                                This is for a voice exploder. The delay is the processing window for chord input from an arbitrary amount of voices up to 16. They need to all get written to an array before proceeding to the next step of sorting and allocating the voices to independent channels.
                                The reason for starting with a 1 sample delay window is to allow for quick turnaround for chord inputs where the notes arrive at the same sample (such as the output of harmonizer plugins that output to only one channel).
                                4ms is way too much budget for such a task.
                                I may be close to a solution.

                                You can listen to my orchestral mockups here:
                                https://www.virtualvirgin.net/

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

                                  @VirtualVirgin I have a chord detector script which adds notes to an array as they come in and then processes them. Sounds like a similar thing.

                                  Here's a simple snippet that adds note numbers to an array in on note on and removes them in on note off. Works with notes played at the same time and sequentially.

                                  HiseSnippet 731.3ocsUstSaCCE1tzfV6tngzd.xOKSHTaoEnBMMfdYqaqP0JCMooIjiiSiEI1QNNrUMs248FrcbRfFfJtTokeTky8udNemSFqjTVbrTgvUOYVDCgel0jYBseWeBWfF1Cgeg0HRrloryTc3rHRbLyEgwq7NiBbkxnzm+71CIADAkMWEBcpjSYehGx0y0Nd+OxCBFPbYmvCK3cq8GRkhtx.YBfmUrpihHzyISYGQLtUxB8dRrOB+ZKGhScB0ya6lN65UuUy1McbZ41Bz3rSmNc7Z2fzdqcnTDd09tbsTMQSzrXHoGJcmMwW9CQVANkGycBXFgFnIPkyTi55yCbGeYyIFgvkGOuUsRVq5UVi3t7qzOuk8xTC1yinXSCW5tfTiGAjvEfT4LHsl0DphGomawfmmZMT.SPOBLaJBkLeQk9.1pqD7Pn2LjbNafBDtJhZaWu9F1vOquW0pJ1TagDvs8ar+122yKQP0bovVJNBzdrn15U+U0JARJIvV.9LB.AL.2bJSab3njPGlplISURSylQIw9C8.aGDnXD2Ym3yTrZBvieW09lo2y6QmeEKTdwhRn4OrRFDXb2jyaX1vLWrk7.qIRq0F1WPBRXW4HLIt93c0G13kl0+K3nTLTv0GGwxkGHCbMiMy62lLfxGfvaeYXOhlX3G45.+hXJM2.GbO1EvFYFaohUOV74ZYDrSdKpDPhktIAD80Y1lc9bCP+3ZzICkQDy0yJdS3QP2qemz8GJDWyZLWS8WLFKs.LBcp+GXL+Hwys564wn54.rr0futrWDtmx+YYhlKlNhnU7ehvVv9vD3XJkAUWHXAPxsvkLrkL45FYSGXBS3lJ7W3I2XCiLN2XiKMhBITk7LZ1Vf4LzSR0.XRjdltB78BP1tAJcynXeNDtJdl4pbwTcq.atrAt0xFXqkMv1KafaurAtyxF3t2eflOZcPhVFls1fPiF2O8TBF2WP.FXJaE8OLLOJoG
                                  

                                  Peek 2024-11-11 23-23.gif

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  VirtualVirginV 1 Reply Last reply Reply Quote 0
                                  • VirtualVirginV
                                    VirtualVirgin @d.healey
                                    last edited by

                                    @d-healey said in Confusing results from message delay?:

                                    @VirtualVirgin I have a chord detector script which adds notes to an array as they come in and then processes them. Sounds like a similar thing.

                                    Here's a simple snippet that adds note numbers to an array in on note on and removes them in on note off. Works with notes played at the same time and sequentially.

                                    HiseSnippet 731.3ocsUstSaCCE1tzfV6tngzd.xOKSHTaoEnBMMfdYqaqP0JCMooIjiiSiEI1QNNrUMs248FrcbRfFfJtTokeTky8udNemSFqjTVbrTgvUOYVDCgel0jYBseWeBWfF1Cgeg0HRrloryTc3rHRbLyEgwq7NiBbkxnzm+71CIADAkMWEBcpjSYehGx0y0Nd+OxCBFPbYmvCK3cq8GRkhtx.YBfmUrpihHzyISYGQLtUxB8dRrOB+ZKGhScB0ya6lN65UuUy1McbZ41Bz3rSmNc7Z2fzdqcnTDd09tbsTMQSzrXHoGJcmMwW9CQVANkGycBXFgFnIPkyTi55yCbGeYyIFgvkGOuUsRVq5UVi3t7qzOuk8xTC1yinXSCW5tfTiGAjvEfT4LHsl0DphGomawfmmZMT.SPOBLaJBkLeQk9.1pqD7Pn2LjbNafBDtJhZaWu9F1vOquW0pJ1TagDvs8ar+122yKQP0bovVJNBzdrn15U+U0JARJIvV.9LB.AL.2bJSab3njPGlplISURSylQIw9C8.aGDnXD2Ym3yTrZBvieW09lo2y6QmeEKTdwhRn4OrRFDXb2jyaX1vLWrk7.qIRq0F1WPBRXW4HLIt93c0G13kl0+K3nTLTv0GGwxkGHCbMiMy62lLfxGfvaeYXOhlX3G45.+hXJM2.GbO1EvFYFaohUOV74ZYDrSdKpDPhktIAD80Y1lc9bCP+3ZzICkQDy0yJdS3QP2qemz8GJDWyZLWS8WLFKs.LBcp+GXL+Hwys564wn54.rr0futrWDtmx+YYhlKlNhnU7ehvVv9vD3XJkAUWHXAPxsvkLrkL45FYSGXBS3lJ7W3I2XCiLN2XiKMhBITk7LZ1Vf4LzSR0.XRjdltB78BP1tAJcynXeNDtJdl4pbwTcq.atrAt0xFXqkMv1KafaurAtyxF3t2eflOZcPhVFls1fPiF2O8TBF2WP.FXJaE8OLLOJoG
                                    

                                    Peek 2024-11-11 23-23.gif

                                    Thanks :)
                                    I'll check this out tomorrow.
                                    I did end up solving for the delay problem by moving the rest of the code into a child container with another script processor.
                                    Screenshot 2024-11-11 at 10.52.57 PM.png

                                    Screenshot 2024-11-12 at 12.25.24 AM.png

                                    The notes from the note recorder get delayed by 1 sample, and that gives room for the array to record all of the voices before sorting the order in the next module.
                                    The basic problem that the delay solves is that the array cannot be sorted and reversed until all of the notes are in.

                                    It is working so far:
                                    Screenshot 2024-11-12 at 12.33.00 AM.png

                                    I have a stray note off that I will try to clean up, but at the moment is not effecting the function.

                                    You can listen to my orchestral mockups here:
                                    https://www.virtualvirgin.net/

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

                                    26

                                    Online

                                    1.8k

                                    Users

                                    12.0k

                                    Topics

                                    104.3k

                                    Posts