HISE Logo Forum
    • Categories
    • Register
    • Login

    Very strange behaviour with Engine.getUptime()?

    Scheduled Pinned Locked Moved Scripting
    8 Posts 2 Posters 63 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

      I am trying to measure and record time deltas for MIDI note on messages with Engine.getUptime() and getting very strange results:

      Most of the time, the "currentTime" and "lastTime" are showing as the same here, when I think the logic clearly shows that they should be different.
      This means that inside the inline function, the time difference is always evaluating to 0.
      But when I am using that inline function to record to an array, is recording non-zero values.
      Furthermore, the array and count are set to reset if the timeDelta is greater than 5 seconds, but when even when the array shows that I recorded a timeDelta greater than 5, the array and counter do not reset.

      What could be going on with the values to create such an issue?

      Screenshot 2025-05-31 at 3.50.19 PM.png

      HiseSnippet 974.3ocsV00aaaCEkxwZXRaCXEX.6Ug9jyRWpsisaxBVWWhc1L1RpQcaQAFFJXotxlHTjBTTcyXH+m2+fMRQaKpXmrNiM8fguebt7vit7RMQJHPdtPh7Be4hL.48o9SWvUyOeNlxQiGh79R+WRSgng.SgidAPDxXPF0Ec1hLbdNDi7716GLI6EzDU97me2YXFlSfJWHzqETB7yzTppx6jm8STF6BbLXVhJ+8d1XhfetfIJzDaO+1nLL4Z7L3JrIsF9neDmOG48U986dDoW7Sh61s+ICH3AvII3jjNGE2q2fiOoyQmf6c7.ncej2GMJlpDxoJrBxQdMOSDuX5bwuwsKvqo4z2w.iQGzT8JacegfEa1hFunymSYwSVoX4HcUlToe6Y0uuv+RZLcs+Jc7yKCDUgvU.8ZTmd6UidcboWaG5sEJ44PolVJ8.+oDIMSUEwvmOweLWAxDr98jKUr4hZbZS+yE5L3pCSwWCWH0FqQzZP61OJR+y9mFFFJgYQLbtprQ4aiZeZoGRgTpQW2oRaYakJcER4LJGhRJ3DEUvilAk.JSo09g+QXP8xLhOSm+g5zdUloVszDHHLPyzbACNLSR4pVOzAyCiNvkIlzuUxqXtIyU+2VUWx5RiudcdaawWixTv0FFgJvQjbpmtHRPUH4UYeZ3Mg00qbMle4WshHWnfmqOeTvUaQBkkmQWqh4VYjlD0pZ+7zn96GFncWsGyOjv.rrTPCbVA6KpfaBq47fC1THch+MQlMuiCSUMTvsFOMpyljHqHedq5cAkLZKhbTb4dgxyowvxssdzzJgvxg+MkJ2BQIMc3UbRiJvH.2rVhE7qJ2GVoML3wOlIHXVsta2EdLeJNMiA4V0Ui3V4ad6t46s6s65tIqt2I51TMIYIWqGybBWJXLPt0vFxHuOfs3EouCjOJ58XVArNQ8nm5yy7u64YtiaI1ANNIJ3i4T0yy.9cMDFsbJk9euZ7PrBaFBtzmNuLPpnFJ3MDdu9JH6Hw.+gP90JQl9RnMlWpmTKhKXXU8w2lK4VFPqA0lYZlKp6BUKbuD71yza9gMS+9ux4CktOveBUQluc91XK7UqZ+ey2k2P9Y9iRR.hphrM8u3M260g+2PkWHJTT9rKwJI8208jWUjNU+EFDPyDNGXl9TuFlNJqcaisQYlB73Ri+R+rLXGis2xfcVEDkhIRwaI1SGl6i+3ROZNwK+1k.+KM1QcPkmXb0+T8mG7VBodo1.X2cE3Q6Jvd6Jv96JvA6Jvmrq.O9eFn4q299BkH0dbBgtbxnxwMddi3Xc2XYmK5uo4kFIK
      

      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 Why not store the event IDs along with the timestamp - Message.getTimestamp(). Then you can compare the timestamps directly instead of relying on Engine.getUptime().

        I had a quick look through your snippet but couldn't immediately see why you're getting the behaviour you are. However I made a minimal test just to demonstrate that currentTime and lastTime will have different values in a simple scenario:

        HiseSnippet 785.3ocsU00aRDDEcFnqwE0DahI95l9DnMM6hsTvFi0BTkXokTZa7slgYuKLoKyrY1YqRL8mh+G8efNytPYoenFhkGHb+3bmybmy8ROofBwwBIBW5jIQ.B+Tq9S3pQMGQXbTmVH7KsNgMFbZAgJhyw.UH8AoSUzdShHwwfOBiK9QSxX6UPoe9462iDR3TXtKD5LAiBGvFyTy81a2OyBC2m3CliXt+M2sCUvaJBEIZhUzxEEQnWPFBGRLoUvB8IR7HD9UVta0ng6f5a2vMnlmGodi50FPb872jB08HUaD3sc0ACnTD9Qs8YJgruhnfXDdk8D9S5OR7Ud1AbFKlMHDLFdn95SNy89hPeyUz3E0bDKzu2rNVLRWkdy6eEy5euvpKymcs+48wmmFvYNh7MPbgEoWwEnmWd54lid2Akv4nzJYTZUq9TIKRMOhgOOwpCWAx.h9cJOUxxEU3GXqlBcFb0FiIW.6K0FWinbMW20czeUYmRkjvPmPRrx7HtSpEMQJ0.ybDjvoJlf6H3GJTvQ7xUJ88R14xw4cNs4CYbXigf5zHk1UYcgsKYyBbJyhaAA5f9kmcHUpTxVWAaM+hEgvFQRFWUdslYUzwjxacVy4044god2DvA55kK6qKuN0qrsMm+LWZFtvc5pRN27ZEDjcutQLSOTJBCA4cF1TN4eBXYdx3AfbcmKIgIv0IpebWTwXc+Jl7BZZ1SZtDE7Nbl5nHfeexbzTcf9Wm1oEQQLxro9z4EAREyPAbK3R8Pdlny1pEDegRDoGyukhTOKH7SBIpEGPLqQlFP2CVPUZTd7XlZR90L+2lZ9Wo3pV8XJ5n6liEtCNp6TODbb5tlmY0NH.np4DbEq8+xCyhEzwhDEiOrKQIYeSq2NLYbe89YJnOcNGBMZPbAiZIy10Xa5.8AtepwuzelFzyXimFzaVPzXBUJNmlo7MaydbpGMm3oa9ss5Zrc7PoSC46yi0KWO2rnOeotEvpKKv2rr.2bYAt0xBr1xBb6kEX8+NPy+88gDkXb1XCB0sW6zUIXbaNQq.SUqneOggjUN
        

        Edit: Just commented out some lines in your snippet, and the lastTime/currentTime are different there too

        HiseSnippet 981.3ocsV01aaaCDlJwZXRaCXEX.6qB8SNIcwRY4E6ErttD6rYzkTi51hALLTPSQaSDZRAJptY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5sioZwNN1L1n.CohzxA+E7svYhYr2BmIKchlgIJ4aI1JeycueboEfShx2oD3esYbTBp7zfqNOCdJvaMOKwMU2C3QaKvudaAd71B7jsE3oaKvy1Vfse+.MuT66KzxY1iMHz0C5U1Jwyqm.CUfkUqn+F.QHJzJ
        

        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 Very strange behaviour with Engine.getUptime()?:

          @VirtualVirgin Why not store the event IDs along with the timestamp - Message.getTimeStamp(). Then you can compare the timestamps directly instead of relying on Engine.getUptime().

          I was trying to make something more generic so I could use it for getting the time difference from buttons as well (for making a tap tempo for instance).

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

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

            @d-healey

            Message.getTimestamp() always returns 0?
            Screenshot 2025-05-31 at 4.37.35 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

              @VirtualVirgin Message only exists within the on note on callback - and any inline functions called from on note on

              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 It is being called from an inline function placed on the onNoteOn.

                Using Message.getTimestamp() directly on the onNoteOn callback also returns "0":

                Screenshot 2025-05-31 at 6.22.05 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

                  @VirtualVirgin Weird, I'm getting output here. But actually the values don't make sense to me, I'm not sure what they represent.

                  9a1f626a-3bed-4248-af5d-131a0b144d02-image.png

                  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 There isn't a particular standardization spec for MIDI 1.0 timestamps that I am aware of so I was thinking the HISE timestamp would be related to an internal clock. I would expect the output to be in samples, milliseconds or maybe PPQ, but I don't see that reflected in your Console.print there.

                    @Christoph-Hart
                    How do the timestamps for MIDI messages work in HISE?

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

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

                    19

                    Online

                    1.7k

                    Users

                    11.9k

                    Topics

                    103.2k

                    Posts