HISE Logo Forum
    • Categories
    • Register
    • Login

    Engine.getPlayhead() functionality

    Scheduled Pinned Locked Moved Feature Requests
    playheadtransport
    23 Posts 7 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.
    • SimonS
      Simon @Simon
      last edited by

      I hoped this was Linux only but the behavior is identical on Windows ASIO!

      SimonS 1 Reply Last reply Reply Quote 0
      • SimonS
        Simon @Simon
        last edited by

        Alright, I have no idea why that happens, can't find any mention of it in JUCE forums so I have to assume it's something HISE specific.

        I am only using the position to check if the user jumps somewhere else in the timeline. This means I can just use timeInSamples to ignore any movements smaller than 4096 samples.

        I would base it on the current buffer size, but unfortunately Engine.getBufferSize() doesn't get updated if you change the ASIO buffer size without a restart, so it can't be relied on.

        If you're looking to use the current playback time for something more musical... godspeed, let us know how it goes.

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

          @Simon said in Engine.getPlayhead() functionality:

          I am only using the position to check if the user jumps somewhere else in the timeline.

          Can't you use the transport handler for this?

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

          SimonS 1 Reply Last reply Reply Quote 0
          • SimonS
            Simon @d.healey
            last edited by

            I don't think so? Maybe I misunderstood one of the methods, but there doesn't seem to be one that fires when the playhead is moved.

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

              @Simon I think setOnGridChange but the docs are sparse so not sure.

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

              SimonS 1 Reply Last reply Reply Quote 0
              • SimonS
                Simon @d.healey
                last edited by

                @d-healey I have that commented in my script as the first thing I tried, and I can't get it to fire atm, so I'm gonna assume it's something else.

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

                  @Simon You might have to call this first setEnableGrid but I just looked at the example snippet from the docs and onBeatChanged might do the trick...

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

                  SimonS 1 Reply Last reply Reply Quote 1
                  • SimonS
                    Simon @d.healey
                    last edited by

                    Assuming the doc entry is accurate, onBeatChange won't work as I need the exact position.

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

                      @Simon The reason is that HISE splits up buffers bigger than 512 into chunks of 512 samples - above 512 there's hardly any CPU benefits but the memory consumption gets annoying (plus there are a few ugly edge cases with the audio buffer size conflicting with the streaming buffers).

                      Now the problem is that for every 2048 sample buffer that comes in, it calls the internal processing function 4 times and each time the ppq is bumped to stay consistent with the actual DAW position - that is if the playback is running. If not, then it jitters around like you analysed.

                      You can temporarily deactivate this by setting HISE_MAX_PROCESSING_BLOCKSIZE to a bigger value, but the real fix shouldn't be too hard. Please open a github issue and refer to this topic so that it doesn't get lost.

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

                        @Christoph-Hart found the culprit:

                                // if this is non-zero it means that the buffer coming
                                // from the DAW was split into chunks for processing
                                // so we need to update the playhead to reflect the
                                // "real" position for the given buffer
                                if(offsetWithinProcessBuffer != 0)
                                {
                                    newTime.timeInSamples += offsetWithinProcessBuffer;
                                    newTime.timeInSeconds += (double)offsetWithinProcessBuffer / processingSampleRate;
                                    
                                    const auto numSamplesPerQuarter = (double)TempoSyncer::getTempoInSamples(newTime.bpm, processingSampleRate, 1.0f);
                                    
                                    newTime.ppqPosition += (double)offsetWithinProcessBuffer / numSamplesPerQuarter;
                                }
                        1 Reply Last reply Reply Quote 2
                        • First post
                          Last post

                        60

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        102.1k

                        Posts