@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.d.mts CHANGED
@@ -961,10 +961,17 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
961
961
  set ppqn(value: number);
962
962
  private _ppqn;
963
963
  snapTo: SnapTo;
964
- /** Optional tempo-aware conversion: seconds → PPQN ticks. When provided, enables variable tempo. */
964
+ /** Optional tempo-aware conversion: seconds → PPQN ticks. When provided
965
+ * together with ticksToSeconds, enables variable tempo AND makes `bpm`
966
+ * display/grid-only (no engine/adapter tempo forwarding — #407). */
965
967
  secondsToTicks?: (seconds: number) => number;
966
- /** Optional tempo-aware conversion: PPQN ticks → seconds. Required alongside secondsToTicks. */
968
+ /** Optional tempo-aware conversion: PPQN ticks → seconds. Required alongside
969
+ * secondsToTicks — see that property for the variable-tempo and bpm
970
+ * display-only semantics enabled when both are set (#407). */
967
971
  ticksToSeconds?: (ticks: number) => number;
972
+ /** True when the consumer provided BOTH tick conversion callbacks — the
973
+ * external tempo map is authoritative and `bpm` is display/grid-only (#407). */
974
+ get _hasTickCallbacks(): boolean;
968
975
  /** Sample rate — reads from adapter's AudioContext when available, otherwise falls back to 48000. */
969
976
  get sampleRate(): number;
970
977
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
package/dist/index.d.ts CHANGED
@@ -961,10 +961,17 @@ declare class DawEditorElement extends LitElement implements MidiLoaderHost {
961
961
  set ppqn(value: number);
962
962
  private _ppqn;
963
963
  snapTo: SnapTo;
964
- /** Optional tempo-aware conversion: seconds → PPQN ticks. When provided, enables variable tempo. */
964
+ /** Optional tempo-aware conversion: seconds → PPQN ticks. When provided
965
+ * together with ticksToSeconds, enables variable tempo AND makes `bpm`
966
+ * display/grid-only (no engine/adapter tempo forwarding — #407). */
965
967
  secondsToTicks?: (seconds: number) => number;
966
- /** Optional tempo-aware conversion: PPQN ticks → seconds. Required alongside secondsToTicks. */
968
+ /** Optional tempo-aware conversion: PPQN ticks → seconds. Required alongside
969
+ * secondsToTicks — see that property for the variable-tempo and bpm
970
+ * display-only semantics enabled when both are set (#407). */
967
971
  ticksToSeconds?: (ticks: number) => number;
972
+ /** True when the consumer provided BOTH tick conversion callbacks — the
973
+ * external tempo map is authoritative and `bpm` is display/grid-only (#407). */
974
+ get _hasTickCallbacks(): boolean;
968
975
  /** Sample rate — reads from adapter's AudioContext when available, otherwise falls back to 48000. */
969
976
  get sampleRate(): number;
970
977
  /** Resolved sample rate — falls back to sampleRate property until first audio decode. */
package/dist/index.js CHANGED
@@ -4652,7 +4652,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
4652
4652
  const old = this._bpm;
4653
4653
  if (!Number.isFinite(value) || value <= 0) return;
4654
4654
  this._bpm = value;
4655
- if (this._engine) {
4655
+ if (this._engine && !this._hasTickCallbacks) {
4656
4656
  this._engine.setTempo(value);
4657
4657
  }
4658
4658
  this.requestUpdate("bpm", old);
@@ -4671,6 +4671,11 @@ var DawEditorElement = class extends import_lit15.LitElement {
4671
4671
  this._ppqn = value;
4672
4672
  this.requestUpdate("ppqn", old);
4673
4673
  }
4674
+ /** True when the consumer provided BOTH tick conversion callbacks — the
4675
+ * external tempo map is authoritative and `bpm` is display/grid-only (#407). */
4676
+ get _hasTickCallbacks() {
4677
+ return !!(this.secondsToTicks && this.ticksToSeconds);
4678
+ }
4674
4679
  /** Sample rate — reads from adapter's AudioContext when available, otherwise falls back to 48000. */
4675
4680
  get sampleRate() {
4676
4681
  return this._resolvedSampleRate ?? this._externalAdapter?.audioContext.sampleRate ?? 48e3;
@@ -5556,12 +5561,14 @@ var DawEditorElement = class extends import_lit15.LitElement {
5556
5561
  }
5557
5562
  const { PlaylistEngine } = await import("@waveform-playlist/engine");
5558
5563
  const adapter = this._externalAdapter;
5559
- if (adapter.setTempo) {
5560
- adapter.setTempo(this._bpm);
5561
- } else if (this._bpm !== 120) {
5562
- console.warn(
5563
- "[dawcore] Adapter does not implement setTempo. Initial BPM " + this._bpm + " will not be applied \u2014 clips may use wrong tempo."
5564
- );
5564
+ if (!this._hasTickCallbacks) {
5565
+ if (adapter.setTempo) {
5566
+ adapter.setTempo(this._bpm);
5567
+ } else if (this._bpm !== 120) {
5568
+ console.warn(
5569
+ "[dawcore] Adapter does not implement setTempo. Initial BPM " + this._bpm + " will not be applied \u2014 clips may use wrong tempo."
5570
+ );
5571
+ }
5565
5572
  }
5566
5573
  adapter.setPpqn?.(this._ppqn);
5567
5574
  this.ppqn = adapter.ppqn;
@@ -6097,12 +6104,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
6097
6104
  const playhead = this._getPlayhead();
6098
6105
  if (!playhead || !this._engine) return;
6099
6106
  const engine = this._engine;
6100
- const ctx = this.audioContext;
6101
- const audibleTime = () => {
6102
- const outputLatency = "outputLatency" in ctx ? ctx.outputLatency : 0;
6103
- const t = engine.getCurrentTime() - outputLatency - engine.lookAhead;
6104
- return Number.isFinite(t) ? Math.max(0, t) : 0;
6105
- };
6107
+ const audibleTime = () => engine.getAudibleTime();
6106
6108
  if (this.scaleMode === "beats") {
6107
6109
  const secondsToTicksFn = (s) => this._secondsToTicks(s);
6108
6110
  playhead.startBeatsAnimationWithMap(audibleTime, secondsToTicksFn, this.ticksPerPixel);
@@ -6113,10 +6115,7 @@ var DawEditorElement = class extends import_lit15.LitElement {
6113
6115
  _stopPlayhead() {
6114
6116
  const playhead = this._getPlayhead();
6115
6117
  if (!playhead) return;
6116
- const ctx = this.audioContext;
6117
- const outputLatency = "outputLatency" in ctx ? ctx.outputLatency : 0;
6118
- const lookAhead = this._engine?.lookAhead ?? 0;
6119
- const t = this._currentTime - outputLatency - lookAhead;
6118
+ const t = this._currentTime;
6120
6119
  const visualTime = Number.isFinite(t) ? Math.max(0, t) : 0;
6121
6120
  if (this.scaleMode === "beats") {
6122
6121
  playhead.stopBeatsAnimationWithMap(