@waveform-playlist/core 13.0.0-next.1 → 13.0.0-next.11
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 -43
- package/dist/index.d.ts +180 -43
- 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
|
|
@@ -627,23 +681,6 @@ type FadeType = 'logarithmic' | 'linear' | 'sCurve' | 'exponential';
|
|
|
627
681
|
* Alias for Fade — used by media-element-playout and playout packages
|
|
628
682
|
*/
|
|
629
683
|
type FadeConfig = Fade;
|
|
630
|
-
interface PlaylistConfig {
|
|
631
|
-
samplesPerPixel?: number;
|
|
632
|
-
waveHeight?: number;
|
|
633
|
-
container?: HTMLElement;
|
|
634
|
-
isAutomaticScroll?: boolean;
|
|
635
|
-
timescale?: boolean;
|
|
636
|
-
colors?: {
|
|
637
|
-
waveOutlineColor?: string;
|
|
638
|
-
waveFillColor?: string;
|
|
639
|
-
waveProgressColor?: string;
|
|
640
|
-
};
|
|
641
|
-
controls?: {
|
|
642
|
-
show?: boolean;
|
|
643
|
-
width?: number;
|
|
644
|
-
};
|
|
645
|
-
zoomLevels?: number[];
|
|
646
|
-
}
|
|
647
684
|
interface PlayoutState {
|
|
648
685
|
isPlaying: boolean;
|
|
649
686
|
isPaused: boolean;
|
|
@@ -876,10 +913,6 @@ declare function createAudioBuffer(audioContext: AudioContext, channelData: Floa
|
|
|
876
913
|
* Append new samples to an existing AudioBuffer (mono convenience)
|
|
877
914
|
*/
|
|
878
915
|
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
916
|
|
|
884
917
|
/**
|
|
885
918
|
* Sample count corresponding to the audible-latency window
|
|
@@ -1065,8 +1098,8 @@ interface TrackChannelSource {
|
|
|
1065
1098
|
}
|
|
1066
1099
|
/**
|
|
1067
1100
|
* Max audio channel count across a track's clips (1 for a track with no
|
|
1068
|
-
* decoded audio).
|
|
1069
|
-
*
|
|
1101
|
+
* decoded audio). Read for the React export's output channels. The track's
|
|
1102
|
+
* pan law is not chosen from it: that is `trackPanLaw(track)` (#684).
|
|
1070
1103
|
*/
|
|
1071
1104
|
declare function trackChannelCount(track: TrackChannelSource): number;
|
|
1072
1105
|
/**
|
|
@@ -1257,7 +1290,9 @@ declare function keyBelongsToFocusedControl(event: KeyboardEvent): boolean;
|
|
|
1257
1290
|
* Pure function, no framework dependency.
|
|
1258
1291
|
*
|
|
1259
1292
|
* Shortcuts do not fire for a key the focused control uses itself; see
|
|
1260
|
-
* `keyBelongsToFocusedControl`.
|
|
1293
|
+
* `keyBelongsToFocusedControl`. Nor for an Escape whose default something
|
|
1294
|
+
* other than a shortcut already prevented (a drag cancelled it): an Escape that
|
|
1295
|
+
* cancelled a drag does nothing else.
|
|
1261
1296
|
*/
|
|
1262
1297
|
declare function handleKeyboardEvent(event: KeyboardEvent, shortcuts: KeyboardShortcut[], enabled: boolean): void;
|
|
1263
1298
|
|
|
@@ -1354,7 +1389,7 @@ interface AnnotationBoundaryUpdate {
|
|
|
1354
1389
|
annotationIndex: number;
|
|
1355
1390
|
newTime: number;
|
|
1356
1391
|
isDraggingStart: boolean;
|
|
1357
|
-
annotations: AnnotationData[];
|
|
1392
|
+
annotations: readonly AnnotationData[];
|
|
1358
1393
|
duration: number;
|
|
1359
1394
|
linkEndpoints: boolean;
|
|
1360
1395
|
}
|
|
@@ -1390,6 +1425,61 @@ declare function resolveAnnotationShortcuts(remap: AnnotationShortcutMap | null)
|
|
|
1390
1425
|
binding: KeyBinding;
|
|
1391
1426
|
}>;
|
|
1392
1427
|
|
|
1428
|
+
/**
|
|
1429
|
+
* The owner of a list of annotations. The app makes one and gives it to a
|
|
1430
|
+
* provider; everything that reads the annotations reads them here, and every
|
|
1431
|
+
* change is a call to `set` or `update`.
|
|
1432
|
+
*/
|
|
1433
|
+
interface AnnotationStore {
|
|
1434
|
+
/**
|
|
1435
|
+
* The current annotations. The same array until a change. Never write to
|
|
1436
|
+
* it: outside production builds it is frozen.
|
|
1437
|
+
*/
|
|
1438
|
+
getAnnotations(): readonly AnnotationData[];
|
|
1439
|
+
/** Be told after every change. Returns the function that unsubscribes. */
|
|
1440
|
+
subscribe(listener: () => void): () => void;
|
|
1441
|
+
/** Replace the annotations. */
|
|
1442
|
+
set(annotations: readonly AnnotationData[]): void;
|
|
1443
|
+
/**
|
|
1444
|
+
* Change the annotations: `fn` gets the current array and returns the next.
|
|
1445
|
+
* The change is applied before `update` returns, so the next call's
|
|
1446
|
+
* `current` already holds it. Returning `current` changes nothing.
|
|
1447
|
+
*/
|
|
1448
|
+
update(fn: (current: readonly AnnotationData[]) => readonly AnnotationData[]): void;
|
|
1449
|
+
}
|
|
1450
|
+
interface AnnotationStoreOptions {
|
|
1451
|
+
/**
|
|
1452
|
+
* The app's rule for every change. Gets the proposed list and the current
|
|
1453
|
+
* one, returns the list to store: `next` to accept, `current` to refuse,
|
|
1454
|
+
* or another list to adjust (e.g. clamp an edge so it does not overlap).
|
|
1455
|
+
* Not called for the initial list. A throw from it reaches the caller of
|
|
1456
|
+
* `set` or `update`, and the store keeps its value.
|
|
1457
|
+
*/
|
|
1458
|
+
beforeChange?: (next: readonly AnnotationData[], current: readonly AnnotationData[]) => readonly AnnotationData[];
|
|
1459
|
+
}
|
|
1460
|
+
/**
|
|
1461
|
+
* Make an annotation store holding `initial` (empty when absent). Throws a
|
|
1462
|
+
* `TypeError` for an invalid list: an annotation without numeric `start` and
|
|
1463
|
+
* `end`, or two with one id.
|
|
1464
|
+
*/
|
|
1465
|
+
declare function createAnnotationStore(initial?: readonly AnnotationData[], options?: AnnotationStoreOptions): AnnotationStore;
|
|
1466
|
+
|
|
1467
|
+
/** New bounds for the annotation with `id`. */
|
|
1468
|
+
interface AnnotationBoundsChange {
|
|
1469
|
+
id: string;
|
|
1470
|
+
start: number;
|
|
1471
|
+
end: number;
|
|
1472
|
+
}
|
|
1473
|
+
/**
|
|
1474
|
+
* Write `start` and `end` of each change onto the annotation with that id in
|
|
1475
|
+
* `current`. Every other field, and every annotation no change names, is kept
|
|
1476
|
+
* as it is (the same object). An id that is not in `current` is skipped.
|
|
1477
|
+
*
|
|
1478
|
+
* Returns `current` itself when nothing changes, so an `update` with it
|
|
1479
|
+
* notifies nobody.
|
|
1480
|
+
*/
|
|
1481
|
+
declare function applyAnnotationBounds(current: readonly AnnotationData[], changes: readonly AnnotationBoundsChange[]): readonly AnnotationData[];
|
|
1482
|
+
|
|
1393
1483
|
/** Gains of the pan matrix: `out = [[ll, rl], [lr, rr]] · in`, where e.g.
|
|
1394
1484
|
* `rl` is how much of the input's RIGHT channel reaches the LEFT output. */
|
|
1395
1485
|
interface PanMatrix {
|
|
@@ -1399,40 +1489,47 @@ interface PanMatrix {
|
|
|
1399
1489
|
rr: number;
|
|
1400
1490
|
}
|
|
1401
1491
|
/**
|
|
1402
|
-
* The pan law
|
|
1403
|
-
*
|
|
1492
|
+
* The gains of a pan law at a pan position: exactly the two algorithms of
|
|
1493
|
+
* the Web Audio `StereoPannerNode`. Which law a track has is the track's own
|
|
1494
|
+
* value (`trackPanLaw`), not a property of the signal that reaches the stage.
|
|
1404
1495
|
*
|
|
1405
|
-
* -
|
|
1496
|
+
* - `'mono'` — equal-power pan, θ = (pan + 1)·π/4: L × cos θ, R × sin θ.
|
|
1406
1497
|
* For a mono signal (taken as L = R) that is the mono law, L = m·cos θ and
|
|
1407
1498
|
* R = m·sin θ: −3 dB per side at centre. A stereo signal from the track's
|
|
1408
1499
|
* effects is balanced by the same gains, so it stays stereo at the same
|
|
1409
1500
|
* centre level as the dry signal.
|
|
1410
|
-
* -
|
|
1501
|
+
* - `'stereo'` — the stereo law: centre passes both channels at unity;
|
|
1411
1502
|
* panning left folds the right channel into the left
|
|
1412
1503
|
* (L + R·cos x, R·sin x with x = (pan + 1)·π/2), and symmetrically right.
|
|
1413
1504
|
*
|
|
1414
1505
|
* `pan` is clamped to −1 … 1; a non-finite value is treated as centre.
|
|
1415
1506
|
*/
|
|
1416
|
-
declare function panMatrix(pan: number,
|
|
1507
|
+
declare function panMatrix(pan: number, panLaw: DecidedPanLaw): PanMatrix;
|
|
1417
1508
|
/**
|
|
1418
1509
|
* The part of an audio context the pan stage needs. Any `AudioContext` or
|
|
1419
1510
|
* `OfflineAudioContext` satisfies it, and so does the `rawContext` behind
|
|
1420
1511
|
* Tone.js (native or standardized-audio-context).
|
|
1421
1512
|
*/
|
|
1422
|
-
type PanStageContext = Pick<BaseAudioContext, 'createGain' | 'createChannelSplitter' | 'createChannelMerger'>;
|
|
1513
|
+
type PanStageContext = Pick<BaseAudioContext, 'createGain' | 'createChannelSplitter' | 'createChannelMerger' | 'currentTime'>;
|
|
1514
|
+
/** How long a switch of pan law takes: the four gains ramp, so a switch during playback does not click (#684). */
|
|
1515
|
+
declare const PAN_LAW_RAMP_SECONDS = 0.01;
|
|
1423
1516
|
/** A track's pan stage: `input → … → output`, with `setPan(-1 … 1)`. */
|
|
1424
1517
|
interface PanStage {
|
|
1425
1518
|
readonly input: AudioNode;
|
|
1426
1519
|
readonly output: AudioNode;
|
|
1427
1520
|
setPan(pan: number): void;
|
|
1428
|
-
/**
|
|
1429
|
-
|
|
1521
|
+
/**
|
|
1522
|
+
* Switch the pan law, keeping the pan. The four gains ramp to the new
|
|
1523
|
+
* matrix over `PAN_LAW_RAMP_SECONDS`; the law the stage already has does
|
|
1524
|
+
* nothing.
|
|
1525
|
+
*/
|
|
1526
|
+
setPanLaw(panLaw: DecidedPanLaw): void;
|
|
1430
1527
|
/** Disconnect every node of the stage. */
|
|
1431
1528
|
dispose(): void;
|
|
1432
1529
|
}
|
|
1433
1530
|
/**
|
|
1434
|
-
* Build the pan stage for a track
|
|
1435
|
-
* `
|
|
1531
|
+
* Build the pan stage for a track with the pan law `panLaw` (core's
|
|
1532
|
+
* `trackPanLaw(track)`; `'mono'` for synth voices).
|
|
1436
1533
|
*
|
|
1437
1534
|
* Why this is not a `StereoPannerNode`: a track's pan stage is fed by its
|
|
1438
1535
|
* effects chain (pre-fader inserts), whose channel layout is not the
|
|
@@ -1446,7 +1543,7 @@ interface PanStage {
|
|
|
1446
1543
|
* nodes — none of which is restricted — so it behaves identically on every
|
|
1447
1544
|
* context, always passes stereo through, and takes its law from the caller.
|
|
1448
1545
|
*/
|
|
1449
|
-
declare function createPanStage(context: PanStageContext, pan: number,
|
|
1546
|
+
declare function createPanStage(context: PanStageContext, pan: number, panLaw: DecidedPanLaw): PanStage;
|
|
1450
1547
|
|
|
1451
1548
|
type SourceState<V> = {
|
|
1452
1549
|
status: 'pending';
|
|
@@ -1511,6 +1608,8 @@ interface AudioTrackOptions {
|
|
|
1511
1608
|
soloed?: boolean;
|
|
1512
1609
|
volume?: number;
|
|
1513
1610
|
pan?: number;
|
|
1611
|
+
/** The pan law the track enters with. Default: 'auto', decided by its first decoded audio. */
|
|
1612
|
+
panLaw?: PanLaw;
|
|
1514
1613
|
renderMode?: RenderMode;
|
|
1515
1614
|
spectrogramConfig?: SpectrogramConfig;
|
|
1516
1615
|
spectrogramColorMap?: ColorMapValue;
|
|
@@ -1523,6 +1622,44 @@ interface AudioTrackOptions {
|
|
|
1523
1622
|
*/
|
|
1524
1623
|
declare function audioTrack(options: AudioTrackOptions): ArrangementTrack;
|
|
1525
1624
|
|
|
1625
|
+
/**
|
|
1626
|
+
* One gesture on a mixer control (a fader drag, a held arrow key) as one
|
|
1627
|
+
* undo step (#843). The mixer setters join changes that carry the same
|
|
1628
|
+
* `gesture` id into one step; this helper makes the id, and ends the gesture
|
|
1629
|
+
* so that the next change starts a new one.
|
|
1630
|
+
*
|
|
1631
|
+
* Framework-free: React's sliders and dawcore's elements both use it. One
|
|
1632
|
+
* helper per control, so two sliders never share an id. It lives in core,
|
|
1633
|
+
* not beside the setters in the engine, because `<daw-editor>` loads the
|
|
1634
|
+
* engine with a dynamic `import()`: a value import of the engine would put
|
|
1635
|
+
* it back in dawcore's first bundle.
|
|
1636
|
+
*/
|
|
1637
|
+
interface MixerGesture {
|
|
1638
|
+
/** The id to pass while a gesture is going on. */
|
|
1639
|
+
readonly id: string;
|
|
1640
|
+
/** The gesture is over: the next change starts a new one. */
|
|
1641
|
+
end(): void;
|
|
1642
|
+
/** Ends the gesture on the input's own events; returns the detach function. */
|
|
1643
|
+
attach(input: HTMLInputElement): () => void;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Make the gesture helper of one mixer control.
|
|
1647
|
+
*
|
|
1648
|
+
* ```ts
|
|
1649
|
+
* const gesture = createMixerGesture();
|
|
1650
|
+
* const detach = gesture.attach(slider);
|
|
1651
|
+
* slider.addEventListener('input', () =>
|
|
1652
|
+
* engine.setTrackVolume(trackId, slider.valueAsNumber, { gesture: gesture.id })
|
|
1653
|
+
* );
|
|
1654
|
+
* ```
|
|
1655
|
+
*
|
|
1656
|
+
* `attach` ends the gesture on the input's `change` (the end of a pointer
|
|
1657
|
+
* drag), except while a key that moves the input is held down; then on that
|
|
1658
|
+
* key's `keyup`. A `blur` ends it too. Mute and solo buttons need no helper:
|
|
1659
|
+
* each click is a step of its own.
|
|
1660
|
+
*/
|
|
1661
|
+
declare function createMixerGesture(): MixerGesture;
|
|
1662
|
+
|
|
1526
1663
|
/**
|
|
1527
1664
|
* The effect registry shared by `<daw-editor>` and the React effects hooks:
|
|
1528
1665
|
* one `registerEffect()` call makes a custom effect (an AudioWorklet, or any
|
|
@@ -1631,4 +1768,4 @@ declare function needsPrepare(type: string, audioContext: BaseAudioContext): boo
|
|
|
1631
1768
|
declare function ensureEffectPrepared(type: string, audioContext: BaseAudioContext): Promise<void>;
|
|
1632
1769
|
declare function createEffectInstance(type: string, audioContext: BaseAudioContext, params?: Record<string, number>): CreatedNativeEffect;
|
|
1633
1770
|
|
|
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
|
|
1771
|
+
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 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 };
|