@coderline/alphatab 1.3.0-alpha.375 → 1.3.0-alpha.387

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.
@@ -3722,6 +3722,11 @@ declare class MidiTickLookupFindBeatResult {
3722
3722
  * Gets or sets the duration in milliseconds how long this beat is playing.
3723
3723
  */
3724
3724
  duration: number;
3725
+ /**
3726
+ * Gets or sets the duration in midi ticks for how long this tick lookup is valid
3727
+ * starting at the `currentBeatLookup.start`
3728
+ */
3729
+ tickDuration: number;
3725
3730
  /**
3726
3731
  * Gets or sets the beats ot highlight along the current beat.
3727
3732
  */
@@ -4411,6 +4416,10 @@ declare class BarBounds {
4411
4416
  * @returns The beat at the given X-position or null if none was found.
4412
4417
  */
4413
4418
  findBeatAtPos(x: number): BeatBounds | null;
4419
+ /**
4420
+ * Finishes the lookup object and optimizes itself for fast access.
4421
+ */
4422
+ finish(): void;
4414
4423
  }
4415
4424
 
4416
4425
  /**
package/dist/alphaTab.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * alphaTab v1.3.0-alpha.375 (develop, build 375)
2
+ * alphaTab v1.3.0-alpha.387 (develop, build 387)
3
3
  *
4
4
  * Copyright © 2022, Daniel Kuschny and Contributors, All rights reserved.
5
5
  *
@@ -21287,6 +21287,12 @@
21287
21287
  }
21288
21288
  return beat;
21289
21289
  }
21290
+ /**
21291
+ * Finishes the lookup object and optimizes itself for fast access.
21292
+ */
21293
+ finish() {
21294
+ this.beats.sort((a, b) => a.realBounds.x - b.realBounds.x);
21295
+ }
21290
21296
  }
21291
21297
 
21292
21298
  /**
@@ -21373,10 +21379,14 @@
21373
21379
  */
21374
21380
  findBeatAtPos(x, y) {
21375
21381
  let beat = null;
21382
+ let distance = 10000000;
21376
21383
  for (let bar of this.bars) {
21377
21384
  let b = bar.findBeatAtPos(x);
21378
21385
  if (b && (!beat || beat.realBounds.x < b.realBounds.x)) {
21379
- beat = b;
21386
+ const newDistance = Math.abs(b.realBounds.x - x);
21387
+ if (!beat || newDistance < distance) {
21388
+ beat = b;
21389
+ }
21380
21390
  }
21381
21391
  }
21382
21392
  return !beat ? null : beat.beat;
@@ -21400,6 +21410,9 @@
21400
21410
  }
21401
21411
  return 0;
21402
21412
  });
21413
+ for (const bar of this.bars) {
21414
+ bar.finish();
21415
+ }
21403
21416
  }
21404
21417
  /**
21405
21418
  * Adds a new beat to the lookup.
@@ -21916,6 +21929,8 @@
21916
21929
  this.postRenderFinished.trigger();
21917
21930
  }
21918
21931
  onRenderFinished() {
21932
+ var _a;
21933
+ (_a = this.boundsLookup) === null || _a === void 0 ? void 0 : _a.finish();
21919
21934
  const e = new RenderFinishedEventArgs();
21920
21935
  e.totalHeight = this.layout.height;
21921
21936
  e.totalWidth = this.layout.width;
@@ -22675,6 +22690,11 @@
22675
22690
  * Gets or sets the duration in milliseconds how long this beat is playing.
22676
22691
  */
22677
22692
  this.duration = 0;
22693
+ /**
22694
+ * Gets or sets the duration in midi ticks for how long this tick lookup is valid
22695
+ * starting at the `currentBeatLookup.start`
22696
+ */
22697
+ this.tickDuration = 0;
22678
22698
  /**
22679
22699
  * Gets or sets the beat lookup for the next beat.
22680
22700
  */
@@ -22766,7 +22786,8 @@
22766
22786
  return result;
22767
22787
  }
22768
22788
  findBeatFast(trackLookup, currentBeatHint, tick) {
22769
- if (tick >= currentBeatHint.currentBeatLookup.start && tick < currentBeatHint.currentBeatLookup.end) {
22789
+ const end = currentBeatHint.currentBeatLookup.start + currentBeatHint.tickDuration;
22790
+ if (tick >= currentBeatHint.currentBeatLookup.start && tick < end) {
22770
22791
  // still same beat?
22771
22792
  return currentBeatHint;
22772
22793
  }
@@ -22815,9 +22836,8 @@
22815
22836
  const result = new MidiTickLookupFindBeatResult();
22816
22837
  result.currentBeatLookup = beat;
22817
22838
  result.nextBeatLookup = nextBeat;
22818
- result.duration = !nextBeat
22819
- ? MidiUtils.ticksToMillis(beat.end - beat.start, beat.masterBar.tempo)
22820
- : MidiUtils.ticksToMillis(nextBeat.start - beat.start, beat.masterBar.tempo);
22839
+ result.tickDuration = !nextBeat ? beat.end - beat.start : nextBeat.start - beat.start;
22840
+ result.duration = MidiUtils.ticksToMillis(result.tickDuration, beat.masterBar.tempo);
22821
22841
  result.beatsToHighlight = beat.beatsToHighlight;
22822
22842
  return result;
22823
22843
  }
@@ -26669,6 +26689,7 @@
26669
26689
  break;
26670
26690
  case 'alphaTab.postRenderFinished':
26671
26691
  this.boundsLookup = BoundsLookup.fromJson(data.boundsLookup, this._api.score);
26692
+ this.boundsLookup.finish();
26672
26693
  this.postRenderFinished.trigger();
26673
26694
  break;
26674
26695
  case 'alphaTab.error':
@@ -39373,7 +39394,7 @@
39373
39394
  // after the layout is parsed we can build up the
39374
39395
  // track > staff structure for later use
39375
39396
  // curly brackets define which staves go together into a track
39376
- const curlyBrackets = this._brackets.filter(b => b.curly);
39397
+ const curlyBrackets = this._brackets.filter(b => !!b.curly);
39377
39398
  curlyBrackets.sort((a, b) => a.from - b.from);
39378
39399
  let currentBracketIndex = 0;
39379
39400
  let currentTrack = null;
@@ -41114,8 +41135,8 @@
41114
41135
  // </auto-generated>
41115
41136
  class VersionInfo {
41116
41137
  }
41117
- VersionInfo.version = '1.3.0-alpha.375';
41118
- VersionInfo.date = '2022-08-29T00:57:33.607Z';
41138
+ VersionInfo.version = '1.3.0-alpha.387';
41139
+ VersionInfo.date = '2022-09-10T01:00:00.369Z';
41119
41140
 
41120
41141
  var index$5 = /*#__PURE__*/Object.freeze({
41121
41142
  __proto__: null,