| 354 | } |
| 355 | |
| 356 | public addMasterBar(bar: MasterBar): void { |
| 357 | bar.score = this; |
| 358 | bar.index = this.masterBars.length; |
| 359 | if (this.masterBars.length !== 0) { |
| 360 | bar.previousMasterBar = this.masterBars[this.masterBars.length - 1]; |
| 361 | bar.previousMasterBar.nextMasterBar = bar; |
| 362 | // NOTE: this will not work on anacrusis. Correct anacrusis durations are only working |
| 363 | // when there are beats with playback positions already computed which requires full finish |
| 364 | // chicken-egg problem here. temporarily forcing anacrusis length here to 0, |
| 365 | // .finish() will correct these times |
| 366 | bar.start = |
| 367 | bar.previousMasterBar.start + |
| 368 | (bar.previousMasterBar.isAnacrusis ? 0 : bar.previousMasterBar.calculateDuration()); |
| 369 | } |
| 370 | |
| 371 | this._addMasterBarToRepeatGroups(bar); |
| 372 | |
| 373 | this.masterBars.push(bar); |
| 374 | } |
| 375 | |
| 376 | /** |
| 377 | * Adds the given bar correctly into the current repeat group setup. |