MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / calculateDuration

Method calculateDuration

packages/alphatab/src/model/MasterBar.ts:376–391  ·  view source on GitHub ↗

* Calculates the time spent in this bar. (unit: midi ticks)

(respectAnacrusis: boolean = true)

Source from the content-addressed store, hash-verified

374 * Calculates the time spent in this bar. (unit: midi ticks)
375 */
376 public calculateDuration(respectAnacrusis: boolean = true): number {
377 if (this.isAnacrusis && respectAnacrusis) {
378 let duration: number = 0;
379 for (const track of this.score.tracks) {
380 for (const staff of track.staves) {
381 const barDuration: number =
382 this.index < staff.bars.length ? staff.bars[this.index].calculateDuration() : 0;
383 if (barDuration > duration) {
384 duration = barDuration;
385 }
386 }
387 }
388 return duration;
389 }
390 return this.timeSignatureNumerator * MidiUtils.valueToTicks(this.timeSignatureDenominator);
391 }
392
393 /**
394 * Adds a fermata to the masterbar.

Callers 2

insertNewMasterBarMethod · 0.95
finishMethod · 0.45

Calls 1

valueToTicksMethod · 0.80

Tested by

no test coverage detected