* Calculates the time spent in this bar. (unit: midi ticks)
(respectAnacrusis: boolean = true)
| 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. |
no test coverage detected