HISE Logo Forum
    • Categories
    • Register
    • Login

    Still trying to make sense of Tempo, Sync, and MIDI loop issue

    Scheduled Pinned Locked Moved Bug Reports
    19 Posts 2 Posters 1.1k 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.
    • ustkU
      ustk
      last edited by ustk

      @Christoph-Hart TH.setOnBeatChange() always fires at the DAW tempo no matter when you setHostBpm() at different tempo.

      The TH syncMode doesn't seem to affect this

      Can't help pressing F5 in the forum...

      1 Reply Last reply Reply Quote 0
      • ustkU
        ustk
        last edited by ustk

        @Christoph-Hart I prepared a snippet so we can test a few things in order to get the MIDI issues (or my bad implementation) sorted once for all.

        HiseSnippet 4007.3oc6as7aibjdu4LSOqIsmYsw5f.jSUzgMTqF2hujFN1vq3qlhT7o3C8xwwoX2EIaw9AU2MEEm.mXDDffbIHmx48XtFfbH2VCjK4+fbZMLRNkSw+Gj7UU2jraJRFNZ7L6jMRXNv9qpup988n9dTcO0MMjHVVFlbAB1ZxPBWfOfu4Dc69Y6iUz4JliKvSoDjpXHSZQrr4xLYH1xhHyEHvCOjNm.AeDG6ue3fLXUrtDYNINtSLTjHkUzTrmSsdpRJpp4wvJpn4Y1IRUTxPOqgpwH.OOjOB2Prz.bORULcZOfmKviEkUrMLaZisIVbAdTFC4IM6aLV2Y9mnXozQkPeHJWSXgbHm2PUlhXJUtr8UTkqOUts3fEs9bsvCczBeLeEEYkYzmqM9P1.n4b3UeD3A9g2C8AundgWDOvaIP5AdfzOYpggAIU7DhoqgoRwbEQNTh5CHYGYZRzsaRtZDwmA4GNvcnVlfp0K8xFFCE0w.7j8Rlt5cfo1bHw+.Ad3FKqQWqrxQEq7JpDpbGX5CvroxHXyygswbA9a4iFIlfdq8KkLaiSMJIHT4XwKtLsffvYBBoEpKnoznYqhwt.nHbXZgKExIHbdiLRB4xzQ3xRoULZ2umP2CuTna2qSW.VfBWb9E2Pfwk0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UUgqsf3G9+aJHd8IXfp+PuS2VyuOOTEZLDyTh9sisrgwH52ZbELj9hderPsOMgx7kHz2klNQkVqQfGPqJv44HSegLMI5xrG9ug+bGLJ84.tCFc5faTGLV5qpClu427y+WdmoClC1jNXNO0R5f4iSsjNXfFN13NX99i+m+t66f4cjNXh8icGLIey0ASx66f49NX9sQGLeymG5+5N1ACW1E5f4e8uZS5f4e5u69NXtuCl66f49NXtuCl66f4GuNXdarGZXISiuRxoJJZxl2iQAjac1+ufCxWg9LZ12lFOeDgHbZPkxekjD0e8SfhgVNOwtC7D+NvSh6.O6cG3Y+6.OO+NvSx0xCsIkzirMzb74AB0Ec9OWdfY+GeOvC49erQklTK
        

        Here are the questions that @gorangrooves and I need to resolve or understand to conduct the current project:

        • MIDI Player doesn't loop at the endOfTrack event, but after the last note off instead resulting in a truncated sequence.
          This is the case wether you play from startInternalClock or click play in the MP (when not synced to the master clock of course)

        • setOnBeatChange doesn't fire at the first beat
          -> Is this intended?

        • setOnBeatChange doesn't follow a custom tempo (setHostBpm) but only the external one, hence the HACK TEMPO solution.
          -> Is it good or bad?

        • When Internal sync is selected, the playing speed still reacts to DAW tempo change.
          Vice versa with External, the speed reacts to custom tempo.
          -> Is this intended?
          -> Are the sync modes only related to play/stop and not the tempo?

        • In the real world, I am using setOnBeatChange to play the next sequence (number of bars in the seq times a counter+isNewBar)
          -> Is this a good approach?

        EDIT: fix tempo hack in snippet

        Can't help pressing F5 in the forum...

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

          MIDI Player doesn't loop at the endOfTrack event, but after the last note off instead resulting in a truncated sequence.

          I'm such an idiot it isn't even funny anymore. The end of track event was in there all along, I just deleted it :) It's fixed now ...

          setOnBeatChange doesn't fire at the first beat

          Yup, use the start / stop callback for that (or if you don't want to duplicate the logic, just call your onBeatFunction in the onStart callback manually).

          When Internal sync is selected, the playing speed still reacts to DAW tempo change.

          Yeah that was kind of messy (it checks whether you've called Engine.setHostBpm()). I've refactored some code relating to this and added a new function to the TransportHandler that will link the bpm to which mode is currently active. So if this is enabled, it will use the internal BPM if the sync mode is Internal and the host bpm if the sync mode is external (if you set the internal bpm to -1 it will always use the host bpm and if the host bpm can't be detected it will use the internal bpm).

          In the real world, I am using setOnBeatChange to play the next sequence (number of bars in the seq times a counter+isNewBar)

          No, the accuracy of the beat change callback might not be enough. Use the onGridChange callback, this will get you a sample accurate position with a timestamp within the current buffer.

          ustkU 1 Reply Last reply Reply Quote 4
          • ustkU
            ustk @Christoph Hart
            last edited by

            @Christoph-Hart said in Still trying to make sense of Tempo, Sync, and MIDI loop issue:

            I'm such an idiot it isn't even funny anymore. The end of track event was in there all along, I just deleted it :) It's fixed now ...

            Amazing! Thanks!

            Yup, use the start / stop callback for that (or if you don't want to duplicate the logic, just call your onBeatFunction in the onStart callback manually).

            Well, the idiot is me...

            Yeah that was kind of messy (it checks whether you've called Engine.setHostBpm()). I've refactored some code relating to this and added a new function to the TransportHandler that will link the bpm to which mode is currently active. So if this is enabled, it will use the internal BPM if the sync mode is Internal and the host bpm if the sync mode is external (if you set the internal bpm to -1 it will always use the host bpm and if the host bpm can't be detected it will use the internal bpm).

            Nice! I'm checking this ASAP
            But this confirms how setHostBpm term is confusing to me, since it is not necessarily the host that it sets for all values except -1

            No, the accuracy of the beat change callback might not be enough. Use the onGridChange callback, this will get you a sample accurate position with a timestamp within the current buffer.

            Oh of course how couldn't I see this! Math.pow(idiot, greg)...

            Can't help pressing F5 in the forum...

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

              But this confirms how setHostBpm term is confusing to me, since it is not necessarily the host that it sets for all values except -1

              Yeah, it was super convoluted and prone to weird edge cases, but I think I've boiled it down to a very simple logic:

              if(linkBpmToSyncMode) // this is the new function TH.setLinkBpmToSyncMode()
              {
                  if(syncMode == Internal || syncMode == PreferInternal)
                      return internalBPM;
                  else
                      return hostBpm;
              }
              else
              {
                  if(internalBpm != -1)
                      return internalBpm;
                  else
                      return hostBpm;
              }
              
              ustkU 1 Reply Last reply Reply Quote 2
              • ustkU
                ustk @Christoph Hart
                last edited by ustk

                @Christoph-Hart Hmmm... It seems the endOfTrack is still not taken into account for some reasons 🤔

                The NumBars meta should be 1.0 in the above 4/4 sequence example, but is 0.79270833333 in reality, which again seems to correspond to the last noteOff

                This is the midi file in question:
                Rock Groove 01A Bsc Qtrs cl hats.mid.zip

                Could the endOfTrack be at the same timestamp as the last noteOff?

                Can't help pressing F5 in the forum...

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

                  @ustk yes. I noticed that when you export a clip from ableton it will also set the end of track to the last note off.

                  ustkU 1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @Christoph Hart
                    last edited by

                    @Christoph-Hart hmm that's annoying... Someone will not be dancing when learning this 😬

                    Can't help pressing F5 in the forum...

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

                      But I downloaded a random MIDI pack (took me a few minutes to find something that didn‘t want my email address in exchange) and with those it worked so the end of track is definitely detected now).

                      ustkU 2 Replies Last reply Reply Quote 1
                      • ustkU
                        ustk @Christoph Hart
                        last edited by ustk

                        @Christoph-Hart Well apparently it's the same thing from Pro Tools... I have to try another DAW...

                        Can't help pressing F5 in the forum...

                        1 Reply Last reply Reply Quote 0
                        • ustkU
                          ustk @Christoph Hart
                          last edited by ustk

                          @Christoph-Hart Well that's a bit too weird... I tried exporting from Ableton, Cubase, Pro Tools and Reaper, same thing... Knowing that I selected "Export Locator Range" in Cubase and "Time Selection Only" in Reaper

                          Same issue from 4 major DAWs isn't a coincidence... I wonder which DAW has been used for the library you downloaded so I could test it... Or perhaps there's a ghost note that has the noteOff right at the end of the bar? This is the only trick that I found to make it work...

                          The MIDI Viewer still considers the last noteOff...
                          Could you check the last noteOff timestamp in your MIDI files to be sure it is BEFORE the end of the bar? This would be the only indicator that tells if it's the endOfTrack that is then read, or a ghost note...
                          Or the endOfTrack timestamp in this file -> Cubase 4-4 1bar noGhostNote.midi.zip

                          When I re-import back into a DAW, I obtain the full bar length, meaning the endOfTrack is where it should be I think.
                          So I think Hise still doesn't seem to read it... Or is there another indicator for the bar length?

                          (before you ask, yes I updated Hise because I can see the new setLinkBpmToSyncMode method :) )

                          Screenshot 2023-06-03 at 12.23.55.png

                          Screenshot 2023-06-03 at 12.27.04.png

                          Can't help pressing F5 in the forum...

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

                            @ustk I just checked the file and it has an end of track marker, however the event has a timestamp of zero (so it can‘t deduce where the actual event is).

                            ustkU 2 Replies Last reply Reply Quote 0
                            • ustkU
                              ustk @Christoph Hart
                              last edited by ustk

                              @Christoph-Hart Interesting... And what about the one from the library you downloaded yourself? It would be weird that all files exported from 4 different DAWs have the same issue.
                              Could you please send to me the one you used? I'm lost with all these weirdnesses...

                              Can't help pressing F5 in the forum...

                              1 Reply Last reply Reply Quote 0
                              • ustkU
                                ustk @Christoph Hart
                                last edited by ustk

                                @Christoph-Hart Is this normal that I have to set the tempoFactor of setEnableGrid to 0.5 in order to get the gridChange to be in sync?
                                setting to 1.0 doesn't simply double the speed but make it to trigger at a weird tempo...

                                Can't help pressing F5 in the forum...

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

                                  @ustk the tempofactor is the enum from 1-18 (check the values by setting a slider mode to tempo and then read out the integers). 1 is probably 1/1D or something which some people without a feeling for polyrhythms might call „weird“ :)

                                  ustkU 2 Replies Last reply Reply Quote 1
                                  • ustkU
                                    ustk @Christoph Hart
                                    last edited by

                                    @Christoph-Hart Oh that makes sense in this case!

                                    some people without a feeling for polyrhythms might call „weird“ :)

                                    Then I don't ! 🤘

                                    Can't help pressing F5 in the forum...

                                    1 Reply Last reply Reply Quote 1
                                    • ustkU
                                      ustk @Christoph Hart
                                      last edited by ustk

                                      @Christoph-Hart After testing this in all ways I could imagine, this endOfTrack issue still doesn't make sense to me.
                                      Effectively the EOT timestamp is wrong in the library I am using.
                                      But this library is playing nicely in other players, meaning they are not taking the EOT into account (or they fall to another calculation method when the EOT is wrong)

                                      Even if somehow we fix the EOT timestamps of the library, since the exports from major DAWs also have this issue, what will happen when users make their own midi files exports from any DAW? They won't play in our player despite they will work in other players...

                                      All of this tells me that it is Hise that should take care of the sequence length, isn't it?

                                      Another consequence is that the MidiView or rectangle list also reflects this wrong sequence length

                                      Can't help pressing F5 in the forum...

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

                                        @ustk I've just pushed a commit that will round up the value if it can't be detected properly (which I'm guessing is everybody else doing since there is no other way to retrieve that information).

                                        ustkU 1 Reply Last reply Reply Quote 3
                                        • ustkU
                                          ustk @Christoph Hart
                                          last edited by ustk

                                          @Christoph-Hart Great! I will test this asap!
                                          I agree with the principle, and that's what I am doing in the midi browser to display the right sequence length.
                                          I just couldn't do the player side of it, so thanks!

                                          Can't help pressing F5 in the forum...

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

                                          47

                                          Online

                                          1.7k

                                          Users

                                          11.7k

                                          Topics

                                          101.9k

                                          Posts