HISE Logo Forum
    • Categories
    • Register
    • Login

    Timing, Timing, Timing......

    Scheduled Pinned Locked Moved General Questions
    14 Posts 3 Posters 591 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.
    • d.healeyD
      d.healey
      last edited by

      Actually I'm wrong. Turns out the timer callback is real-time, or at least the main onTimer callback is, so I assume individual timers are also real-time.

      I definitely recommend splitting the real-time stuff from the UI stuff. This won't necessarily be straightforward, depending on how entangled they already are in your project, but I'm 90% sure it's doable. I've had a few situations where I've had to re-think my script logic in order to achieve this. Deferring the UI script by default forces me to think of alternate ways to achieve a desired effect.

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

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

        @d-healey er so are you saying I should be deferring the interface script?

        I know its slipping out of thime with that old fashioned appraoch:

        I compiled it as a VST,
        loaded in to Reaper
        ran the plug-in (seq set up to play a note on every beat a)
        recorde its output
        imported its output back into reaper
        --- and saw it didnt line up with the beat markers. it did at the start but after about 2 bars began to slip out of time...

        HISE Development for hire.
        www.channelrobot.com

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

          @d-healey OK more than willing to do that - separating it out (its all in called functions anyway) wont be a big deal....

          I can start run and stop the sequencer in the container...but I guess I cant see an obvious way to reflect the seq state in the UI

          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 can start run and stop the sequencer in the container...but I guess I cant see an obvious way to reflect the seq state in the UI

            Use the real-time script to update a global variable. In your UI script's deferred timer callback you can read this variable to update the UI.

            I'm not sure about the timer drift, I think we'll need some input from @Christoph-Hart - although making the realtime/non-realtime change might fix the issue.

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

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

              @d-healey said in Timing, Timing, Timing......:

              @Lindon

              I can start run and stop the sequencer in the container...but I guess I cant see an obvious way to reflect the seq state in the UI

              Use the real-time script to update a global variable. In your UI script's deferred timer callback you can read this variable to update the UI.

              I'm not sure about the timer drift, I think we'll need some input from @Christoph-Hart

              yeah thats the only way I could think of doing it....its all a bit sloppy tho (well subject to "visual slop" at least)... but if thats the only way...

              HISE Development for hire.
              www.channelrobot.com

              1 Reply Last reply Reply Quote 0
              • Christoph HartC
                Christoph Hart
                last edited by

                If you want precise musical timing you need to use the onTimer callback, the other ones will run in the UI thread.

                If you want 100% sample accurate timing, take the timestamp of the timer callback into account (Message.getTimestamp() works there also)...

                d.healeyD LindonL 2 Replies Last reply Reply Quote 0
                • d.healeyD
                  d.healey @Christoph Hart
                  last edited by

                  @Christoph-Hart said in Timing, Timing, Timing......:

                  If you want precise musical timing you need to use the onTimer callback, the other ones will run in the UI thread.

                  So I was half right :)

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

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

                    @Christoph-Hart said in Timing, Timing, Timing......:

                    If you want precise musical timing you need to use the onTimer callback, the other ones will run in the UI thread.

                    If you want 100% sample accurate timing, take the timestamp of the timer callback into account (Message.getTimestamp() works there also)...

                    OK great - I understand the first part of what you said, but not the second... how would getting the current time(stamp) help me ?

                    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 assume you can put Message.getTimestamp() inside the timer callback to get an accurate timestamp. You can then use Synth.addNote() instead of playNote to generate a MIDI note with that timestamp.

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

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

                        @d-healey said in Timing, Timing, Timing......:

                        @Lindon I assume you can put Message.getTimestamp() inside the timer callback to get an accurate timestamp. You can then use Synth.addNote() instead of playNote to generate a MIDI note with that timestamp.

                        OK well Im still a bit lost in what you are saying about Synth.addNote:

                        So I'm in my timer call back....

                        I check Message.getTimestamp()

                        -- so now I know what time it is (and if I'm late for the party (because - lets say - I worked out the required timestamp value in the last step)

                        -- let assume I'm late - nothing I can do about it now (cant go back in time) gotta just play the note I need to play...

                        -- at this point I can tell the timer to "hurry up to the next step" with startTimer(mySeqStepLength minus how_late_I_am)

                        How does Synth.AddNote() help me here?

                        --- incidentally I moved the seq to the Engine.getTimer (told you it'd be quick) and that sounds like its fixed it...so I'm really asking these questions in an attempt to have a better understanding...

                        HISE Development for hire.
                        www.channelrobot.com

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

                          I think Christoph's idea with using the timestamp is that it will prevent notes triggering early, but this won't help if the notes are triggering late. Yeah moving the GUI stuff out should make a big difference :)

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

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

                            @d-healey said in Timing, Timing, Timing......:

                            I think Christoph's idea with using the timestamp is that it will prevent notes triggering early, but this won't help if the notes are triggering late. Yeah moving the GUI stuff out should make a big difference :)

                            Oh yeah - of course. Thanks for your help (and you too Christoph...)

                            HISE Development for hire.
                            www.channelrobot.com

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

                            45

                            Online

                            1.7k

                            Users

                            11.7k

                            Topics

                            101.8k

                            Posts