Pass down current time info in BlockContext#78
Pass down current time info in BlockContext#78nick-thompson merged 3 commits intoelemaudio:developfrom
Conversation
…via the top level process() call
nick-thompson
left a comment
There was a problem hiding this comment.
Excellent thank you! One thought inline
wasm/Main.cpp
Outdated
| } | ||
| } | ||
|
|
||
| auto const beatTime = sampleTimeToBeatTime(sampleTime, bpm, sampleRate); |
There was a problem hiding this comment.
My only thought is here: should we hold separate state for beatTime and sampleTime? My thought is that if bpm is strictly constant, then this mapping from sampleTime<>beatTime holds as expected. But if the tempo ever changes, this calculation will cause a (potentially large) jump in beat time that isn't quite accurate– like a tempo change at the start of bar 5 should still report the beatTime as start of bar 5 right?
So maybe at the bottom of this process call we have like
sampleTime += numSamples;
beatTime += sampleTimeToBeatTime(numSamples, bpm, sampleRate);
Then the question becomes, what do we do in setCurrentTime in the ms or beattime case.... I guess at that point its' probably fine to just snap both values according to the current bpm.
There was a problem hiding this comment.
@nick-thompson yes you're right! I just pushed this change.
For reference, Ableton Live maintains beat position, but snaps the sample position according to the new BPM when tempo changes. I think it seems intuitive to use that behavior here as well.
There was a problem hiding this comment.
Perfect! Thank you, let's roll
…BPM changes (mimics most DAW behavior)
This adds a new
CurrentTimestruct containing the time in samples, beats, bpm, and time signature. The change is purely additive and does not update existing nodes leverage this time data yet. The wasm implementation has been updated to expose setters for bpm, time in beats, and time signature. It updates the beat time in each process() call.Native clients could leverage this to pass down timing information from a host DAW/application to drive the graph.