@dawcore/components 0.0.21 → 0.0.23

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/index.mjs CHANGED
@@ -4605,7 +4605,7 @@ var DawEditorElement = class extends LitElement11 {
4605
4605
  const old = this._bpm;
4606
4606
  if (!Number.isFinite(value) || value <= 0) return;
4607
4607
  this._bpm = value;
4608
- if (this._engine) {
4608
+ if (this._engine && !this._hasTickCallbacks) {
4609
4609
  this._engine.setTempo(value);
4610
4610
  }
4611
4611
  this.requestUpdate("bpm", old);
@@ -4624,6 +4624,11 @@ var DawEditorElement = class extends LitElement11 {
4624
4624
  this._ppqn = value;
4625
4625
  this.requestUpdate("ppqn", old);
4626
4626
  }
4627
+ /** True when the consumer provided BOTH tick conversion callbacks — the
4628
+ * external tempo map is authoritative and `bpm` is display/grid-only (#407). */
4629
+ get _hasTickCallbacks() {
4630
+ return !!(this.secondsToTicks && this.ticksToSeconds);
4631
+ }
4627
4632
  /** Sample rate — reads from adapter's AudioContext when available, otherwise falls back to 48000. */
4628
4633
  get sampleRate() {
4629
4634
  return this._resolvedSampleRate ?? this._externalAdapter?.audioContext.sampleRate ?? 48e3;
@@ -5509,12 +5514,14 @@ var DawEditorElement = class extends LitElement11 {
5509
5514
  }
5510
5515
  const { PlaylistEngine } = await import("@waveform-playlist/engine");
5511
5516
  const adapter = this._externalAdapter;
5512
- if (adapter.setTempo) {
5513
- adapter.setTempo(this._bpm);
5514
- } else if (this._bpm !== 120) {
5515
- console.warn(
5516
- "[dawcore] Adapter does not implement setTempo. Initial BPM " + this._bpm + " will not be applied \u2014 clips may use wrong tempo."
5517
- );
5517
+ if (!this._hasTickCallbacks) {
5518
+ if (adapter.setTempo) {
5519
+ adapter.setTempo(this._bpm);
5520
+ } else if (this._bpm !== 120) {
5521
+ console.warn(
5522
+ "[dawcore] Adapter does not implement setTempo. Initial BPM " + this._bpm + " will not be applied \u2014 clips may use wrong tempo."
5523
+ );
5524
+ }
5518
5525
  }
5519
5526
  adapter.setPpqn?.(this._ppqn);
5520
5527
  this.ppqn = adapter.ppqn;
@@ -6050,12 +6057,7 @@ var DawEditorElement = class extends LitElement11 {
6050
6057
  const playhead = this._getPlayhead();
6051
6058
  if (!playhead || !this._engine) return;
6052
6059
  const engine = this._engine;
6053
- const ctx = this.audioContext;
6054
- const audibleTime = () => {
6055
- const outputLatency = "outputLatency" in ctx ? ctx.outputLatency : 0;
6056
- const t = engine.getCurrentTime() - outputLatency - engine.lookAhead;
6057
- return Number.isFinite(t) ? Math.max(0, t) : 0;
6058
- };
6060
+ const audibleTime = () => engine.getAudibleTime();
6059
6061
  if (this.scaleMode === "beats") {
6060
6062
  const secondsToTicksFn = (s) => this._secondsToTicks(s);
6061
6063
  playhead.startBeatsAnimationWithMap(audibleTime, secondsToTicksFn, this.ticksPerPixel);
@@ -6066,10 +6068,7 @@ var DawEditorElement = class extends LitElement11 {
6066
6068
  _stopPlayhead() {
6067
6069
  const playhead = this._getPlayhead();
6068
6070
  if (!playhead) return;
6069
- const ctx = this.audioContext;
6070
- const outputLatency = "outputLatency" in ctx ? ctx.outputLatency : 0;
6071
- const lookAhead = this._engine?.lookAhead ?? 0;
6072
- const t = this._currentTime - outputLatency - lookAhead;
6071
+ const t = this._currentTime;
6073
6072
  const visualTime = Number.isFinite(t) ? Math.max(0, t) : 0;
6074
6073
  if (this.scaleMode === "beats") {
6075
6074
  playhead.stopBeatsAnimationWithMap(