Timemap: Find measure duration #3732
Unanswered
infojunkie
asked this question in
Q&A
Replies: 1 comment
-
For what it's worth, I ended up using the largest let tstamp = 0;
this._vrv.renderToTimemap({ includeMeasures: true, includeRests: true }).forEach((event) => {
// If starting a measure, add it to the timemap.
if ('measureOn' in event) {
const i = this._timemap.length;
if (i > 0) {
this._timemap[i - 1].duration =
event.tstamp - this._timemap[i - 1].timestamp;
}
this._timemap.push({
measure: i,
timestamp: event.tstamp,
duration: 0,
});
}
// Find the duration of the last measure.
// Calculate the max tstamp and compute the last measure duration based on that.
tstamp = Math.max(tstamp, event.tstamp);
});
this._timemap[this._timemap.length - 1].duration =
tstamp - this._timemap[this._timemap.length - 1].timestamp; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm using the timemap feature to map measures to their timestamps and enable audio playback of the score. My rendering of the cursor would benefit from knowing the measure duration. Is there a way to compute that, preferably in milliseconds? I am aware that a measure ends when the next one starts, but how to compute the duration of the last measure?
Beta Was this translation helpful? Give feedback.
All reactions