@waveform-playlist/core 13.0.0-next.1 → 13.0.0-next.10
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/README.md +17 -7
- package/dist/index.d.mts +180 -26
- package/dist/index.d.ts +180 -26
- package/dist/index.js +238 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +229 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,6 +13,7 @@ Used by nearly every `@waveform-playlist/*` and `@dawcore/*` package (`engine`,
|
|
|
13
13
|
- **Peaks generation** — real-time min/max peak extraction during recording
|
|
14
14
|
- **Musical time** — PPQN tick math, bar/beat conversion, time-signature meter detection, grid snapping
|
|
15
15
|
- **Keyboard shortcuts** — a framework-agnostic shortcut matcher shared by the React and Web Components layers
|
|
16
|
+
- **Annotation store** — `createAnnotationStore`, the one owner of a list of annotations that both React providers take as `annotationStore`: `set` / `update` apply at once, every list is validated, and an optional `beforeChange` rule can accept, refuse or adjust each change
|
|
16
17
|
- **Spectrogram canvas-ID contract** — canonical build/parse helpers for the `${clipId}-ch${n}-chunk${m}` canvas ID format shared by the worker pool and rendering layers
|
|
17
18
|
- **HTTP range support probing** — detect whether an audio host supports byte-range seeking
|
|
18
19
|
|
|
@@ -62,17 +63,20 @@ parseSpectrogramCanvasId(id);
|
|
|
62
63
|
| `clipTimeHelpers` | `clipStartTime`, `clipEndTime`, `clipOffsetTime`, `clipDurationTime`, `clipPixelWidth`, `trackChannelCount` |
|
|
63
64
|
| clip constructors (`types/clip`) | `createClip`, `createClipFromSeconds`, `createClipFromTicks`, `createTrack`, `createTimeline`, `getClipsInRange`, `getClipsAtSample`, `clipsOverlap`, `sortClipsByTime`, `findGaps` |
|
|
64
65
|
| `fades` | `applyFadeIn`, `applyFadeOut`, `generateCurve`, `linearCurve`, `exponentialCurve`, `logarithmicCurve`, `sCurveCurve` |
|
|
65
|
-
| `panStage` | `createPanStage`, `panMatrix`, `PanStage`, `PanMatrix`, `PanStageContext` |
|
|
66
|
+
| `panStage` | `createPanStage`, `panMatrix`, `PAN_LAW_RAMP_SECONDS`, `PanStage`, `PanMatrix`, `PanStageContext` |
|
|
67
|
+
| `panLaw` | `PanLaw`, `DecidedPanLaw`, `DEFAULT_PAN_LAW`, `isDecidedPanLaw`, `audioPanLaw`, `trackPanLaw`, `TrackPanLawSource` |
|
|
66
68
|
| `utils/dBUtils` | `gainToDb`, `dBToNormalized`, `normalizedToDb`, `gainToNormalized` |
|
|
67
69
|
| `utils/conversions` | `samplesToSeconds`, `secondsToSamples`, `samplesToPixels`, `pixelsToSamples`, `pixelsToSeconds`, `secondsToPixels` |
|
|
68
70
|
| `utils/beatsAndBars` | `PPQN`, `ticksPerBeat`, `ticksPerBar`, `ticksToSamples`, `samplesToTicks`, `snapToGrid` |
|
|
69
71
|
| `utils/musicalTicks` | `computeMusicalTicks`, `snapToTicks`, `snapTickToGrid`, `SnapTo`, `MusicalTick` |
|
|
70
72
|
| `utils/meterDetection` | `MeterEntry`, `detectMeterChanges` |
|
|
71
73
|
| `utils/peaksGenerator` | `generatePeaks`, `appendPeaks` |
|
|
72
|
-
| `utils/audioBufferUtils` | `concatenateAudioData`, `createAudioBuffer`, `appendToAudioBuffer
|
|
74
|
+
| `utils/audioBufferUtils` | `concatenateAudioData`, `createAudioBuffer`, `appendToAudioBuffer` |
|
|
73
75
|
| `utils/latency` | `resolveRecordingOffsetSamples` — override-vs-auto recording latency compensation (shared by React + dawcore) |
|
|
74
76
|
| `utils/carveClipRange` | `carveClipRange` — punch-in replace: carve a sample range out of a clip list (trim/remove/split) |
|
|
75
77
|
| `keyboard` | `KeyboardShortcut`, `handleKeyboardEvent` |
|
|
78
|
+
| `annotations/store` | `createAnnotationStore`, `AnnotationStore`, `AnnotationStoreOptions` |
|
|
79
|
+
| `annotations/bounds` | `applyAnnotationBounds`, `AnnotationBoundsChange` — write `start`/`end` onto annotations by id |
|
|
76
80
|
| `spectrogramCanvasId` | `buildSpectrogramCanvasId`, `parseSpectrogramCanvasId`, `SpectrogramCanvasIdParts`, `SpectrogramCanvasRegistration` |
|
|
77
81
|
| `probeRangeSupport` | `probeRangeSupport`, `RangeSupport` |
|
|
78
82
|
| `enumerateMicrophones` | `enumerateMicrophones`, `watchMicrophoneDevices`, `MicrophoneEnumeration` — permission-free device listing with `supported`/`hasLabels` flags (labels are browser-redacted pre-permission) |
|
|
@@ -88,17 +92,17 @@ MIT
|
|
|
88
92
|
|
|
89
93
|
## Pan stage
|
|
90
94
|
|
|
91
|
-
`createPanStage(audioContext, pan,
|
|
95
|
+
`createPanStage(audioContext, pan, panLaw)` builds a track's pan stage from plain gain, splitter and merger nodes. Every renderer in this project pans with it — the native transport, the Tone.js adapter and both offline exports — instead of a Web Audio `StereoPannerNode` or a Tone.js `Panner`.
|
|
92
96
|
|
|
93
97
|
```typescript
|
|
94
|
-
import { createPanStage,
|
|
98
|
+
import { createPanStage, trackPanLaw } from '@waveform-playlist/core';
|
|
95
99
|
|
|
96
|
-
const stage = createPanStage(audioContext, track.pan,
|
|
100
|
+
const stage = createPanStage(audioContext, track.pan, trackPanLaw(track)); // 'mono' | 'stereo'
|
|
97
101
|
faderNode.connect(stage.input);
|
|
98
102
|
stage.output.connect(muteNode);
|
|
99
103
|
|
|
100
104
|
stage.setPan(-0.5);
|
|
101
|
-
stage.
|
|
105
|
+
stage.setPanLaw('stereo'); // the four gains ramp over 10 ms
|
|
102
106
|
stage.dispose();
|
|
103
107
|
```
|
|
104
108
|
|
|
@@ -107,7 +111,13 @@ Why not the built-in nodes:
|
|
|
107
111
|
- **`StereoPannerNode`** chooses its pan law from the signal it receives: equal-power for mono input (−3 dB per side at centre), the stereo law for stereo input (unity at centre). Track effects are pre-fader inserts, so the panner would be fed by the effects chain and the law would follow the chain's output: a mono track would jump about 3 dB at centre as soon as a stereo effect was added.
|
|
108
112
|
- **Tone.js `Panner`** wraps a `StereoPannerNode` with a fixed channel count. On Tone's default context (standardized-audio-context) that setting cannot be changed, so a mono track's panner is locked to one channel and a stereo effect on the track is summed to mono before it is panned.
|
|
109
113
|
|
|
110
|
-
The stage implements the same two laws as `StereoPannerNode` (`panMatrix(pan,
|
|
114
|
+
The stage implements the same two laws as `StereoPannerNode` (`panMatrix(pan, panLaw)` is the pure math) but takes the law from the caller and always passes stereo through. It works on any `AudioContext` or `OfflineAudioContext`, and on the raw context behind Tone.js.
|
|
115
|
+
|
|
116
|
+
### A track's pan law
|
|
117
|
+
|
|
118
|
+
`PanLaw` is `'auto' | 'mono' | 'stereo'`. `'mono'` is equal power (−3 dB per side at centre, the channels never mixed); `'stereo'` is unity at centre with fold-over; `'auto'` means not decided yet. `ClipTrack.panLaw` is the law a track enters an arrangement with (default `'auto'`), and `audioTrack({ panLaw })` sets it.
|
|
119
|
+
|
|
120
|
+
`trackPanLaw(track)` is the law a renderer pans a track with: the track's own when it is `'mono'` or `'stereo'`, else the law of its clips (`audioPanLaw(track)`: `'stereo'` if a clip's buffer has two or more channels, `'mono'` if a clip has a buffer), else `'mono'`. In an arrangement (`@waveform-playlist/engine`) the law is a mixer value that the track's first decoded audio decides and its clips never change afterwards. The law converts no audio.
|
|
111
121
|
|
|
112
122
|
## Effect registry
|
|
113
123
|
|
package/dist/index.d.mts
CHANGED
|
@@ -81,12 +81,48 @@ type SpectrogramDisplayConfig = Pick<SpectrogramConfig, 'frequencyScale' | 'minF
|
|
|
81
81
|
* mode: it is always drawn as a piano roll.
|
|
82
82
|
*/
|
|
83
83
|
type RenderMode = 'waveform' | 'spectrogram' | 'both';
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A track's pan law (#684).
|
|
87
|
+
*
|
|
88
|
+
* - `'mono'`: equal power, −3 dB per side at centre; the channels are never
|
|
89
|
+
* mixed.
|
|
90
|
+
* - `'stereo'`: unity at centre; panning folds one channel into the other.
|
|
91
|
+
* - `'auto'`: not decided yet. It is the default, and the first decoded
|
|
92
|
+
* audio a track holds decides it (an arrangement stores the result as a
|
|
93
|
+
* mixer value, and a track's clips never change it afterwards).
|
|
94
|
+
*
|
|
95
|
+
* The law says how a track is panned. It converts nothing: a stereo clip on
|
|
96
|
+
* a `'mono'` track still plays in stereo.
|
|
97
|
+
*/
|
|
98
|
+
type PanLaw = 'auto' | 'mono' | 'stereo';
|
|
99
|
+
/** A law a pan stage can apply: every `PanLaw` except `'auto'`. */
|
|
100
|
+
type DecidedPanLaw = Exclude<PanLaw, 'auto'>;
|
|
101
|
+
declare const DEFAULT_PAN_LAW: PanLaw;
|
|
102
|
+
/** True for `'mono'` and `'stereo'` only; any other value, of any type, is not a decided law. */
|
|
103
|
+
declare function isDecidedPanLaw(value: unknown): value is DecidedPanLaw;
|
|
104
|
+
/** The part of a track `trackPanLaw` reads: `ClipTrack` satisfies it. */
|
|
105
|
+
interface TrackPanLawSource {
|
|
106
|
+
panLaw?: PanLaw;
|
|
107
|
+
clips: ReadonlyArray<{
|
|
108
|
+
audioBuffer?: {
|
|
109
|
+
numberOfChannels: number;
|
|
110
|
+
};
|
|
111
|
+
}>;
|
|
89
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* The law of the decoded audio a track holds: `'stereo'` when any clip's
|
|
115
|
+
* buffer has two or more channels, `'mono'` when at least one clip has a
|
|
116
|
+
* buffer, `null` when none has (an empty track, loading clips, MIDI clips,
|
|
117
|
+
* clips made from peaks alone).
|
|
118
|
+
*/
|
|
119
|
+
declare function audioPanLaw(track: Pick<TrackPanLawSource, 'clips'>): DecidedPanLaw | null;
|
|
120
|
+
/**
|
|
121
|
+
* The law a renderer pans a track with: the track's own when it is decided;
|
|
122
|
+
* else (`'auto'`, no field, or a value that is not a law) the law of its
|
|
123
|
+
* audio; else `'mono'`.
|
|
124
|
+
*/
|
|
125
|
+
declare function trackPanLaw(track: TrackPanLawSource): DecidedPanLaw;
|
|
90
126
|
|
|
91
127
|
/**
|
|
92
128
|
* Clip-Based Model Types
|
|
@@ -235,6 +271,18 @@ interface LoadingClip {
|
|
|
235
271
|
/** Pre-computed peaks, drawn while the audio loads */
|
|
236
272
|
waveformData?: WaveformDataObject;
|
|
237
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* The fields of a track that say how it is drawn, not how it plays. An
|
|
276
|
+
* adapter is never given them (`PlayoutTrack`), and the engine makes no
|
|
277
|
+
* adapter call for a change of these fields alone: on the native transport an
|
|
278
|
+
* `updateTrack` stops the track's playing sources (silent until its next
|
|
279
|
+
* clip), so a render-mode choice during playback silenced it (review of #930). The one list; the engine reads it.
|
|
280
|
+
*/
|
|
281
|
+
declare const TRACK_VIEW_FIELDS: readonly ["name", "color", "height", "renderMode", "spectrogramConfig", "spectrogramColorMap"];
|
|
282
|
+
/** A field of `TRACK_VIEW_FIELDS`. */
|
|
283
|
+
type TrackViewField = (typeof TRACK_VIEW_FIELDS)[number];
|
|
284
|
+
/** A track as a playout adapter is given it: a `ClipTrack` without the view fields. */
|
|
285
|
+
type PlayoutTrack = Omit<ClipTrack, TrackViewField>;
|
|
238
286
|
/** A track whose clips are loaded (`AudioClip`) or not loaded yet (`LoadingClip`). */
|
|
239
287
|
type ArrangementTrack = Omit<ClipTrack, 'clips'> & {
|
|
240
288
|
clips: (AudioClip | LoadingClip)[];
|
|
@@ -268,6 +316,12 @@ interface ClipTrack {
|
|
|
268
316
|
volume: number;
|
|
269
317
|
/** Stereo pan (-1.0 = left, 0 = center, 1.0 = right) */
|
|
270
318
|
pan: number;
|
|
319
|
+
/**
|
|
320
|
+
* The pan law this track enters with (default `'auto'`: decided by its
|
|
321
|
+
* first decoded audio). While the track is in an arrangement, the
|
|
322
|
+
* arrangement's mixer holds the value (#684).
|
|
323
|
+
*/
|
|
324
|
+
panLaw?: PanLaw;
|
|
271
325
|
/** Optional track color for visual distinction */
|
|
272
326
|
color?: string;
|
|
273
327
|
/** Track height in pixels (for UI) */
|
|
@@ -513,7 +567,7 @@ interface AnnotationData {
|
|
|
513
567
|
interface AnnotationFormat {
|
|
514
568
|
name: string;
|
|
515
569
|
parse: (data: unknown) => AnnotationData[];
|
|
516
|
-
serialize: (annotations: AnnotationData[]) => unknown;
|
|
570
|
+
serialize: (annotations: readonly AnnotationData[]) => unknown;
|
|
517
571
|
}
|
|
518
572
|
/**
|
|
519
573
|
* Options for annotation list behavior
|
|
@@ -876,10 +930,6 @@ declare function createAudioBuffer(audioContext: AudioContext, channelData: Floa
|
|
|
876
930
|
* Append new samples to an existing AudioBuffer (mono convenience)
|
|
877
931
|
*/
|
|
878
932
|
declare function appendToAudioBuffer(audioContext: AudioContext, existingBuffer: AudioBuffer | null, newSamples: Float32Array, sampleRate: number): AudioBuffer;
|
|
879
|
-
/**
|
|
880
|
-
* Calculate duration in seconds from sample count and sample rate
|
|
881
|
-
*/
|
|
882
|
-
declare function calculateDuration(sampleCount: number, sampleRate: number): number;
|
|
883
933
|
|
|
884
934
|
/**
|
|
885
935
|
* Sample count corresponding to the audible-latency window
|
|
@@ -1065,8 +1115,8 @@ interface TrackChannelSource {
|
|
|
1065
1115
|
}
|
|
1066
1116
|
/**
|
|
1067
1117
|
* Max audio channel count across a track's clips (1 for a track with no
|
|
1068
|
-
* decoded audio).
|
|
1069
|
-
*
|
|
1118
|
+
* decoded audio). Read for the React export's output channels. The track's
|
|
1119
|
+
* pan law is not chosen from it: that is `trackPanLaw(track)` (#684).
|
|
1070
1120
|
*/
|
|
1071
1121
|
declare function trackChannelCount(track: TrackChannelSource): number;
|
|
1072
1122
|
/**
|
|
@@ -1257,7 +1307,9 @@ declare function keyBelongsToFocusedControl(event: KeyboardEvent): boolean;
|
|
|
1257
1307
|
* Pure function, no framework dependency.
|
|
1258
1308
|
*
|
|
1259
1309
|
* Shortcuts do not fire for a key the focused control uses itself; see
|
|
1260
|
-
* `keyBelongsToFocusedControl`.
|
|
1310
|
+
* `keyBelongsToFocusedControl`. Nor for an Escape whose default something
|
|
1311
|
+
* other than a shortcut already prevented (a drag cancelled it): an Escape that
|
|
1312
|
+
* cancelled a drag does nothing else.
|
|
1261
1313
|
*/
|
|
1262
1314
|
declare function handleKeyboardEvent(event: KeyboardEvent, shortcuts: KeyboardShortcut[], enabled: boolean): void;
|
|
1263
1315
|
|
|
@@ -1354,7 +1406,7 @@ interface AnnotationBoundaryUpdate {
|
|
|
1354
1406
|
annotationIndex: number;
|
|
1355
1407
|
newTime: number;
|
|
1356
1408
|
isDraggingStart: boolean;
|
|
1357
|
-
annotations: AnnotationData[];
|
|
1409
|
+
annotations: readonly AnnotationData[];
|
|
1358
1410
|
duration: number;
|
|
1359
1411
|
linkEndpoints: boolean;
|
|
1360
1412
|
}
|
|
@@ -1390,6 +1442,61 @@ declare function resolveAnnotationShortcuts(remap: AnnotationShortcutMap | null)
|
|
|
1390
1442
|
binding: KeyBinding;
|
|
1391
1443
|
}>;
|
|
1392
1444
|
|
|
1445
|
+
/**
|
|
1446
|
+
* The owner of a list of annotations. The app makes one and gives it to a
|
|
1447
|
+
* provider; everything that reads the annotations reads them here, and every
|
|
1448
|
+
* change is a call to `set` or `update`.
|
|
1449
|
+
*/
|
|
1450
|
+
interface AnnotationStore {
|
|
1451
|
+
/**
|
|
1452
|
+
* The current annotations. The same array until a change. Never write to
|
|
1453
|
+
* it: outside production builds it is frozen.
|
|
1454
|
+
*/
|
|
1455
|
+
getAnnotations(): readonly AnnotationData[];
|
|
1456
|
+
/** Be told after every change. Returns the function that unsubscribes. */
|
|
1457
|
+
subscribe(listener: () => void): () => void;
|
|
1458
|
+
/** Replace the annotations. */
|
|
1459
|
+
set(annotations: readonly AnnotationData[]): void;
|
|
1460
|
+
/**
|
|
1461
|
+
* Change the annotations: `fn` gets the current array and returns the next.
|
|
1462
|
+
* The change is applied before `update` returns, so the next call's
|
|
1463
|
+
* `current` already holds it. Returning `current` changes nothing.
|
|
1464
|
+
*/
|
|
1465
|
+
update(fn: (current: readonly AnnotationData[]) => readonly AnnotationData[]): void;
|
|
1466
|
+
}
|
|
1467
|
+
interface AnnotationStoreOptions {
|
|
1468
|
+
/**
|
|
1469
|
+
* The app's rule for every change. Gets the proposed list and the current
|
|
1470
|
+
* one, returns the list to store: `next` to accept, `current` to refuse,
|
|
1471
|
+
* or another list to adjust (e.g. clamp an edge so it does not overlap).
|
|
1472
|
+
* Not called for the initial list. A throw from it reaches the caller of
|
|
1473
|
+
* `set` or `update`, and the store keeps its value.
|
|
1474
|
+
*/
|
|
1475
|
+
beforeChange?: (next: readonly AnnotationData[], current: readonly AnnotationData[]) => readonly AnnotationData[];
|
|
1476
|
+
}
|
|
1477
|
+
/**
|
|
1478
|
+
* Make an annotation store holding `initial` (empty when absent). Throws a
|
|
1479
|
+
* `TypeError` for an invalid list: an annotation without numeric `start` and
|
|
1480
|
+
* `end`, or two with one id.
|
|
1481
|
+
*/
|
|
1482
|
+
declare function createAnnotationStore(initial?: readonly AnnotationData[], options?: AnnotationStoreOptions): AnnotationStore;
|
|
1483
|
+
|
|
1484
|
+
/** New bounds for the annotation with `id`. */
|
|
1485
|
+
interface AnnotationBoundsChange {
|
|
1486
|
+
id: string;
|
|
1487
|
+
start: number;
|
|
1488
|
+
end: number;
|
|
1489
|
+
}
|
|
1490
|
+
/**
|
|
1491
|
+
* Write `start` and `end` of each change onto the annotation with that id in
|
|
1492
|
+
* `current`. Every other field, and every annotation no change names, is kept
|
|
1493
|
+
* as it is (the same object). An id that is not in `current` is skipped.
|
|
1494
|
+
*
|
|
1495
|
+
* Returns `current` itself when nothing changes, so an `update` with it
|
|
1496
|
+
* notifies nobody.
|
|
1497
|
+
*/
|
|
1498
|
+
declare function applyAnnotationBounds(current: readonly AnnotationData[], changes: readonly AnnotationBoundsChange[]): readonly AnnotationData[];
|
|
1499
|
+
|
|
1393
1500
|
/** Gains of the pan matrix: `out = [[ll, rl], [lr, rr]] · in`, where e.g.
|
|
1394
1501
|
* `rl` is how much of the input's RIGHT channel reaches the LEFT output. */
|
|
1395
1502
|
interface PanMatrix {
|
|
@@ -1399,40 +1506,47 @@ interface PanMatrix {
|
|
|
1399
1506
|
rr: number;
|
|
1400
1507
|
}
|
|
1401
1508
|
/**
|
|
1402
|
-
* The pan law
|
|
1403
|
-
*
|
|
1509
|
+
* The gains of a pan law at a pan position: exactly the two algorithms of
|
|
1510
|
+
* the Web Audio `StereoPannerNode`. Which law a track has is the track's own
|
|
1511
|
+
* value (`trackPanLaw`), not a property of the signal that reaches the stage.
|
|
1404
1512
|
*
|
|
1405
|
-
* -
|
|
1513
|
+
* - `'mono'` — equal-power pan, θ = (pan + 1)·π/4: L × cos θ, R × sin θ.
|
|
1406
1514
|
* For a mono signal (taken as L = R) that is the mono law, L = m·cos θ and
|
|
1407
1515
|
* R = m·sin θ: −3 dB per side at centre. A stereo signal from the track's
|
|
1408
1516
|
* effects is balanced by the same gains, so it stays stereo at the same
|
|
1409
1517
|
* centre level as the dry signal.
|
|
1410
|
-
* -
|
|
1518
|
+
* - `'stereo'` — the stereo law: centre passes both channels at unity;
|
|
1411
1519
|
* panning left folds the right channel into the left
|
|
1412
1520
|
* (L + R·cos x, R·sin x with x = (pan + 1)·π/2), and symmetrically right.
|
|
1413
1521
|
*
|
|
1414
1522
|
* `pan` is clamped to −1 … 1; a non-finite value is treated as centre.
|
|
1415
1523
|
*/
|
|
1416
|
-
declare function panMatrix(pan: number,
|
|
1524
|
+
declare function panMatrix(pan: number, panLaw: DecidedPanLaw): PanMatrix;
|
|
1417
1525
|
/**
|
|
1418
1526
|
* The part of an audio context the pan stage needs. Any `AudioContext` or
|
|
1419
1527
|
* `OfflineAudioContext` satisfies it, and so does the `rawContext` behind
|
|
1420
1528
|
* Tone.js (native or standardized-audio-context).
|
|
1421
1529
|
*/
|
|
1422
|
-
type PanStageContext = Pick<BaseAudioContext, 'createGain' | 'createChannelSplitter' | 'createChannelMerger'>;
|
|
1530
|
+
type PanStageContext = Pick<BaseAudioContext, 'createGain' | 'createChannelSplitter' | 'createChannelMerger' | 'currentTime'>;
|
|
1531
|
+
/** How long a switch of pan law takes: the four gains ramp, so a switch during playback does not click (#684). */
|
|
1532
|
+
declare const PAN_LAW_RAMP_SECONDS = 0.01;
|
|
1423
1533
|
/** A track's pan stage: `input → … → output`, with `setPan(-1 … 1)`. */
|
|
1424
1534
|
interface PanStage {
|
|
1425
1535
|
readonly input: AudioNode;
|
|
1426
1536
|
readonly output: AudioNode;
|
|
1427
1537
|
setPan(pan: number): void;
|
|
1428
|
-
/**
|
|
1429
|
-
|
|
1538
|
+
/**
|
|
1539
|
+
* Switch the pan law, keeping the pan. The four gains ramp to the new
|
|
1540
|
+
* matrix over `PAN_LAW_RAMP_SECONDS`; the law the stage already has does
|
|
1541
|
+
* nothing.
|
|
1542
|
+
*/
|
|
1543
|
+
setPanLaw(panLaw: DecidedPanLaw): void;
|
|
1430
1544
|
/** Disconnect every node of the stage. */
|
|
1431
1545
|
dispose(): void;
|
|
1432
1546
|
}
|
|
1433
1547
|
/**
|
|
1434
|
-
* Build the pan stage for a track
|
|
1435
|
-
* `
|
|
1548
|
+
* Build the pan stage for a track with the pan law `panLaw` (core's
|
|
1549
|
+
* `trackPanLaw(track)`; `'mono'` for synth voices).
|
|
1436
1550
|
*
|
|
1437
1551
|
* Why this is not a `StereoPannerNode`: a track's pan stage is fed by its
|
|
1438
1552
|
* effects chain (pre-fader inserts), whose channel layout is not the
|
|
@@ -1446,7 +1560,7 @@ interface PanStage {
|
|
|
1446
1560
|
* nodes — none of which is restricted — so it behaves identically on every
|
|
1447
1561
|
* context, always passes stereo through, and takes its law from the caller.
|
|
1448
1562
|
*/
|
|
1449
|
-
declare function createPanStage(context: PanStageContext, pan: number,
|
|
1563
|
+
declare function createPanStage(context: PanStageContext, pan: number, panLaw: DecidedPanLaw): PanStage;
|
|
1450
1564
|
|
|
1451
1565
|
type SourceState<V> = {
|
|
1452
1566
|
status: 'pending';
|
|
@@ -1511,6 +1625,8 @@ interface AudioTrackOptions {
|
|
|
1511
1625
|
soloed?: boolean;
|
|
1512
1626
|
volume?: number;
|
|
1513
1627
|
pan?: number;
|
|
1628
|
+
/** The pan law the track enters with. Default: 'auto', decided by its first decoded audio. */
|
|
1629
|
+
panLaw?: PanLaw;
|
|
1514
1630
|
renderMode?: RenderMode;
|
|
1515
1631
|
spectrogramConfig?: SpectrogramConfig;
|
|
1516
1632
|
spectrogramColorMap?: ColorMapValue;
|
|
@@ -1523,6 +1639,44 @@ interface AudioTrackOptions {
|
|
|
1523
1639
|
*/
|
|
1524
1640
|
declare function audioTrack(options: AudioTrackOptions): ArrangementTrack;
|
|
1525
1641
|
|
|
1642
|
+
/**
|
|
1643
|
+
* One gesture on a mixer control (a fader drag, a held arrow key) as one
|
|
1644
|
+
* undo step (#843). The mixer setters join changes that carry the same
|
|
1645
|
+
* `gesture` id into one step; this helper makes the id, and ends the gesture
|
|
1646
|
+
* so that the next change starts a new one.
|
|
1647
|
+
*
|
|
1648
|
+
* Framework-free: React's sliders and dawcore's elements both use it. One
|
|
1649
|
+
* helper per control, so two sliders never share an id. It lives in core,
|
|
1650
|
+
* not beside the setters in the engine, because `<daw-editor>` loads the
|
|
1651
|
+
* engine with a dynamic `import()`: a value import of the engine would put
|
|
1652
|
+
* it back in dawcore's first bundle.
|
|
1653
|
+
*/
|
|
1654
|
+
interface MixerGesture {
|
|
1655
|
+
/** The id to pass while a gesture is going on. */
|
|
1656
|
+
readonly id: string;
|
|
1657
|
+
/** The gesture is over: the next change starts a new one. */
|
|
1658
|
+
end(): void;
|
|
1659
|
+
/** Ends the gesture on the input's own events; returns the detach function. */
|
|
1660
|
+
attach(input: HTMLInputElement): () => void;
|
|
1661
|
+
}
|
|
1662
|
+
/**
|
|
1663
|
+
* Make the gesture helper of one mixer control.
|
|
1664
|
+
*
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* const gesture = createMixerGesture();
|
|
1667
|
+
* const detach = gesture.attach(slider);
|
|
1668
|
+
* slider.addEventListener('input', () =>
|
|
1669
|
+
* engine.setTrackVolume(trackId, slider.valueAsNumber, { gesture: gesture.id })
|
|
1670
|
+
* );
|
|
1671
|
+
* ```
|
|
1672
|
+
*
|
|
1673
|
+
* `attach` ends the gesture on the input's `change` (the end of a pointer
|
|
1674
|
+
* drag), except while a key that moves the input is held down; then on that
|
|
1675
|
+
* key's `keyup`. A `blur` ends it too. Mute and solo buttons need no helper:
|
|
1676
|
+
* each click is a step of its own.
|
|
1677
|
+
*/
|
|
1678
|
+
declare function createMixerGesture(): MixerGesture;
|
|
1679
|
+
|
|
1526
1680
|
/**
|
|
1527
1681
|
* The effect registry shared by `<daw-editor>` and the React effects hooks:
|
|
1528
1682
|
* one `registerEffect()` call makes a custom effect (an AudioWorklet, or any
|
|
@@ -1631,4 +1785,4 @@ declare function needsPrepare(type: string, audioContext: BaseAudioContext): boo
|
|
|
1631
1785
|
declare function ensureEffectPrepared(type: string, audioContext: BaseAudioContext): Promise<void>;
|
|
1632
1786
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedNativeEffect;
|
|
1633
1787
|
|
|
1634
|
-
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_SPECTROGRAM_COLOR_MAP, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PPQN, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type PlaylistConfig, type PlayoutState, type RangeSupport, type ReadMeterMessageParams, type RecordingProgress, type RecordingProgressSource, type RenderAnnotationItemProps, type RenderMode, SPECTROGRAM_DEFAULTS, type SnapTo, type SourceLoader, type SourceState, type SpectrogramCanvasIdParts, type SpectrogramCanvasRegistration, type SpectrogramComputeConfig, type SpectrogramConfig, type SpectrogramData, type SpectrogramDisplayConfig, type TickType, type TimeSelection, type Timeline, type Track, type TrackChannelSource, type TrackKind, type
|
|
1788
|
+
export { ANNOTATION_LINK_THRESHOLD_TICKS, type AnnotationAction, type AnnotationActionOptions, type AnnotationBoundaryOptions, type AnnotationBoundaryUpdate, type AnnotationBoundsChange, type AnnotationData, type AnnotationEventMap, type AnnotationFormat, type AnnotationListOptions, type AnnotationShortcutAction, type AnnotationShortcutMap, type AnnotationStore, type AnnotationStoreOptions, type ArrangementTrack, type AudioBuffer$1 as AudioBuffer, type AudioClip, type AudioTrackOptions, type Bits, type ClipSource, type ClipTrack, type ColorMapEntry, type ColorMapName, type ColorMapValue, type CreateClipOptions, type CreateClipOptionsSeconds, type CreateClipOptionsTicks, type CreateTrackOptions, type CreatedNativeEffect, DEFAULT_ANNOTATION_SHORTCUTS, DEFAULT_PAN_LAW, DEFAULT_SPECTROGRAM_COLOR_MAP, type DecidedPanLaw, type EffectParamDef, type FFTSize, type Fade, type FadeConfig, type FadeType, type Gap, InteractionState, type KeyBinding, type KeyboardShortcut, LINK_THRESHOLD, type LoadingClip, MAX_CANVAS_WIDTH, METER_PEAK_DECAY, MIN_ANNOTATION_DURATION, MIN_PIXELS_PER_UNIT, type MeterEntry, type MeterLevels, type MeterReading, type MeterSource, type MicrophoneDeviceInfo, type MicrophoneEnumeration, type MidiNoteData, type MixerGesture, type MusicalTick, type MusicalTickData, type MusicalTickParams, type NativeEffectDefinition, type NativeEffectInstance, PAN_LAW_RAMP_SECONDS, PPQN, type PanLaw, type PanMatrix, type PanStage, type PanStageContext, type PeakData, type Peaks, type PlaylistConfig, type PlayoutState, type PlayoutTrack, type RangeSupport, type ReadMeterMessageParams, type RecordingProgress, type RecordingProgressSource, type RenderAnnotationItemProps, type RenderMode, SPECTROGRAM_DEFAULTS, type SnapTo, type SourceLoader, type SourceState, type SpectrogramCanvasIdParts, type SpectrogramCanvasRegistration, type SpectrogramComputeConfig, type SpectrogramConfig, type SpectrogramData, type SpectrogramDisplayConfig, TRACK_VIEW_FIELDS, type TickType, type TimeSelection, type Timeline, type Track, type TrackChannelSource, type TrackKind, type TrackPanLawSource, type TrackViewField, type ValueSource, type ValueSourceHandle, type WaveformConfig, type WaveformDataObject, type ZoomLevel, annotationMinDurationTicks, appendPeaks, appendToAudioBuffer, applyAnnotationBounds, applyFadeIn, applyFadeOut, assertTrackKind, audibleLatencySamples, audioPanLaw, audioTrack, buildSpectrogramCanvasId, carveClipRange, clipDurationTime, clipEndTime, clipKind, clipOffsetTime, clipPixelWidth, clipStartTime, clipsOverlap, computeMusicalTicks, concatenateAudioData, createAnnotationStore, createAudioBuffer, createClip, createClipFromSeconds, createClipFromTicks, createEffectInstance, createMixerGesture, createPanStage, createSourceLoader, createTimeline, createTrack, createValueSource, dBToNormalized, detectMeterChanges, ensureEffectPrepared, enumerateMicrophones, exponentialCurve, findGaps, gainToDb, gainToNormalized, generateCurve, generatePeaks, getClipsAtSample, getClipsInRange, getEffectDefinitions, handleKeyboardEvent, isDecidedPanLaw, isLoadingClip, keyBelongsToFocusedControl, linearCurve, logarithmicCurve, matchesKeyBinding, needsPrepare, normalizedToDb, panMatrix, parseSpectrogramCanvasId, pixelsToSamples, pixelsToSeconds, prepareEffect, probeRangeSupport, readMeterMessage, registerEffect, resolveAnnotationShortcuts, resolveRecordingOffsetSamples, sCurveCurve, samplesToPixels, samplesToSeconds, samplesToTicks, secondsToPixels, secondsToSamples, silentMeterLevels, snapTickToGrid, snapToGrid, snapToTicks, sortClipsByTime, splitTrackByKind, ticksPerBar, ticksPerBeat, ticksToBarBeat, ticksToSamples, trackChannelCount, trackKind, trackPanLaw, unregisterEffect, updateAnnotationBoundaries, watchMicrophoneDevices };
|