@coderline/alphatab 1.3.0-alpha.874 → 1.3.0-alpha.877

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5613,6 +5613,24 @@ declare class Environment {
5613
5613
  private static detectWebPlatform;
5614
5614
  }
5615
5615
 
5616
+ /**
5617
+ * Represents a beat and when it is actually played according to the generated audio.
5618
+ */
5619
+ declare class BeatTickLookupItem {
5620
+ /**
5621
+ * Gets the beat represented by this item.
5622
+ */
5623
+ readonly beat: Beat;
5624
+ /**
5625
+ * Gets the playback start of the beat according to the generated audio.
5626
+ */
5627
+ readonly playbackStart: number;
5628
+ /**
5629
+ * Gets the playback start of the beat duration according to the generated audio.
5630
+ */
5631
+ readonly playbackDuration: number;
5632
+ constructor(beat: Beat, playbackStart: number, playbackDuration: number);
5633
+ }
5616
5634
  /**
5617
5635
  * Represents the time period, for which one or multiple {@link Beat}s are played
5618
5636
  */
@@ -5631,7 +5649,7 @@ declare class BeatTickLookup {
5631
5649
  * the beat of this lookup starts playing. This might not mean
5632
5650
  * the beats start at this position.
5633
5651
  */
5634
- highlightedBeats: Beat[];
5652
+ highlightedBeats: BeatTickLookupItem[];
5635
5653
  /**
5636
5654
  * Gets the next BeatTickLookup which comes after this one and is in the same
5637
5655
  * MasterBarTickLookup.
@@ -5651,7 +5669,7 @@ declare class BeatTickLookup {
5651
5669
  * Marks the given beat as highlighed as part of this lookup.
5652
5670
  * @param beat The beat to add.
5653
5671
  */
5654
- highlightBeat(beat: Beat): void;
5672
+ highlightBeat(beat: Beat, playbackStart: number, playbackDuration: number): void;
5655
5673
  /**
5656
5674
  * Looks for the first visible beat which starts at this lookup so it can be used for cursor placement.
5657
5675
  * @param visibleTracks The visible tracks.
@@ -5700,6 +5718,10 @@ declare class MasterBarTickLookup {
5700
5718
  * Gets or sets the {@link MasterBarTickLookup} of the next masterbar in the {@link Score}
5701
5719
  */
5702
5720
  nextMasterBar: MasterBarTickLookup | null;
5721
+ /**
5722
+ * Gets or sets the {@link MasterBarTickLookup} of the previous masterbar in the {@link Score}
5723
+ */
5724
+ previousMasterBar: MasterBarTickLookup | null;
5703
5725
  /**
5704
5726
  * Adds a new beat to this masterbar following the slicing logic required by the MidiTickLookup.
5705
5727
  * @returns The first item of the chain which was affected.
package/dist/alphaTab.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
- * alphaTab v1.3.0-alpha.874 (develop, build 874)
2
+ * alphaTab v1.3.0-alpha.877 (develop, build 877)
3
3
  *
4
- * Copyright © 2023, Daniel Kuschny and Contributors, All rights reserved.
4
+ * Copyright © 2024, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
6
6
  * This Source Code Form is subject to the terms of the Mozilla Public
7
7
  * License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -16809,6 +16809,16 @@
16809
16809
  }
16810
16810
  }
16811
16811
 
16812
+ /**
16813
+ * Represents a beat and when it is actually played according to the generated audio.
16814
+ */
16815
+ class BeatTickLookupItem {
16816
+ constructor(beat, playbackStart, playbackDuration) {
16817
+ this.beat = beat;
16818
+ this.playbackStart = playbackStart;
16819
+ this.playbackDuration = playbackDuration;
16820
+ }
16821
+ }
16812
16822
  /**
16813
16823
  * Represents the time period, for which one or multiple {@link Beat}s are played
16814
16824
  */
@@ -16844,13 +16854,13 @@
16844
16854
  * Marks the given beat as highlighed as part of this lookup.
16845
16855
  * @param beat The beat to add.
16846
16856
  */
16847
- highlightBeat(beat) {
16857
+ highlightBeat(beat, playbackStart, playbackDuration) {
16848
16858
  if (beat.isEmpty) {
16849
16859
  return;
16850
16860
  }
16851
16861
  if (!this._highlightedBeats.has(beat.id)) {
16852
16862
  this._highlightedBeats.set(beat.id, true);
16853
- this.highlightedBeats.push(beat);
16863
+ this.highlightedBeats.push(new BeatTickLookupItem(beat, playbackStart, playbackDuration));
16854
16864
  }
16855
16865
  }
16856
16866
  /**
@@ -16860,8 +16870,8 @@
16860
16870
  */
16861
16871
  getVisibleBeatAtStart(visibleTracks) {
16862
16872
  for (const b of this.highlightedBeats) {
16863
- if (b.playbackStart == this.start && visibleTracks.has(b.voice.bar.staff.track.index)) {
16864
- return b;
16873
+ if (b.playbackStart == this.start && visibleTracks.has(b.beat.voice.bar.staff.track.index)) {
16874
+ return b.beat;
16865
16875
  }
16866
16876
  }
16867
16877
  return null;
@@ -16891,6 +16901,10 @@
16891
16901
  * Gets or sets the {@link MasterBarTickLookup} of the next masterbar in the {@link Score}
16892
16902
  */
16893
16903
  this.nextMasterBar = null;
16904
+ /**
16905
+ * Gets or sets the {@link MasterBarTickLookup} of the previous masterbar in the {@link Score}
16906
+ */
16907
+ this.previousMasterBar = null;
16894
16908
  }
16895
16909
  /**
16896
16910
  * Inserts `newNextBeat` after `currentBeat` in the linked list of items and updates.
@@ -17038,7 +17052,7 @@
17038
17052
  // Variant A
17039
17053
  if (this.firstBeat == null) {
17040
17054
  const n1 = new BeatTickLookup(start, end);
17041
- n1.highlightBeat(beat);
17055
+ n1.highlightBeat(beat, start, duration);
17042
17056
  this.insertAfter(this.firstBeat, n1);
17043
17057
  }
17044
17058
  // Variant B
@@ -17046,7 +17060,7 @@
17046
17060
  else if (start >= this.lastBeat.end) {
17047
17061
  // using the end here allows merge of B & C
17048
17062
  const n1 = new BeatTickLookup(this.lastBeat.end, end);
17049
- n1.highlightBeat(beat);
17063
+ n1.highlightBeat(beat, start, duration);
17050
17064
  this.insertAfter(this.lastBeat, n1);
17051
17065
  }
17052
17066
  else {
@@ -17077,34 +17091,34 @@
17077
17091
  if (end == l1.start) {
17078
17092
  // using firstBeat.start here allows merge of D & E
17079
17093
  const n1 = new BeatTickLookup(start, l1.start);
17080
- n1.highlightBeat(beat);
17094
+ n1.highlightBeat(beat, start, duration);
17081
17095
  this.insertBefore(this.firstBeat, n1);
17082
17096
  }
17083
17097
  // Variant F
17084
17098
  else if (end < l1.end) {
17085
17099
  const n1 = new BeatTickLookup(start, l1.start);
17086
- n1.highlightBeat(beat);
17100
+ n1.highlightBeat(beat, start, duration);
17087
17101
  this.insertBefore(l1, n1);
17088
17102
  const n2 = new BeatTickLookup(l1.start, end);
17089
17103
  for (const b of l1.highlightedBeats) {
17090
- n2.highlightBeat(b);
17104
+ n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17091
17105
  }
17092
- n2.highlightBeat(beat);
17106
+ n2.highlightBeat(beat, start, duration);
17093
17107
  this.insertBefore(l1, n2);
17094
17108
  l1.start = end;
17095
17109
  }
17096
17110
  // Variant G
17097
17111
  else if (end == l1.end) {
17098
17112
  const n1 = new BeatTickLookup(start, l1.start);
17099
- n1.highlightBeat(beat);
17100
- l1.highlightBeat(beat);
17113
+ n1.highlightBeat(beat, start, duration);
17114
+ l1.highlightBeat(beat, start, duration);
17101
17115
  this.insertBefore(l1, n1);
17102
17116
  }
17103
17117
  // Variant H
17104
17118
  else /* end > this.firstBeat.end */ {
17105
17119
  const n1 = new BeatTickLookup(start, l1.start);
17106
- n1.highlightBeat(beat);
17107
- l1.highlightBeat(beat);
17120
+ n1.highlightBeat(beat, start, duration);
17121
+ l1.highlightBeat(beat, start, duration);
17108
17122
  this.insertBefore(l1, n1);
17109
17123
  this.addBeat(beat, l1.end, end - l1.end);
17110
17124
  }
@@ -17114,10 +17128,10 @@
17114
17128
  if (end == l1.end) {
17115
17129
  const n1 = new BeatTickLookup(l1.start, start);
17116
17130
  for (const b of l1.highlightedBeats) {
17117
- n1.highlightBeat(b);
17131
+ n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17118
17132
  }
17119
17133
  l1.start = start;
17120
- l1.highlightBeat(beat);
17134
+ l1.highlightBeat(beat, start, duration);
17121
17135
  this.insertBefore(l1, n1);
17122
17136
  }
17123
17137
  // Variant J
@@ -17127,20 +17141,20 @@
17127
17141
  const n2 = new BeatTickLookup(start, end);
17128
17142
  this.insertBefore(l1, n2);
17129
17143
  for (const b of l1.highlightedBeats) {
17130
- n1.highlightBeat(b);
17131
- n2.highlightBeat(b);
17144
+ n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17145
+ n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17132
17146
  }
17133
- n2.highlightBeat(beat);
17147
+ n2.highlightBeat(beat, start, duration);
17134
17148
  l1.start = end;
17135
17149
  }
17136
17150
  // Variant K
17137
17151
  else /* end > l1.end */ {
17138
17152
  const n1 = new BeatTickLookup(l1.start, start);
17139
17153
  for (const b of l1.highlightedBeats) {
17140
- n1.highlightBeat(b);
17154
+ n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17141
17155
  }
17142
17156
  l1.start = start;
17143
- l1.highlightBeat(beat);
17157
+ l1.highlightBeat(beat, start, duration);
17144
17158
  this.insertBefore(l1, n1);
17145
17159
  this.addBeat(beat, l1.end, end - l1.end);
17146
17160
  }
@@ -17148,21 +17162,21 @@
17148
17162
  else /* start == l1.start */ {
17149
17163
  // Variant L
17150
17164
  if (end === l1.end) {
17151
- l1.highlightBeat(beat);
17165
+ l1.highlightBeat(beat, start, end);
17152
17166
  }
17153
17167
  // Variant M
17154
17168
  else if (end < l1.end) {
17155
17169
  const n1 = new BeatTickLookup(l1.start, end);
17156
17170
  for (const b of l1.highlightedBeats) {
17157
- n1.highlightBeat(b);
17171
+ n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17158
17172
  }
17159
- n1.highlightBeat(beat);
17173
+ n1.highlightBeat(beat, start, duration);
17160
17174
  l1.start = end;
17161
17175
  this.insertBefore(l1, n1);
17162
17176
  }
17163
17177
  // variant N
17164
17178
  else /* end > l1.end */ {
17165
- l1.highlightBeat(beat);
17179
+ l1.highlightBeat(beat, start, duration);
17166
17180
  this.addBeat(beat, l1.end, end - l1.end);
17167
17181
  }
17168
17182
  }
@@ -17288,6 +17302,11 @@
17288
17302
  current.tickDuration = current.nextBeat.start - current.start;
17289
17303
  current.duration = MidiUtils.ticksToMillis(current.tickDuration, current.masterBar.tempo);
17290
17304
  }
17305
+ // no next beat, animate to the end of the bar (could be an incomplete bar)
17306
+ if (!current.nextBeat) {
17307
+ current.tickDuration = current.masterBar.end - current.start;
17308
+ current.duration = MidiUtils.ticksToMillis(current.tickDuration, current.masterBar.tempo);
17309
+ }
17291
17310
  }
17292
17311
  findBeatSlow(trackLookup, currentBeatHint, tick, isNextSearch) {
17293
17312
  // get all beats within the masterbar
@@ -17335,7 +17354,7 @@
17335
17354
  * @returns
17336
17355
  */
17337
17356
  findBeatInMasterBar(masterBar, currentStartLookup, tick, visibleTracks, fillNext, isNextSeach) {
17338
- var _a;
17357
+ var _a, _b, _c;
17339
17358
  if (!currentStartLookup) {
17340
17359
  return null;
17341
17360
  }
@@ -17350,23 +17369,39 @@
17350
17369
  // in this case scan further to the next lookup which has any visible beat
17351
17370
  if (!startBeat) {
17352
17371
  if (isNextSeach) {
17353
- while (currentStartLookup != null) {
17354
- startBeat = currentStartLookup.getVisibleBeatAtStart(visibleTracks);
17355
- if (startBeat) {
17356
- startBeatLookup = currentStartLookup;
17357
- break;
17372
+ let currentMasterBar = masterBar;
17373
+ while (currentMasterBar != null && startBeat == null) {
17374
+ while (currentStartLookup != null) {
17375
+ startBeat = currentStartLookup.getVisibleBeatAtStart(visibleTracks);
17376
+ if (startBeat) {
17377
+ startBeatLookup = currentStartLookup;
17378
+ masterBar = currentMasterBar;
17379
+ break;
17380
+ }
17381
+ currentStartLookup = currentStartLookup.nextBeat;
17382
+ }
17383
+ if (!startBeat || !startBeatLookup) {
17384
+ currentMasterBar = currentMasterBar.nextMasterBar;
17385
+ currentStartLookup = (_a = currentMasterBar === null || currentMasterBar === void 0 ? void 0 : currentMasterBar.firstBeat) !== null && _a !== void 0 ? _a : null;
17358
17386
  }
17359
- currentStartLookup = currentStartLookup.nextBeat;
17360
17387
  }
17361
17388
  }
17362
17389
  else {
17363
- while (currentStartLookup != null) {
17364
- startBeat = currentStartLookup.getVisibleBeatAtStart(visibleTracks);
17365
- if (startBeat) {
17366
- startBeatLookup = currentStartLookup;
17367
- break;
17390
+ let currentMasterBar = masterBar;
17391
+ while (currentMasterBar != null && startBeat == null) {
17392
+ while (currentStartLookup != null) {
17393
+ startBeat = currentStartLookup.getVisibleBeatAtStart(visibleTracks);
17394
+ if (startBeat) {
17395
+ startBeatLookup = currentStartLookup;
17396
+ masterBar = currentMasterBar;
17397
+ break;
17398
+ }
17399
+ currentStartLookup = currentStartLookup.previousBeat;
17400
+ }
17401
+ if (!startBeat || !startBeatLookup) {
17402
+ currentMasterBar = currentMasterBar.previousMasterBar;
17403
+ currentStartLookup = (_b = currentMasterBar === null || currentMasterBar === void 0 ? void 0 : currentMasterBar.firstBeat) !== null && _b !== void 0 ? _b : null;
17368
17404
  }
17369
- currentStartLookup = currentStartLookup.previousBeat;
17370
17405
  }
17371
17406
  }
17372
17407
  }
@@ -17374,7 +17409,7 @@
17374
17409
  else if (currentStartLookup.end > relativeTick) {
17375
17410
  break;
17376
17411
  }
17377
- currentStartLookup = (_a = currentStartLookup === null || currentStartLookup === void 0 ? void 0 : currentStartLookup.nextBeat) !== null && _a !== void 0 ? _a : null;
17412
+ currentStartLookup = (_c = currentStartLookup === null || currentStartLookup === void 0 ? void 0 : currentStartLookup.nextBeat) !== null && _c !== void 0 ? _c : null;
17378
17413
  }
17379
17414
  if (startBeat == null) {
17380
17415
  return null;
@@ -17456,6 +17491,7 @@
17456
17491
  addMasterBar(masterBar) {
17457
17492
  this.masterBars.push(masterBar);
17458
17493
  if (this._currentMasterBar) {
17494
+ masterBar.previousMasterBar = this._currentMasterBar;
17459
17495
  this._currentMasterBar.nextMasterBar = masterBar;
17460
17496
  }
17461
17497
  this._currentMasterBar = masterBar;
@@ -19519,16 +19555,13 @@
19519
19555
  }
19520
19556
  }
19521
19557
  }
19522
- const realTickOffset = !beat.nextBeat
19523
- ? audioDuration
19524
- : beat.nextBeat.absolutePlaybackStart - beat.absolutePlaybackStart;
19525
19558
  // in case of normal playback register playback
19526
19559
  if (realBar === beat.voice.bar) {
19527
- this.tickLookup.addBeat(beat, beatStart, realTickOffset > audioDuration ? realTickOffset : audioDuration);
19560
+ this.tickLookup.addBeat(beat, beatStart, audioDuration);
19528
19561
  }
19529
19562
  else {
19530
19563
  // in case of simile marks where we repeat we also register
19531
- this.tickLookup.addBeat(beat, 0, realTickOffset > audioDuration ? realTickOffset : audioDuration);
19564
+ this.tickLookup.addBeat(beat, 0, audioDuration);
19532
19565
  }
19533
19566
  const track = beat.voice.bar.staff.track;
19534
19567
  for (const automation of beat.automations) {
@@ -26136,7 +26169,7 @@
26136
26169
  if (this._playerState === PlayerState.Playing && !stop) {
26137
26170
  if (this.settings.player.enableElementHighlighting) {
26138
26171
  for (let highlight of beatsToHighlight) {
26139
- let className = BeatContainerGlyph.getGroupId(highlight);
26172
+ let className = BeatContainerGlyph.getGroupId(highlight.beat);
26140
26173
  this.uiFacade.highlightElements(className, beat.voice.bar.index);
26141
26174
  }
26142
26175
  }
@@ -26170,7 +26203,7 @@
26170
26203
  // trigger an event for others to indicate which beat/bar is played
26171
26204
  if (shouldNotifyBeatChange) {
26172
26205
  this.onPlayedBeatChanged(beat);
26173
- this.onActiveBeatsChanged(new ActiveBeatsChangedEventArgs(beatsToHighlight));
26206
+ this.onActiveBeatsChanged(new ActiveBeatsChangedEventArgs(beatsToHighlight.map(i => i.beat)));
26174
26207
  }
26175
26208
  }
26176
26209
  onPlayedBeatChanged(beat) {
@@ -42799,8 +42832,8 @@
42799
42832
  // </auto-generated>
42800
42833
  class VersionInfo {
42801
42834
  }
42802
- VersionInfo.version = '1.3.0-alpha.874';
42803
- VersionInfo.date = '2023-12-30T01:20:54.980Z';
42835
+ VersionInfo.version = '1.3.0-alpha.877';
42836
+ VersionInfo.date = '2024-01-02T01:23:49.737Z';
42804
42837
 
42805
42838
  var index$5 = /*#__PURE__*/Object.freeze({
42806
42839
  __proto__: null,