| 126 | } |
| 127 | |
| 128 | private _chain(beat: Beat, sharedDataBag: Map<string, unknown> | null = null): void { |
| 129 | if (!this.bar) { |
| 130 | return; |
| 131 | } |
| 132 | if (beat.index < this.beats.length - 1) { |
| 133 | beat.nextBeat = this.beats[beat.index + 1]; |
| 134 | beat.nextBeat.previousBeat = beat; |
| 135 | } else if (beat.isLastOfVoice && beat.voice.bar.nextBar) { |
| 136 | const nextVoice: Voice = this.bar.nextBar!.voices[this.index]; |
| 137 | if (nextVoice.beats.length > 0) { |
| 138 | beat.nextBeat = nextVoice.beats[0]; |
| 139 | beat.nextBeat.previousBeat = beat; |
| 140 | } else { |
| 141 | beat.nextBeat!.previousBeat = beat; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | beat.chain(sharedDataBag); |
| 146 | } |
| 147 | |
| 148 | public addGraceBeat(beat: Beat): void { |
| 149 | if (this.beats.length === 0) { |