Dplug icon indicating copy to clipboard operation
Dplug copied to clipboard

Add musical time to TimeInfo, support tempo change

Open debrisapron opened this issue 3 years ago • 3 comments

It would be good to have a parameter on TimeInfo which gives access to the DAW's elapsed musical time. I'm thinking something like JUCE's AudioPlayHead::PositionInfo.getPpqPosition().

At the moment it is possible (albeit rather fiddly) to reconstruct the musical position from the current sample rate, TimeInfo.tempo and TimeInfo.timeInSamples, however there are a couple of problems with this approach:

  1. If there is any tempo automation before the current playhead position, there is no way to figure out the current musical position as the tempo change will have scrambled the relationship between samples & beats/bars. You can still calculate musical time relative to when the user hit play, but not the absolute song position of the playhead.
  2. On Reaper at least, there is vari-speed control for the whole project which does some weird thing where it misreports the sample rate to make everything run slower/faster. This is a great feature but it breaks my plugin & a couple of others I've used. Having a musical time parameter would fix this.
  3. It makes the logic for any kind of sequencer much cleaner, particularly if the sequencer is expected to follow tempo.

I believe this is a cross-platform feature as the JUCE docs don't mention any caveats about what hosts it works in. I'd be willing to take a look at raising a PR if you don't have time for this, but I'm quite a n00b with D 😅

BTW absolutely loving Dplug so far, thank you for giving the people a better way of writing plugins!

debrisapron avatar Sep 06 '22 22:09 debrisapron

thank you and welcome! Good idea, there is also the issue of TimeInfo.timeInSamples not supporting negative values. (EDIT: it does) Well if you can get that PpqPosition it would for sure be very interesting. I certainly have plugin that suffer from that. However, as always in Dplug, it shall be done for every plugin format :)

p0nce avatar Sep 07 '22 09:09 p0nce

I tell you what, I'll research what the different plugin formats provide in terms of transport information and see if I can draft a PR, even if it's not good enough maybe it will be a useful implementation reference.

debrisapron avatar Sep 07 '22 17:09 debrisapron

Apparently REAPER doesn't send negative ppq, have a plan to deal with that

p0nce avatar Nov 02 '22 12:11 p0nce