@coderline/alphatab 1.3.0-alpha.890 → 1.3.0-alpha.897

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.
@@ -5625,11 +5625,7 @@ declare class BeatTickLookupItem {
5625
5625
  * Gets the playback start of the beat according to the generated audio.
5626
5626
  */
5627
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);
5628
+ constructor(beat: Beat, playbackStart: number);
5633
5629
  }
5634
5630
  /**
5635
5631
  * Represents the time period, for which one or multiple {@link Beat}s are played
@@ -5669,7 +5665,7 @@ declare class BeatTickLookup {
5669
5665
  * Marks the given beat as highlighed as part of this lookup.
5670
5666
  * @param beat The beat to add.
5671
5667
  */
5672
- highlightBeat(beat: Beat, playbackStart: number, playbackDuration: number): void;
5668
+ highlightBeat(beat: Beat, playbackStart: number): void;
5673
5669
  /**
5674
5670
  * Looks for the first visible beat which starts at this lookup so it can be used for cursor placement.
5675
5671
  * @param visibleTracks The visible tracks.
@@ -5724,9 +5720,13 @@ declare class MasterBarTickLookup {
5724
5720
  previousMasterBar: MasterBarTickLookup | null;
5725
5721
  /**
5726
5722
  * Adds a new beat to this masterbar following the slicing logic required by the MidiTickLookup.
5723
+ * @param beat The beat to add to this masterbat
5724
+ * @param beatPlaybackStart The original start of this beat. This time is relevant for highlighting.
5725
+ * @param sliceStart The slice start to which this beat should be added. This time is relevant for creating new slices.
5726
+ * @param sliceDuration The slice duration to which this beat should be added. This time is relevant for creating new slices.
5727
5727
  * @returns The first item of the chain which was affected.
5728
5728
  */
5729
- addBeat(beat: Beat, start: number, duration: number): void;
5729
+ addBeat(beat: Beat, beatPlaybackStart: number, sliceStart: number, sliceDuration: number): void;
5730
5730
  }
5731
5731
 
5732
5732
  /**
package/dist/alphaTab.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alphaTab v1.3.0-alpha.890 (develop, build 890)
2
+ * alphaTab v1.3.0-alpha.897 (develop, build 897)
3
3
  *
4
4
  * Copyright © 2024, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
@@ -16813,10 +16813,9 @@
16813
16813
  * Represents a beat and when it is actually played according to the generated audio.
16814
16814
  */
16815
16815
  class BeatTickLookupItem {
16816
- constructor(beat, playbackStart, playbackDuration) {
16816
+ constructor(beat, playbackStart) {
16817
16817
  this.beat = beat;
16818
16818
  this.playbackStart = playbackStart;
16819
- this.playbackDuration = playbackDuration;
16820
16819
  }
16821
16820
  }
16822
16821
  /**
@@ -16854,13 +16853,13 @@
16854
16853
  * Marks the given beat as highlighed as part of this lookup.
16855
16854
  * @param beat The beat to add.
16856
16855
  */
16857
- highlightBeat(beat, playbackStart, playbackDuration) {
16858
- if (beat.isEmpty) {
16856
+ highlightBeat(beat, playbackStart) {
16857
+ if (beat.isEmpty && !beat.voice.isEmpty) {
16859
16858
  return;
16860
16859
  }
16861
16860
  if (!this._highlightedBeats.has(beat.id)) {
16862
16861
  this._highlightedBeats.set(beat.id, true);
16863
- this.highlightedBeats.push(new BeatTickLookupItem(beat, playbackStart, playbackDuration));
16862
+ this.highlightedBeats.push(new BeatTickLookupItem(beat, playbackStart));
16864
16863
  }
16865
16864
  }
16866
16865
  /**
@@ -16958,10 +16957,14 @@
16958
16957
  }
16959
16958
  /**
16960
16959
  * Adds a new beat to this masterbar following the slicing logic required by the MidiTickLookup.
16960
+ * @param beat The beat to add to this masterbat
16961
+ * @param beatPlaybackStart The original start of this beat. This time is relevant for highlighting.
16962
+ * @param sliceStart The slice start to which this beat should be added. This time is relevant for creating new slices.
16963
+ * @param sliceDuration The slice duration to which this beat should be added. This time is relevant for creating new slices.
16961
16964
  * @returns The first item of the chain which was affected.
16962
16965
  */
16963
- addBeat(beat, start, duration) {
16964
- const end = start + duration;
16966
+ addBeat(beat, beatPlaybackStart, sliceStart, sliceDuration) {
16967
+ const end = sliceStart + sliceDuration;
16965
16968
  // We have following scenarios we cover overall on inserts
16966
16969
  // Technically it would be possible to merge some code paths and work with loops
16967
16970
  // to handle all scenarios in a shorter piece of code.
@@ -17051,28 +17054,28 @@
17051
17054
  // | L 1 | L2 |
17052
17055
  // Variant A
17053
17056
  if (this.firstBeat == null) {
17054
- const n1 = new BeatTickLookup(start, end);
17055
- n1.highlightBeat(beat, start, duration);
17057
+ const n1 = new BeatTickLookup(sliceStart, end);
17058
+ n1.highlightBeat(beat, beatPlaybackStart);
17056
17059
  this.insertAfter(this.firstBeat, n1);
17057
17060
  }
17058
17061
  // Variant B
17059
17062
  // Variant C
17060
- else if (start >= this.lastBeat.end) {
17063
+ else if (sliceStart >= this.lastBeat.end) {
17061
17064
  // using the end here allows merge of B & C
17062
17065
  const n1 = new BeatTickLookup(this.lastBeat.end, end);
17063
- n1.highlightBeat(beat, start, duration);
17066
+ n1.highlightBeat(beat, beatPlaybackStart);
17064
17067
  this.insertAfter(this.lastBeat, n1);
17065
17068
  }
17066
17069
  else {
17067
17070
  let l1 = null;
17068
- if (start < this.firstBeat.start) {
17071
+ if (sliceStart < this.firstBeat.start) {
17069
17072
  l1 = this.firstBeat;
17070
17073
  }
17071
17074
  else {
17072
17075
  let current = this.firstBeat;
17073
17076
  while (current != null) {
17074
17077
  // find item where we fall into
17075
- if (start >= current.start && start < current.end) {
17078
+ if (sliceStart >= current.start && sliceStart < current.end) {
17076
17079
  l1 = current;
17077
17080
  break;
17078
17081
  }
@@ -17085,99 +17088,99 @@
17085
17088
  }
17086
17089
  // those scenarios should only happen if we insert before the
17087
17090
  // first item (e.g. for grace notes starting < 0)
17088
- if (start < l1.start) {
17091
+ if (sliceStart < l1.start) {
17089
17092
  // Variant D
17090
17093
  // Variant E
17091
17094
  if (end == l1.start) {
17092
17095
  // using firstBeat.start here allows merge of D & E
17093
- const n1 = new BeatTickLookup(start, l1.start);
17094
- n1.highlightBeat(beat, start, duration);
17096
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17097
+ n1.highlightBeat(beat, beatPlaybackStart);
17095
17098
  this.insertBefore(this.firstBeat, n1);
17096
17099
  }
17097
17100
  // Variant F
17098
17101
  else if (end < l1.end) {
17099
- const n1 = new BeatTickLookup(start, l1.start);
17100
- n1.highlightBeat(beat, start, duration);
17102
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17103
+ n1.highlightBeat(beat, beatPlaybackStart);
17101
17104
  this.insertBefore(l1, n1);
17102
17105
  const n2 = new BeatTickLookup(l1.start, end);
17103
17106
  for (const b of l1.highlightedBeats) {
17104
- n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17107
+ n2.highlightBeat(b.beat, b.playbackStart);
17105
17108
  }
17106
- n2.highlightBeat(beat, start, duration);
17109
+ n2.highlightBeat(beat, beatPlaybackStart);
17107
17110
  this.insertBefore(l1, n2);
17108
17111
  l1.start = end;
17109
17112
  }
17110
17113
  // Variant G
17111
17114
  else if (end == l1.end) {
17112
- const n1 = new BeatTickLookup(start, l1.start);
17113
- n1.highlightBeat(beat, start, duration);
17114
- l1.highlightBeat(beat, start, duration);
17115
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17116
+ n1.highlightBeat(beat, beatPlaybackStart);
17117
+ l1.highlightBeat(beat, beatPlaybackStart);
17115
17118
  this.insertBefore(l1, n1);
17116
17119
  }
17117
17120
  // Variant H
17118
17121
  else /* end > this.firstBeat.end */ {
17119
- const n1 = new BeatTickLookup(start, l1.start);
17120
- n1.highlightBeat(beat, start, duration);
17121
- l1.highlightBeat(beat, start, duration);
17122
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17123
+ n1.highlightBeat(beat, beatPlaybackStart);
17124
+ l1.highlightBeat(beat, beatPlaybackStart);
17122
17125
  this.insertBefore(l1, n1);
17123
- this.addBeat(beat, l1.end, end - l1.end);
17126
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17124
17127
  }
17125
17128
  }
17126
- else if (start > l1.start) {
17129
+ else if (sliceStart > l1.start) {
17127
17130
  // variant I
17128
17131
  if (end == l1.end) {
17129
- const n1 = new BeatTickLookup(l1.start, start);
17132
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17130
17133
  for (const b of l1.highlightedBeats) {
17131
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17134
+ n1.highlightBeat(b.beat, b.playbackStart);
17132
17135
  }
17133
- l1.start = start;
17134
- l1.highlightBeat(beat, start, duration);
17136
+ l1.start = sliceStart;
17137
+ l1.highlightBeat(beat, beatPlaybackStart);
17135
17138
  this.insertBefore(l1, n1);
17136
17139
  }
17137
17140
  // Variant J
17138
17141
  else if (end < l1.end) {
17139
- const n1 = new BeatTickLookup(l1.start, start);
17142
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17140
17143
  this.insertBefore(l1, n1);
17141
- const n2 = new BeatTickLookup(start, end);
17144
+ const n2 = new BeatTickLookup(sliceStart, end);
17142
17145
  this.insertBefore(l1, n2);
17143
17146
  for (const b of l1.highlightedBeats) {
17144
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17145
- n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17147
+ n1.highlightBeat(b.beat, b.playbackStart);
17148
+ n2.highlightBeat(b.beat, b.playbackStart);
17146
17149
  }
17147
- n2.highlightBeat(beat, start, duration);
17150
+ n2.highlightBeat(beat, beatPlaybackStart);
17148
17151
  l1.start = end;
17149
17152
  }
17150
17153
  // Variant K
17151
17154
  else /* end > l1.end */ {
17152
- const n1 = new BeatTickLookup(l1.start, start);
17155
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17153
17156
  for (const b of l1.highlightedBeats) {
17154
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17157
+ n1.highlightBeat(b.beat, b.playbackStart);
17155
17158
  }
17156
- l1.start = start;
17157
- l1.highlightBeat(beat, start, duration);
17159
+ l1.start = sliceStart;
17160
+ l1.highlightBeat(beat, beatPlaybackStart);
17158
17161
  this.insertBefore(l1, n1);
17159
- this.addBeat(beat, l1.end, end - l1.end);
17162
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17160
17163
  }
17161
17164
  }
17162
17165
  else /* start == l1.start */ {
17163
17166
  // Variant L
17164
17167
  if (end === l1.end) {
17165
- l1.highlightBeat(beat, start, end);
17168
+ l1.highlightBeat(beat, beatPlaybackStart);
17166
17169
  }
17167
17170
  // Variant M
17168
17171
  else if (end < l1.end) {
17169
17172
  const n1 = new BeatTickLookup(l1.start, end);
17170
17173
  for (const b of l1.highlightedBeats) {
17171
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17174
+ n1.highlightBeat(b.beat, b.playbackStart);
17172
17175
  }
17173
- n1.highlightBeat(beat, start, duration);
17176
+ n1.highlightBeat(beat, beatPlaybackStart);
17174
17177
  l1.start = end;
17175
17178
  this.insertBefore(l1, n1);
17176
17179
  }
17177
17180
  // variant N
17178
17181
  else /* end > l1.end */ {
17179
- l1.highlightBeat(beat, start, duration);
17180
- this.addBeat(beat, l1.end, end - l1.end);
17182
+ l1.highlightBeat(beat, beatPlaybackStart);
17183
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17181
17184
  }
17182
17185
  }
17183
17186
  }
@@ -17500,8 +17503,25 @@
17500
17503
  }
17501
17504
  }
17502
17505
  addBeat(beat, start, duration) {
17503
- var _a;
17504
- (_a = this._currentMasterBar) === null || _a === void 0 ? void 0 : _a.addBeat(beat, start, duration);
17506
+ const currentMasterBar = this._currentMasterBar;
17507
+ if (currentMasterBar) {
17508
+ // pre-beat grace notes at the start of the bar we also add the beat to the previous bar
17509
+ if (start < 0 && currentMasterBar.previousMasterBar) {
17510
+ const previousStart = currentMasterBar.previousMasterBar.end + start;
17511
+ const previousEnd = previousStart + duration;
17512
+ // add to previous bar
17513
+ currentMasterBar.previousMasterBar.addBeat(beat, previousStart, previousStart, currentMasterBar.previousMasterBar.end - previousStart);
17514
+ // overlap to current bar?
17515
+ if (previousEnd > currentMasterBar.previousMasterBar.end) {
17516
+ // the start is negative and representing the overlap to the previous bar.
17517
+ const overlapDuration = duration + start;
17518
+ currentMasterBar.addBeat(beat, start, 0, overlapDuration);
17519
+ }
17520
+ }
17521
+ else {
17522
+ currentMasterBar.addBeat(beat, start, start, duration);
17523
+ }
17524
+ }
17505
17525
  }
17506
17526
  }
17507
17527
 
@@ -42832,8 +42852,8 @@
42832
42852
  // </auto-generated>
42833
42853
  class VersionInfo {
42834
42854
  }
42835
- VersionInfo.version = '1.3.0-alpha.890';
42836
- VersionInfo.date = '2024-01-15T01:34:32.275Z';
42855
+ VersionInfo.version = '1.3.0-alpha.897';
42856
+ VersionInfo.date = '2024-01-22T01:35:37.246Z';
42837
42857
 
42838
42858
  var index$5 = /*#__PURE__*/Object.freeze({
42839
42859
  __proto__: null,