@coderline/alphatab 1.3.0-alpha.891 → 1.3.0-alpha.898

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.
package/dist/alphaTab.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alphaTab v1.3.0-alpha.891 (develop, build 891)
2
+ * alphaTab v1.3.0-alpha.898 (develop, build 898)
3
3
  *
4
4
  * Copyright © 2024, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
@@ -16807,10 +16807,9 @@ class Queue {
16807
16807
  * Represents a beat and when it is actually played according to the generated audio.
16808
16808
  */
16809
16809
  class BeatTickLookupItem {
16810
- constructor(beat, playbackStart, playbackDuration) {
16810
+ constructor(beat, playbackStart) {
16811
16811
  this.beat = beat;
16812
16812
  this.playbackStart = playbackStart;
16813
- this.playbackDuration = playbackDuration;
16814
16813
  }
16815
16814
  }
16816
16815
  /**
@@ -16848,13 +16847,13 @@ class BeatTickLookup {
16848
16847
  * Marks the given beat as highlighed as part of this lookup.
16849
16848
  * @param beat The beat to add.
16850
16849
  */
16851
- highlightBeat(beat, playbackStart, playbackDuration) {
16852
- if (beat.isEmpty) {
16850
+ highlightBeat(beat, playbackStart) {
16851
+ if (beat.isEmpty && !beat.voice.isEmpty) {
16853
16852
  return;
16854
16853
  }
16855
16854
  if (!this._highlightedBeats.has(beat.id)) {
16856
16855
  this._highlightedBeats.set(beat.id, true);
16857
- this.highlightedBeats.push(new BeatTickLookupItem(beat, playbackStart, playbackDuration));
16856
+ this.highlightedBeats.push(new BeatTickLookupItem(beat, playbackStart));
16858
16857
  }
16859
16858
  }
16860
16859
  /**
@@ -16952,10 +16951,14 @@ class MasterBarTickLookup {
16952
16951
  }
16953
16952
  /**
16954
16953
  * Adds a new beat to this masterbar following the slicing logic required by the MidiTickLookup.
16954
+ * @param beat The beat to add to this masterbat
16955
+ * @param beatPlaybackStart The original start of this beat. This time is relevant for highlighting.
16956
+ * @param sliceStart The slice start to which this beat should be added. This time is relevant for creating new slices.
16957
+ * @param sliceDuration The slice duration to which this beat should be added. This time is relevant for creating new slices.
16955
16958
  * @returns The first item of the chain which was affected.
16956
16959
  */
16957
- addBeat(beat, start, duration) {
16958
- const end = start + duration;
16960
+ addBeat(beat, beatPlaybackStart, sliceStart, sliceDuration) {
16961
+ const end = sliceStart + sliceDuration;
16959
16962
  // We have following scenarios we cover overall on inserts
16960
16963
  // Technically it would be possible to merge some code paths and work with loops
16961
16964
  // to handle all scenarios in a shorter piece of code.
@@ -17045,28 +17048,28 @@ class MasterBarTickLookup {
17045
17048
  // | L 1 | L2 |
17046
17049
  // Variant A
17047
17050
  if (this.firstBeat == null) {
17048
- const n1 = new BeatTickLookup(start, end);
17049
- n1.highlightBeat(beat, start, duration);
17051
+ const n1 = new BeatTickLookup(sliceStart, end);
17052
+ n1.highlightBeat(beat, beatPlaybackStart);
17050
17053
  this.insertAfter(this.firstBeat, n1);
17051
17054
  }
17052
17055
  // Variant B
17053
17056
  // Variant C
17054
- else if (start >= this.lastBeat.end) {
17057
+ else if (sliceStart >= this.lastBeat.end) {
17055
17058
  // using the end here allows merge of B & C
17056
17059
  const n1 = new BeatTickLookup(this.lastBeat.end, end);
17057
- n1.highlightBeat(beat, start, duration);
17060
+ n1.highlightBeat(beat, beatPlaybackStart);
17058
17061
  this.insertAfter(this.lastBeat, n1);
17059
17062
  }
17060
17063
  else {
17061
17064
  let l1 = null;
17062
- if (start < this.firstBeat.start) {
17065
+ if (sliceStart < this.firstBeat.start) {
17063
17066
  l1 = this.firstBeat;
17064
17067
  }
17065
17068
  else {
17066
17069
  let current = this.firstBeat;
17067
17070
  while (current != null) {
17068
17071
  // find item where we fall into
17069
- if (start >= current.start && start < current.end) {
17072
+ if (sliceStart >= current.start && sliceStart < current.end) {
17070
17073
  l1 = current;
17071
17074
  break;
17072
17075
  }
@@ -17079,99 +17082,99 @@ class MasterBarTickLookup {
17079
17082
  }
17080
17083
  // those scenarios should only happen if we insert before the
17081
17084
  // first item (e.g. for grace notes starting < 0)
17082
- if (start < l1.start) {
17085
+ if (sliceStart < l1.start) {
17083
17086
  // Variant D
17084
17087
  // Variant E
17085
17088
  if (end == l1.start) {
17086
17089
  // using firstBeat.start here allows merge of D & E
17087
- const n1 = new BeatTickLookup(start, l1.start);
17088
- n1.highlightBeat(beat, start, duration);
17090
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17091
+ n1.highlightBeat(beat, beatPlaybackStart);
17089
17092
  this.insertBefore(this.firstBeat, n1);
17090
17093
  }
17091
17094
  // Variant F
17092
17095
  else if (end < l1.end) {
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(l1, n1);
17096
17099
  const n2 = new BeatTickLookup(l1.start, end);
17097
17100
  for (const b of l1.highlightedBeats) {
17098
- n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17101
+ n2.highlightBeat(b.beat, b.playbackStart);
17099
17102
  }
17100
- n2.highlightBeat(beat, start, duration);
17103
+ n2.highlightBeat(beat, beatPlaybackStart);
17101
17104
  this.insertBefore(l1, n2);
17102
17105
  l1.start = end;
17103
17106
  }
17104
17107
  // Variant G
17105
17108
  else if (end == l1.end) {
17106
- const n1 = new BeatTickLookup(start, l1.start);
17107
- n1.highlightBeat(beat, start, duration);
17108
- l1.highlightBeat(beat, start, duration);
17109
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17110
+ n1.highlightBeat(beat, beatPlaybackStart);
17111
+ l1.highlightBeat(beat, beatPlaybackStart);
17109
17112
  this.insertBefore(l1, n1);
17110
17113
  }
17111
17114
  // Variant H
17112
17115
  else /* end > this.firstBeat.end */ {
17113
- const n1 = new BeatTickLookup(start, l1.start);
17114
- n1.highlightBeat(beat, start, duration);
17115
- l1.highlightBeat(beat, start, duration);
17116
+ const n1 = new BeatTickLookup(sliceStart, l1.start);
17117
+ n1.highlightBeat(beat, beatPlaybackStart);
17118
+ l1.highlightBeat(beat, beatPlaybackStart);
17116
17119
  this.insertBefore(l1, n1);
17117
- this.addBeat(beat, l1.end, end - l1.end);
17120
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17118
17121
  }
17119
17122
  }
17120
- else if (start > l1.start) {
17123
+ else if (sliceStart > l1.start) {
17121
17124
  // variant I
17122
17125
  if (end == l1.end) {
17123
- const n1 = new BeatTickLookup(l1.start, start);
17126
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17124
17127
  for (const b of l1.highlightedBeats) {
17125
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17128
+ n1.highlightBeat(b.beat, b.playbackStart);
17126
17129
  }
17127
- l1.start = start;
17128
- l1.highlightBeat(beat, start, duration);
17130
+ l1.start = sliceStart;
17131
+ l1.highlightBeat(beat, beatPlaybackStart);
17129
17132
  this.insertBefore(l1, n1);
17130
17133
  }
17131
17134
  // Variant J
17132
17135
  else if (end < l1.end) {
17133
- const n1 = new BeatTickLookup(l1.start, start);
17136
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17134
17137
  this.insertBefore(l1, n1);
17135
- const n2 = new BeatTickLookup(start, end);
17138
+ const n2 = new BeatTickLookup(sliceStart, end);
17136
17139
  this.insertBefore(l1, n2);
17137
17140
  for (const b of l1.highlightedBeats) {
17138
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17139
- n2.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17141
+ n1.highlightBeat(b.beat, b.playbackStart);
17142
+ n2.highlightBeat(b.beat, b.playbackStart);
17140
17143
  }
17141
- n2.highlightBeat(beat, start, duration);
17144
+ n2.highlightBeat(beat, beatPlaybackStart);
17142
17145
  l1.start = end;
17143
17146
  }
17144
17147
  // Variant K
17145
17148
  else /* end > l1.end */ {
17146
- const n1 = new BeatTickLookup(l1.start, start);
17149
+ const n1 = new BeatTickLookup(l1.start, sliceStart);
17147
17150
  for (const b of l1.highlightedBeats) {
17148
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17151
+ n1.highlightBeat(b.beat, b.playbackStart);
17149
17152
  }
17150
- l1.start = start;
17151
- l1.highlightBeat(beat, start, duration);
17153
+ l1.start = sliceStart;
17154
+ l1.highlightBeat(beat, beatPlaybackStart);
17152
17155
  this.insertBefore(l1, n1);
17153
- this.addBeat(beat, l1.end, end - l1.end);
17156
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17154
17157
  }
17155
17158
  }
17156
17159
  else /* start == l1.start */ {
17157
17160
  // Variant L
17158
17161
  if (end === l1.end) {
17159
- l1.highlightBeat(beat, start, end);
17162
+ l1.highlightBeat(beat, beatPlaybackStart);
17160
17163
  }
17161
17164
  // Variant M
17162
17165
  else if (end < l1.end) {
17163
17166
  const n1 = new BeatTickLookup(l1.start, end);
17164
17167
  for (const b of l1.highlightedBeats) {
17165
- n1.highlightBeat(b.beat, b.playbackStart, b.playbackDuration);
17168
+ n1.highlightBeat(b.beat, b.playbackStart);
17166
17169
  }
17167
- n1.highlightBeat(beat, start, duration);
17170
+ n1.highlightBeat(beat, beatPlaybackStart);
17168
17171
  l1.start = end;
17169
17172
  this.insertBefore(l1, n1);
17170
17173
  }
17171
17174
  // variant N
17172
17175
  else /* end > l1.end */ {
17173
- l1.highlightBeat(beat, start, duration);
17174
- this.addBeat(beat, l1.end, end - l1.end);
17176
+ l1.highlightBeat(beat, beatPlaybackStart);
17177
+ this.addBeat(beat, beatPlaybackStart, l1.end, end - l1.end);
17175
17178
  }
17176
17179
  }
17177
17180
  }
@@ -17494,8 +17497,25 @@ class MidiTickLookup {
17494
17497
  }
17495
17498
  }
17496
17499
  addBeat(beat, start, duration) {
17497
- var _a;
17498
- (_a = this._currentMasterBar) === null || _a === void 0 ? void 0 : _a.addBeat(beat, start, duration);
17500
+ const currentMasterBar = this._currentMasterBar;
17501
+ if (currentMasterBar) {
17502
+ // pre-beat grace notes at the start of the bar we also add the beat to the previous bar
17503
+ if (start < 0 && currentMasterBar.previousMasterBar) {
17504
+ const previousStart = currentMasterBar.previousMasterBar.end + start;
17505
+ const previousEnd = previousStart + duration;
17506
+ // add to previous bar
17507
+ currentMasterBar.previousMasterBar.addBeat(beat, previousStart, previousStart, currentMasterBar.previousMasterBar.end - previousStart);
17508
+ // overlap to current bar?
17509
+ if (previousEnd > currentMasterBar.previousMasterBar.end) {
17510
+ // the start is negative and representing the overlap to the previous bar.
17511
+ const overlapDuration = duration + start;
17512
+ currentMasterBar.addBeat(beat, start, 0, overlapDuration);
17513
+ }
17514
+ }
17515
+ else {
17516
+ currentMasterBar.addBeat(beat, start, start, duration);
17517
+ }
17518
+ }
17499
17519
  }
17500
17520
  }
17501
17521
 
@@ -42826,8 +42846,8 @@ class CoreSettings {
42826
42846
  // </auto-generated>
42827
42847
  class VersionInfo {
42828
42848
  }
42829
- VersionInfo.version = '1.3.0-alpha.891';
42830
- VersionInfo.date = '2024-01-16T01:25:36.345Z';
42849
+ VersionInfo.version = '1.3.0-alpha.898';
42850
+ VersionInfo.date = '2024-01-23T01:33:07.438Z';
42831
42851
 
42832
42852
  var index$5 = /*#__PURE__*/Object.freeze({
42833
42853
  __proto__: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coderline/alphatab",
3
- "version": "1.3.0-alpha.891",
3
+ "version": "1.3.0-alpha.898",
4
4
  "description": "alphaTab is a music notation and guitar tablature rendering library",
5
5
  "keywords": [
6
6
  "guitar",