@opendaw/studio-adapters 0.3.0 → 0.3.2

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.
Files changed (62) hide show
  1. package/dist/AutomatableParameterFieldAdapter.d.ts +9 -5
  2. package/dist/AutomatableParameterFieldAdapter.d.ts.map +1 -1
  3. package/dist/AutomatableParameterFieldAdapter.js +61 -40
  4. package/dist/BoxAdapters.d.ts.map +1 -1
  5. package/dist/BoxAdapters.js +12 -0
  6. package/dist/DeviceManualUrls.d.ts +4 -3
  7. package/dist/DeviceManualUrls.d.ts.map +1 -1
  8. package/dist/DeviceManualUrls.js +4 -3
  9. package/dist/ParameterFieldAdapters.d.ts +3 -7
  10. package/dist/ParameterFieldAdapters.d.ts.map +1 -1
  11. package/dist/ParameterFieldAdapters.js +2 -15
  12. package/dist/ParameterOwner.d.ts +10 -0
  13. package/dist/ParameterOwner.d.ts.map +1 -0
  14. package/dist/ParameterOwner.js +77 -0
  15. package/dist/RootBoxAdapter.d.ts +2 -0
  16. package/dist/RootBoxAdapter.d.ts.map +1 -1
  17. package/dist/RootBoxAdapter.js +8 -2
  18. package/dist/audio-unit/AudioUnitTracks.d.ts +2 -15
  19. package/dist/audio-unit/AudioUnitTracks.d.ts.map +1 -1
  20. package/dist/audio-unit/AudioUnitTracks.js +5 -59
  21. package/dist/devices/audio-effects/ConvolverDeviceBoxAdapter.d.ts +35 -0
  22. package/dist/devices/audio-effects/ConvolverDeviceBoxAdapter.d.ts.map +1 -0
  23. package/dist/devices/audio-effects/ConvolverDeviceBoxAdapter.js +60 -0
  24. package/dist/devices/audio-effects/ReverbDeviceBoxAdapter.d.ts +1 -1
  25. package/dist/devices/audio-effects/ReverbDeviceBoxAdapter.d.ts.map +1 -1
  26. package/dist/devices/audio-effects/StereoToolDeviceBoxAdapter.d.ts +1 -1
  27. package/dist/devices/audio-effects/StereoToolDeviceBoxAdapter.d.ts.map +1 -1
  28. package/dist/devices/instruments/MIDIOutputDeviceBoxAdapter.d.ts +1 -1
  29. package/dist/devices/instruments/MIDIOutputDeviceBoxAdapter.d.ts.map +1 -1
  30. package/dist/index.d.ts +10 -0
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +10 -0
  33. package/dist/modulation/LfoModulatorBoxAdapter.d.ts +31 -0
  34. package/dist/modulation/LfoModulatorBoxAdapter.d.ts.map +1 -0
  35. package/dist/modulation/LfoModulatorBoxAdapter.js +48 -0
  36. package/dist/modulation/MacroModulatorBoxAdapter.d.ts +11 -0
  37. package/dist/modulation/MacroModulatorBoxAdapter.d.ts.map +1 -0
  38. package/dist/modulation/MacroModulatorBoxAdapter.js +21 -0
  39. package/dist/modulation/ModulationBoxAdapter.d.ts +27 -0
  40. package/dist/modulation/ModulationBoxAdapter.d.ts.map +1 -0
  41. package/dist/modulation/ModulationBoxAdapter.js +72 -0
  42. package/dist/modulation/ModulatorBoxAdapter.d.ts +35 -0
  43. package/dist/modulation/ModulatorBoxAdapter.d.ts.map +1 -0
  44. package/dist/modulation/ModulatorBoxAdapter.js +69 -0
  45. package/dist/modulation/Modulators.d.ts +25 -0
  46. package/dist/modulation/Modulators.d.ts.map +1 -0
  47. package/dist/modulation/Modulators.js +110 -0
  48. package/dist/modulation/RandomModulatorBoxAdapter.d.ts +22 -0
  49. package/dist/modulation/RandomModulatorBoxAdapter.d.ts.map +1 -0
  50. package/dist/modulation/RandomModulatorBoxAdapter.js +60 -0
  51. package/dist/modulation/StepsModulatorBoxAdapter.d.ts +40 -0
  52. package/dist/modulation/StepsModulatorBoxAdapter.d.ts.map +1 -0
  53. package/dist/modulation/StepsModulatorBoxAdapter.js +99 -0
  54. package/dist/protocols.d.ts +2 -0
  55. package/dist/protocols.d.ts.map +1 -1
  56. package/dist/timeline/ParameterTracks.d.ts +30 -0
  57. package/dist/timeline/ParameterTracks.d.ts.map +1 -0
  58. package/dist/timeline/ParameterTracks.js +75 -0
  59. package/dist/timeline/TrackBoxAdapter.d.ts +1 -0
  60. package/dist/timeline/TrackBoxAdapter.d.ts.map +1 -1
  61. package/dist/timeline/TrackBoxAdapter.js +21 -27
  62. package/package.json +10 -10
@@ -0,0 +1,35 @@
1
+ import { Address, BooleanField, Box, Int32Field, StringField } from "@opendaw/lib-box";
2
+ import { LfoModulatorBox, MacroModulatorBox, RandomModulatorBox, StepsModulatorBox } from "@opendaw/studio-boxes";
3
+ import { AssertType, StringMapping, Terminator, unitValue, UUID } from "@opendaw/lib-std";
4
+ import { IndexedBoxAdapter } from "../IndexedBoxAdapterCollection";
5
+ import { BoxAdaptersContext } from "../BoxAdaptersContext";
6
+ import { ParameterAdapterSet } from "../ParameterAdapterSet";
7
+ import { AutomatableParameterFieldAdapter } from "../AutomatableParameterFieldAdapter";
8
+ import { FieldParameterTracks } from "../timeline/ParameterTracks";
9
+ import { ModulationBoxAdapter } from "./ModulationBoxAdapter";
10
+ export declare const rangeStringMapping: (bipolar: BooleanField) => StringMapping<unitValue>;
11
+ export declare const polarityStringMapping: (bipolar: BooleanField) => StringMapping<unitValue>;
12
+ export type ModulatorBox = LfoModulatorBox | StepsModulatorBox | MacroModulatorBox | RandomModulatorBox;
13
+ export declare const isModulatorBox: (box: Box) => box is ModulatorBox;
14
+ export declare abstract class ModulatorBoxAdapter<BOX extends ModulatorBox = ModulatorBox> implements IndexedBoxAdapter {
15
+ #private;
16
+ protected readonly terminator: Terminator;
17
+ protected readonly context: BoxAdaptersContext;
18
+ protected readonly parametric: ParameterAdapterSet;
19
+ readonly tracks: FieldParameterTracks;
20
+ readonly amount: AutomatableParameterFieldAdapter<unitValue>;
21
+ protected constructor(context: BoxAdaptersContext, box: BOX);
22
+ get box(): BOX;
23
+ get uuid(): UUID.Bytes;
24
+ get address(): Address;
25
+ get label(): string;
26
+ get labelField(): StringField;
27
+ get enabled(): boolean;
28
+ get indexField(): Int32Field;
29
+ get bipolarField(): BooleanField;
30
+ get assignments(): ReadonlyArray<ModulationBoxAdapter>;
31
+ protected registerParameterTracks(): void;
32
+ terminate(): void;
33
+ }
34
+ export declare const isModulatorBoxAdapter: AssertType<ModulatorBoxAdapter>;
35
+ //# sourceMappingURL=ModulatorBoxAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ModulatorBoxAdapter.d.ts","sourceRoot":"","sources":["../../src/modulation/ModulatorBoxAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACpF,OAAO,EACH,eAAe,EACf,iBAAiB,EAEjB,kBAAkB,EAClB,iBAAiB,EACpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAEH,UAAU,EAGV,aAAa,EAEb,UAAU,EACV,SAAS,EACT,IAAI,EAEP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAC,mBAAmB,EAAC,MAAM,wBAAwB,CAAA;AAC1D,OAAO,EAAC,gCAAgC,EAAC,MAAM,qCAAqC,CAAA;AACpF,OAAO,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAA;AAChE,OAAO,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAA;AAI3D,eAAO,MAAM,kBAAkB,GAAI,SAAS,YAAY,KAAG,aAAa,CAAC,SAAS,CAOhF,CAAA;AAEF,eAAO,MAAM,qBAAqB,GAAI,SAAS,YAAY,KAAG,aAAa,CAAC,SAAS,CAQnF,CAAA;AAEF,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,kBAAkB,CAAA;AAEvG,eAAO,MAAM,cAAc,GAAI,KAAK,GAAG,KAAG,GAAG,IAAI,YAA6C,CAAA;AAE9F,8BAAsB,mBAAmB,CAAC,GAAG,SAAS,YAAY,GAAG,YAAY,CAAE,YAAW,iBAAiB;;IAC3G,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAmB;IAC5D,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAA;IAC9C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,mBAAmB,CAAA;IAClD,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAA;IACrC,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC,SAAS,CAAC,CAAA;IAI5D,SAAS,aAAa,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,GAAG;IAU3D,IAAI,GAAG,IAAI,GAAG,CAAmB;IACjC,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAgC;IACtD,IAAI,OAAO,IAAI,OAAO,CAA2B;IACjD,IAAI,KAAK,IAAI,MAAM,CAAoC;IACvD,IAAI,UAAU,IAAI,WAAW,CAAyB;IACtD,IAAI,OAAO,IAAI,OAAO,CAAsC;IAC5D,IAAI,UAAU,IAAI,UAAU,CAAyB;IACrD,IAAI,YAAY,IAAI,YAAY,CAA2B;IAE3D,IAAI,WAAW,IAAI,aAAa,CAAC,oBAAoB,CAAC,CAGrD;IAID,SAAS,CAAC,uBAAuB,IAAI,IAAI;IAOzC,SAAS,IAAI,IAAI;CACpB;AAED,eAAO,MAAM,qBAAqB,EAAE,UAAU,CAAC,mBAAmB,CACkC,CAAA"}
@@ -0,0 +1,69 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _ModulatorBoxAdapter_box;
13
+ import { ModulationBox } from "@opendaw/studio-boxes";
14
+ import { asInstanceOf, isInstanceOf, Terminator, ValueMapping } from "@opendaw/lib-std";
15
+ import { ParameterAdapterSet } from "../ParameterAdapterSet";
16
+ import { FieldParameterTracks } from "../timeline/ParameterTracks";
17
+ import { ModulationBoxAdapter } from "./ModulationBoxAdapter";
18
+ const percent = (value) => (value * 100.0).toFixed(0);
19
+ export const rangeStringMapping = (bipolar) => ({
20
+ x: (value) => ({ value: `${bipolar.getValue() ? "±" : "+"}${percent(value)}`, unit: "%" }),
21
+ y: (text) => {
22
+ const value = parseFloat(text.replace("±", "").replace("+", "").trim());
23
+ return isNaN(value) ? { type: "unknown", value: text.trim() } : { type: "explicit", value: value / 100.0 };
24
+ }
25
+ });
26
+ export const polarityStringMapping = (bipolar) => ({
27
+ x: (value) => ({ value: percent(bipolar.getValue() ? value * 2.0 - 1.0 : value), unit: "%" }),
28
+ y: (text) => {
29
+ const value = parseFloat(text.replace("%", "").trim());
30
+ if (isNaN(value)) {
31
+ return { type: "unknown", value: text.trim() };
32
+ }
33
+ return { type: "explicit", value: bipolar.getValue() ? value / 200.0 + 0.5 : value / 100.0 };
34
+ }
35
+ });
36
+ export const isModulatorBox = (box) => box.tags.type === "modulator";
37
+ export class ModulatorBoxAdapter {
38
+ constructor(context, box) {
39
+ this.terminator = new Terminator();
40
+ _ModulatorBoxAdapter_box.set(this, void 0);
41
+ this.context = context;
42
+ __classPrivateFieldSet(this, _ModulatorBoxAdapter_box, box, "f");
43
+ this.parametric = this.terminator.own(new ParameterAdapterSet(context));
44
+ this.tracks = this.terminator.own(new FieldParameterTracks(box.graph, box.tracks, context.boxAdapters));
45
+ this.amount = this.parametric.createParameter(box.amount, ValueMapping.unipolar(), rangeStringMapping(box.bipolar), "Range");
46
+ }
47
+ get box() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f"); }
48
+ get uuid() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").address.uuid; }
49
+ get address() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").address; }
50
+ get label() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").label.getValue(); }
51
+ get labelField() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").label; }
52
+ get enabled() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").enabled.getValue(); }
53
+ get indexField() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").index; }
54
+ get bipolarField() { return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").bipolar; }
55
+ get assignments() {
56
+ return __classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").assignments.pointerHub.incoming()
57
+ .map(({ box }) => this.context.boxAdapters.adapterFor(asInstanceOf(box, ModulationBox), ModulationBoxAdapter));
58
+ }
59
+ /// The subclass creates its parameters, then hands them their lane owner: automation of a modulator's
60
+ /// parameter lives on the modulator, not on an audio unit.
61
+ registerParameterTracks() {
62
+ const parameters = this.parametric.parameters();
63
+ parameters.forEach(parameter => this.terminator.own(parameter.registerTracks(this.tracks)));
64
+ this.terminator.own(__classPrivateFieldGet(this, _ModulatorBoxAdapter_box, "f").bipolar.subscribe(() => parameters.forEach(parameter => parameter.notifyPrinting())));
65
+ }
66
+ terminate() { this.terminator.terminate(); }
67
+ }
68
+ _ModulatorBoxAdapter_box = new WeakMap();
69
+ export const isModulatorBoxAdapter = (adapter) => isInstanceOf(adapter, ModulatorBoxAdapter);
@@ -0,0 +1,25 @@
1
+ import { LfoModulatorBox, MacroModulatorBox, ModulationBox, RandomModulatorBox, StepsModulatorBox } from "@opendaw/studio-boxes";
2
+ import { Field } from "@opendaw/lib-box";
3
+ import { Pointers } from "@opendaw/studio-enums";
4
+ import { Func, unitValue } from "@opendaw/lib-std";
5
+ import { BoxAdaptersContext } from "../BoxAdaptersContext";
6
+ import { ModulatorBox } from "./ModulatorBoxAdapter";
7
+ export declare namespace Modulators {
8
+ const createLfo: (context: BoxAdaptersContext, label?: string) => LfoModulatorBox;
9
+ const createSteps: (context: BoxAdaptersContext, label?: string) => StepsModulatorBox;
10
+ const createMacro: (context: BoxAdaptersContext, label?: string) => MacroModulatorBox;
11
+ const createRandom: (context: BoxAdaptersContext, label?: string) => RandomModulatorBox;
12
+ type Kind = {
13
+ readonly label: string;
14
+ readonly boxName: string;
15
+ readonly create: Func<BoxAdaptersContext, ModulatorBox>;
16
+ };
17
+ const Kinds: ReadonlyArray<Kind>;
18
+ const replace: (context: BoxAdaptersContext, modulator: ModulatorBox, kind: Kind) => ModulatorBox;
19
+ const duplicate: (context: BoxAdaptersContext, modulator: ModulatorBox) => ModulatorBox;
20
+ const duplicateAll: (context: BoxAdaptersContext, modulators: ReadonlyArray<ModulatorBox>) => ReadonlyArray<ModulatorBox>;
21
+ const deleteAll: (context: BoxAdaptersContext, modulators: ReadonlyArray<ModulatorBox>) => void;
22
+ const move: (context: BoxAdaptersContext, modulators: ReadonlyArray<ModulatorBox>, target: ModulatorBox) => void;
23
+ const assign: (context: BoxAdaptersContext, modulator: ModulatorBox, target: Field<Pointers.Modulation>, depth?: unitValue) => ModulationBox;
24
+ }
25
+ //# sourceMappingURL=Modulators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Modulators.d.ts","sourceRoot":"","sources":["../../src/modulation/Modulators.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,eAAe,EACf,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAElB,iBAAiB,EAEpB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAM,KAAK,EAAe,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM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ACvC,QAAQ,YAAY,KAAG,IAW3C,CAAA;IAqBM,MAAM,MAAM,GAAI,SAAS,kBAAkB,EAC3B,WAAW,YAAY,EACvB,QAAQ,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAClC,QAAO,SAAgB,KAAG,aAM3C,CAAA;CACT"}
@@ -0,0 +1,110 @@
1
+ import { LfoModulatorBox, MacroModulatorBox, ModulationBox, RandomModulatorBox, StepsModulatorBox, TrackBox } from "@opendaw/studio-boxes";
2
+ import { ByteArrayInput, isInstanceOf, panic, Strings, UUID } from "@opendaw/lib-std";
3
+ /// Every caller is inside an `editing.modify`, so nothing here opens a transaction.
4
+ export var Modulators;
5
+ (function (Modulators) {
6
+ Modulators.createLfo = (context, label) => LfoModulatorBox.create(context.boxGraph, UUID.generate(), box => attach(context, box, label ?? "LFO"));
7
+ Modulators.createSteps = (context, label) => StepsModulatorBox.create(context.boxGraph, UUID.generate(), box => attach(context, box, label ?? "Steps"));
8
+ Modulators.createMacro = (context, label) => MacroModulatorBox.create(context.boxGraph, UUID.generate(), box => attach(context, box, label ?? "Macro"));
9
+ Modulators.createRandom = (context, label) => RandomModulatorBox.create(context.boxGraph, UUID.generate(), box => attach(context, box, label ?? "Random"));
10
+ Modulators.Kinds = [
11
+ { label: "LFO", boxName: "LfoModulatorBox", create: Modulators.createLfo },
12
+ { label: "Steps", boxName: "StepsModulatorBox", create: Modulators.createSteps },
13
+ { label: "Macro", boxName: "MacroModulatorBox", create: Modulators.createMacro },
14
+ { label: "Random", boxName: "RandomModulatorBox", create: Modulators.createRandom }
15
+ ];
16
+ /// Becomes another kind in place: the assignments move over first, so they never see the old box die.
17
+ Modulators.replace = (context, modulator, kind) => {
18
+ const replacement = kind.create(context);
19
+ modulator.assignments.pointerHub.incoming().slice()
20
+ .forEach((pointer) => pointer.refer(replacement.assignments));
21
+ // An assignment's depth lane is parented to its SOURCE, so it would die with the old box while the
22
+ // assignment it belongs to survives. The old kind's own parameter lanes have no meaning in the new
23
+ // kind and are left to the cascade.
24
+ modulator.tracks.pointerHub.incoming().slice()
25
+ .map((pointer) => pointer.box)
26
+ .filter((box) => isInstanceOf(box, TrackBox))
27
+ .filter((track) => track.target.targetVertex
28
+ .mapOr(vertex => isInstanceOf(vertex.box, ModulationBox), false))
29
+ .forEach((track) => track.tracks.refer(replacement.tracks));
30
+ const label = modulator.label.getValue();
31
+ const index = modulator.index.getValue();
32
+ const enabled = modulator.enabled.getValue();
33
+ const bipolar = modulator.bipolar.getValue();
34
+ const amount = modulator.amount.getValue();
35
+ modulator.delete();
36
+ replacement.label.setValue(label);
37
+ replacement.index.setValue(index);
38
+ replacement.enabled.setValue(enabled);
39
+ replacement.bipolar.setValue(bipolar);
40
+ replacement.amount.setValue(amount);
41
+ return replacement;
42
+ };
43
+ /// Same kind and settings, no targets. The copy reads the original's own bytes, so every kind is covered.
44
+ Modulators.duplicate = (context, modulator) => Modulators.duplicateAll(context, [modulator])[0];
45
+ /// Several at once, appended in their list order, each with its own unique name. A box created in THIS
46
+ /// transaction is not in the collection yet (its edges resolve on commit), so index and name are counted
47
+ /// forward here rather than re-read per copy.
48
+ Modulators.duplicateAll = (context, modulators) => {
49
+ const existing = context.rootBoxAdapter.modulators.adapters();
50
+ const taken = existing.map(adapter => adapter.label);
51
+ return modulators.slice()
52
+ .sort((a, b) => a.index.getValue() - b.index.getValue())
53
+ .map((modulator, offset) => {
54
+ const input = new ByteArrayInput(modulator.toArrayBuffer());
55
+ const copy = asModulatorBox(context.boxGraph.createBox(modulator.name, UUID.generate(), box => box.read(input)));
56
+ const label = Strings.getUniqueName(taken, modulator.label.getValue());
57
+ taken.push(label);
58
+ copy.index.setValue(existing.length + offset);
59
+ copy.label.setValue(label);
60
+ return copy;
61
+ });
62
+ };
63
+ /// Delete a whole selection and close the gaps it leaves, so the remaining indices stay 0..n-1.
64
+ Modulators.deleteAll = (context, modulators) => {
65
+ const doomed = new Set(modulators);
66
+ const remaining = context.rootBoxAdapter.modulators.adapters()
67
+ .filter(adapter => !doomed.has(adapter.box));
68
+ doomed.forEach(modulator => modulator.delete());
69
+ reindex(remaining.map(adapter => adapter.box));
70
+ };
71
+ /// Move a set to `target`'s place, keeping the moved ones in their own order. Dropping onto a member of
72
+ /// the set itself is a no-op, so a drag that ends where it started changes nothing.
73
+ Modulators.move = (context, modulators, target) => {
74
+ const moved = new Set(modulators);
75
+ if (moved.has(target) || moved.size === 0) {
76
+ return;
77
+ }
78
+ const ordered = context.rootBoxAdapter.modulators.adapters().map(adapter => adapter.box);
79
+ const stationary = ordered.filter(box => !moved.has(box));
80
+ const insertAt = stationary.indexOf(target);
81
+ if (insertAt < 0) {
82
+ return;
83
+ }
84
+ const dragged = ordered.filter(box => moved.has(box));
85
+ const before = ordered.indexOf(dragged[0]) < ordered.indexOf(target);
86
+ stationary.splice(before ? insertAt + 1 : insertAt, 0, ...dragged);
87
+ reindex(stationary);
88
+ };
89
+ const reindex = (modulators) => modulators.forEach((modulator, index) => modulator.index.setValue(index));
90
+ const asModulatorBox = (box) => box.accept({
91
+ visitLfoModulatorBox: (box) => box,
92
+ visitStepsModulatorBox: (box) => box,
93
+ visitMacroModulatorBox: (box) => box,
94
+ visitRandomModulatorBox: (box) => box
95
+ }) ?? panic(`${box.name} is no modulator`);
96
+ const attach = (context, box, label) => {
97
+ const rootBox = context.rootBoxAdapter.box;
98
+ const existing = context.rootBoxAdapter.modulators.adapters();
99
+ box.collection.refer(rootBox.modulators);
100
+ box.index.setValue(existing.length);
101
+ box.label.setValue(Strings.getUniqueName(existing.map(adapter => adapter.label), label));
102
+ };
103
+ /// A parameter accepts several assignments, so this never replaces an existing one. `depth` is signed.
104
+ Modulators.assign = (context, modulator, target, depth = 0.25) => ModulationBox.create(context.boxGraph, UUID.generate(), box => {
105
+ box.source.refer(modulator.assignments);
106
+ box.target.refer(target);
107
+ box.index.setValue(modulator.assignments.pointerHub.incoming().length);
108
+ box.depth.setValue(depth);
109
+ });
110
+ })(Modulators || (Modulators = {}));
@@ -0,0 +1,22 @@
1
+ import { RandomModulatorBox } from "@opendaw/studio-boxes";
2
+ import { int, unitValue } from "@opendaw/lib-std";
3
+ import { BoxAdaptersContext } from "../BoxAdaptersContext";
4
+ import { ModulatorBoxAdapter } from "./ModulatorBoxAdapter";
5
+ export declare class RandomModulatorBoxAdapter extends ModulatorBoxAdapter<RandomModulatorBox> {
6
+ #private;
7
+ static readonly MaxLoop = 64;
8
+ static readonly MaxLevels = 32;
9
+ static readonly MaxSeed = 999999;
10
+ readonly namedParameter: {
11
+ readonly rateSync: import("..").AutomatableParameterFieldAdapter<number>;
12
+ readonly rateAbsolute: import("..").AutomatableParameterFieldAdapter<number>;
13
+ readonly phase: import("..").AutomatableParameterFieldAdapter<number>;
14
+ readonly smooth: import("..").AutomatableParameterFieldAdapter<number>;
15
+ };
16
+ constructor(context: BoxAdaptersContext, box: RandomModulatorBox);
17
+ get loop(): int;
18
+ draw(index: int): unitValue;
19
+ valueAt(step: number): unitValue;
20
+ reseed(): void;
21
+ }
22
+ //# sourceMappingURL=RandomModulatorBoxAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RandomModulatorBoxAdapter.d.ts","sourceRoot":"","sources":["../../src/modulation/RandomModulatorBoxAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAC,GAAG,EAAiB,SAAS,EAAe,MAAM,kBAAkB,CAAA;AAC5E,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AAGzD,qBAAa,yBAA0B,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC;;IAClF,MAAM,CAAC,QAAQ,CAAC,OAAO,MAAK;IAC5B,MAAM,CAAC,QAAQ,CAAC,SAAS,MAAK;IAC9B,MAAM,CAAC,QAAQ,CAAC,OAAO,UAAS;IAEhC,QAAQ,CAAC,cAAc;;;;;MAAA;gBAEX,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,kBAAkB;IAMhE,IAAI,IAAI,IAAI,GAAG,CAAkC;IAEjD,IAAI,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS;IAS3B,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS;IAUhC,MAAM,IAAI,IAAI;CA6BjB"}
@@ -0,0 +1,60 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _RandomModulatorBoxAdapter_instances, _RandomModulatorBoxAdapter_localIndex, _RandomModulatorBoxAdapter_quantize, _RandomModulatorBoxAdapter_wrapParameters;
7
+ import { StringMapping, ValueMapping } from "@opendaw/lib-std";
8
+ import { LfoModulatorBoxAdapter } from "./LfoModulatorBoxAdapter";
9
+ import { ModulatorBoxAdapter } from "./ModulatorBoxAdapter";
10
+ // WASM CONTRACT: `draw` and `quantize` mirror the engine's `modulation::hash_bipolar` / `quantize`.
11
+ export class RandomModulatorBoxAdapter extends ModulatorBoxAdapter {
12
+ constructor(context, box) {
13
+ super(context, box);
14
+ _RandomModulatorBoxAdapter_instances.add(this);
15
+ this.namedParameter = __classPrivateFieldGet(this, _RandomModulatorBoxAdapter_instances, "m", _RandomModulatorBoxAdapter_wrapParameters).call(this, box);
16
+ this.registerParameterTracks();
17
+ }
18
+ get loop() { return this.box.loop.getValue(); }
19
+ draw(index) {
20
+ const seed = this.box.seed.getValue();
21
+ const local = __classPrivateFieldGet(this, _RandomModulatorBoxAdapter_instances, "m", _RandomModulatorBoxAdapter_localIndex).call(this, index);
22
+ let hash = Math.imul(seed, 0x9E3779B1) ^ Math.imul(local, 0x85EBCA77);
23
+ hash = Math.imul(hash ^ (hash >>> 15), 0x2545F491);
24
+ hash ^= hash >>> 13;
25
+ return __classPrivateFieldGet(this, _RandomModulatorBoxAdapter_instances, "m", _RandomModulatorBoxAdapter_quantize).call(this, (hash >>> 0) / 4294967295.0 * 2.0 - 1.0);
26
+ }
27
+ valueAt(step) {
28
+ const index = Math.floor(step);
29
+ const current = this.draw(index);
30
+ const smooth = this.box.smooth.getValue();
31
+ if (smooth <= 0.0) {
32
+ return current;
33
+ }
34
+ const previous = this.draw(index - 1);
35
+ const ramp = Math.min(1.0, (step - index) / smooth);
36
+ return previous + (current - previous) * ramp * ramp * (3.0 - 2.0 * ramp);
37
+ }
38
+ reseed() { this.box.seed.setValue(Math.floor(Math.random() * RandomModulatorBoxAdapter.MaxSeed)); }
39
+ }
40
+ _RandomModulatorBoxAdapter_instances = new WeakSet(), _RandomModulatorBoxAdapter_localIndex = function _RandomModulatorBoxAdapter_localIndex(index) {
41
+ const length = this.loop;
42
+ return length > 0 ? ((index % length) + length) % length : index | 0;
43
+ }, _RandomModulatorBoxAdapter_quantize = function _RandomModulatorBoxAdapter_quantize(value) {
44
+ const levels = this.box.levels.getValue();
45
+ if (levels < 2) {
46
+ return value;
47
+ }
48
+ const steps = levels - 1;
49
+ return Math.min(steps, Math.max(0, Math.floor((value + 1.0) * 0.5 * steps + 0.5))) / steps * 2.0 - 1.0;
50
+ }, _RandomModulatorBoxAdapter_wrapParameters = function _RandomModulatorBoxAdapter_wrapParameters(box) {
51
+ return {
52
+ rateSync: this.parametric.createParameter(box.rateSync, ValueMapping.linearInteger(0, LfoModulatorBoxAdapter.RateStrings.length - 1), StringMapping.indices("", LfoModulatorBoxAdapter.RateStrings), "Sync"),
53
+ rateAbsolute: this.parametric.createParameter(box.rateAbsolute, ValueMapping.powerByCenter(LfoModulatorBoxAdapter.CenterAbsoluteRate, 0.0, LfoModulatorBoxAdapter.MaxAbsoluteRate), StringMapping.numeric({ unit: "Hz", fractionDigits: 2 }), "Free"),
54
+ phase: this.parametric.createParameter(box.phase, ValueMapping.unipolar(), StringMapping.percent({ fractionDigits: 0 }), "Phase"),
55
+ smooth: this.parametric.createParameter(box.smooth, ValueMapping.unipolar(), StringMapping.percent({ fractionDigits: 0 }), "Smooth")
56
+ };
57
+ };
58
+ RandomModulatorBoxAdapter.MaxLoop = 64;
59
+ RandomModulatorBoxAdapter.MaxLevels = 32;
60
+ RandomModulatorBoxAdapter.MaxSeed = 999999;
@@ -0,0 +1,40 @@
1
+ import { Float32Field } from "@opendaw/lib-box";
2
+ import { StepsModulatorBox } from "@opendaw/studio-boxes";
3
+ import { int, unitValue } from "@opendaw/lib-std";
4
+ import { BoxAdaptersContext } from "../BoxAdaptersContext";
5
+ import { ModulatorBoxAdapter } from "./ModulatorBoxAdapter";
6
+ export declare enum StepsDirection {
7
+ Forward = 0,
8
+ Backward = 1,
9
+ PingPong = 2,
10
+ Alternate = 3,
11
+ Random = 4
12
+ }
13
+ export type StepsPass = {
14
+ ascending: boolean;
15
+ from: int;
16
+ to: int;
17
+ };
18
+ export declare class StepsModulatorBoxAdapter extends ModulatorBoxAdapter<StepsModulatorBox> {
19
+ #private;
20
+ static readonly MaxSteps = 64;
21
+ static readonly DirectionStrings: ReadonlyArray<string>;
22
+ readonly namedParameter: {
23
+ readonly rateSync: import("..").AutomatableParameterFieldAdapter<number>;
24
+ readonly rateAbsolute: import("..").AutomatableParameterFieldAdapter<number>;
25
+ readonly phase: import("..").AutomatableParameterFieldAdapter<number>;
26
+ readonly smooth: import("..").AutomatableParameterFieldAdapter<number>;
27
+ };
28
+ constructor(context: BoxAdaptersContext, box: StepsModulatorBox);
29
+ get count(): int;
30
+ get steps(): ReadonlyArray<Float32Field>;
31
+ get passes(): ReadonlyArray<StepsPass>;
32
+ patternAt(step: number, ascending: boolean): unitValue;
33
+ get neutral(): unitValue;
34
+ emitted(stored: unitValue): number;
35
+ stored(emitted: number): unitValue;
36
+ clear(): void;
37
+ randomize(): void;
38
+ rotate(offset: int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AiD;IAEzE,OAAO,CAAC,MAAM,EAAE,SAAS,GAAG,MAAM;IAElC,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;IAElC,KAAK,IAAI,IAAI;IAKb,SAAS,IAAI,IAAI;IAEjB,MAAM,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI;CA2B5B"}
@@ -0,0 +1,99 @@
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
6
+ var _StepsModulatorBoxAdapter_instances, _a, _StepsModulatorBoxAdapter_predecessor, _StepsModulatorBoxAdapter_activeSteps, _StepsModulatorBoxAdapter_wrapParameters;
7
+ import { StringMapping, ValueMapping } from "@opendaw/lib-std";
8
+ import { LfoModulatorBoxAdapter } from "./LfoModulatorBoxAdapter";
9
+ import { ModulatorBoxAdapter } from "./ModulatorBoxAdapter";
10
+ // WASM CONTRACT: mirrors the engine's `modulation::DIRECTION_*` (crates/engine/src/modulation.rs).
11
+ export var StepsDirection;
12
+ (function (StepsDirection) {
13
+ StepsDirection[StepsDirection["Forward"] = 0] = "Forward";
14
+ StepsDirection[StepsDirection["Backward"] = 1] = "Backward";
15
+ StepsDirection[StepsDirection["PingPong"] = 2] = "PingPong";
16
+ StepsDirection[StepsDirection["Alternate"] = 3] = "Alternate";
17
+ StepsDirection[StepsDirection["Random"] = 4] = "Random";
18
+ })(StepsDirection || (StepsDirection = {}));
19
+ export class StepsModulatorBoxAdapter extends ModulatorBoxAdapter {
20
+ constructor(context, box) {
21
+ super(context, box);
22
+ _StepsModulatorBoxAdapter_instances.add(this);
23
+ this.namedParameter = __classPrivateFieldGet(this, _StepsModulatorBoxAdapter_instances, "m", _StepsModulatorBoxAdapter_wrapParameters).call(this, box);
24
+ this.registerParameterTracks();
25
+ }
26
+ get count() { return this.box.count.getValue(); }
27
+ get steps() { return this.box.steps.fields(); }
28
+ /// The passes the sequence makes over the pattern, each covering the steps `[from, to)` it reaches.
29
+ get passes() {
30
+ const count = Math.max(1, Math.min(this.count, _a.MaxSteps));
31
+ switch (this.box.direction.getValue()) {
32
+ case StepsDirection.Backward:
33
+ return [{ ascending: false, from: 0, to: count }];
34
+ case StepsDirection.PingPong:
35
+ return [{ ascending: true, from: 0, to: count }, { ascending: false, from: 0, to: count }];
36
+ case StepsDirection.Alternate:
37
+ return count < 3
38
+ ? [{ ascending: true, from: 0, to: count }]
39
+ : [{ ascending: true, from: 0, to: count - 1 }, { ascending: false, from: 1, to: count }];
40
+ // Random reorders per cycle, so there is no one pass to draw: the display shows a forward one.
41
+ default:
42
+ return [{ ascending: true, from: 0, to: count }];
43
+ }
44
+ }
45
+ patternAt(step, ascending) {
46
+ const count = Math.max(1, Math.min(this.count, _a.MaxSteps));
47
+ const index = ((Math.floor(step) % count) + count) % count;
48
+ const current = this.steps[index].getValue();
49
+ const smooth = this.box.smooth.getValue();
50
+ if (smooth <= 0.0) {
51
+ return current;
52
+ }
53
+ const local = step - Math.floor(step);
54
+ const traversed = ascending ? local : 1.0 - local;
55
+ const previous = this.steps[__classPrivateFieldGet(this, _StepsModulatorBoxAdapter_instances, "m", _StepsModulatorBoxAdapter_predecessor).call(this, index, count, ascending)].getValue();
56
+ const ramp = Math.min(1.0, traversed / smooth);
57
+ return previous + (current - previous) * ramp * ramp * (3.0 - 2.0 * ramp);
58
+ }
59
+ get neutral() { return this.box.bipolar.getValue() ? 0.5 : 0.0; }
60
+ emitted(stored) { return this.box.bipolar.getValue() ? stored * 2.0 - 1.0 : stored; }
61
+ stored(emitted) { return this.box.bipolar.getValue() ? emitted * 0.5 + 0.5 : emitted; }
62
+ clear() {
63
+ const neutral = this.neutral;
64
+ __classPrivateFieldGet(this, _StepsModulatorBoxAdapter_instances, "m", _StepsModulatorBoxAdapter_activeSteps).call(this).forEach(step => step.setValue(neutral));
65
+ }
66
+ randomize() { __classPrivateFieldGet(this, _StepsModulatorBoxAdapter_instances, "m", _StepsModulatorBoxAdapter_activeSteps).call(this).forEach(step => step.setValue(Math.random())); }
67
+ rotate(offset) {
68
+ const active = __classPrivateFieldGet(this, _StepsModulatorBoxAdapter_instances, "m", _StepsModulatorBoxAdapter_activeSteps).call(this);
69
+ const values = active.map(step => step.getValue());
70
+ const count = values.length;
71
+ active.forEach((step, index) => step.setValue(values[(((index - offset) % count) + count) % count]));
72
+ }
73
+ }
74
+ _a = StepsModulatorBoxAdapter, _StepsModulatorBoxAdapter_instances = new WeakSet(), _StepsModulatorBoxAdapter_predecessor = function _StepsModulatorBoxAdapter_predecessor(index, count, ascending) {
75
+ const wrap = (value) => ((value % count) + count) % count;
76
+ switch (this.box.direction.getValue()) {
77
+ case StepsDirection.PingPong:
78
+ return ascending
79
+ ? (index === 0 ? 0 : index - 1)
80
+ : (index === count - 1 ? count - 1 : index + 1);
81
+ case StepsDirection.Alternate:
82
+ return ascending
83
+ ? (index === 0 ? Math.min(1, count - 1) : index - 1)
84
+ : (index === count - 1 ? Math.max(0, count - 2) : index + 1);
85
+ default:
86
+ return ascending ? wrap(index - 1) : wrap(index + 1);
87
+ }
88
+ }, _StepsModulatorBoxAdapter_activeSteps = function _StepsModulatorBoxAdapter_activeSteps() {
89
+ return this.steps.slice(0, Math.max(1, Math.min(this.count, _a.MaxSteps)));
90
+ }, _StepsModulatorBoxAdapter_wrapParameters = function _StepsModulatorBoxAdapter_wrapParameters(box) {
91
+ return {
92
+ rateSync: this.parametric.createParameter(box.rateSync, ValueMapping.linearInteger(0, LfoModulatorBoxAdapter.RateStrings.length - 1), StringMapping.indices("", LfoModulatorBoxAdapter.RateStrings), "Sync"),
93
+ rateAbsolute: this.parametric.createParameter(box.rateAbsolute, ValueMapping.powerByCenter(LfoModulatorBoxAdapter.CenterAbsoluteRate, 0.0, LfoModulatorBoxAdapter.MaxAbsoluteRate), StringMapping.numeric({ unit: "Hz", fractionDigits: 2 }), "Free"),
94
+ phase: this.parametric.createParameter(box.phase, ValueMapping.unipolar(), StringMapping.percent({ fractionDigits: 0 }), "Phase"),
95
+ smooth: this.parametric.createParameter(box.smooth, ValueMapping.unipolar(), StringMapping.percent({ fractionDigits: 0 }), "Smooth")
96
+ };
97
+ };
98
+ StepsModulatorBoxAdapter.MaxSteps = 64;
99
+ StepsModulatorBoxAdapter.DirectionStrings = ["Forward", "Backward", "Ping-Pong", "Alternate", "Random"];
@@ -20,6 +20,8 @@ export interface EngineCommands extends Terminable {
20
20
  noteSignal(signal: NoteSignal): void;
21
21
  /** @internal */
22
22
  ignoreNoteRegion(uuid: UUID.Bytes): void;
23
+ /** @internal */
24
+ suspendAutomation(uuid: UUID.Bytes): void;
23
25
  scheduleClipPlay(clipIds: ReadonlyArray<UUID.Bytes>): void;
24
26
  scheduleClipStop(trackIds: ReadonlyArray<UUID.Bytes>): void;
25
27
  /** @internal */
@@ -1 +1 @@
1
- {"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAC,SAAS,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAA;AACzD,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAA;AACvC,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AAE1C,MAAM,MAAM,kBAAkB,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC,KAAK,CAAC;IAAC,QAAQ,EAAE,aAAa,CAAC,GAAG,CAAC,CAAA;CAAE,CAAA;AAEnF,MAAM,WAAW,cAAe,SAAQ,UAAU;IAC9C,IAAI,IAAI,IAA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AAO,CAAC,UAAU,CAAC,CAAA;IACrD,YAAY,IAAI,OAAO,CAAC,WAAW,CAAC,CAAA;IACpC,yBAAyB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAAA;IAC/D,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,GAAG,IAAI,CAAA;IAC3D,KAAK,IAAI,IAAI,CAAA;CAChB"}
@@ -0,0 +1,30 @@
1
+ import { int, Observer, Option, Subscription, Terminable } from "@opendaw/lib-std";
2
+ import { Pointers } from "@opendaw/studio-enums";
3
+ import { TrackBox } from "@opendaw/studio-boxes";
4
+ import { BoxGraph, Field, Vertex } from "@opendaw/lib-box";
5
+ import { IndexedAdapterCollectionListener, IndexedBoxAdapterCollection } from "../IndexedBoxAdapterCollection";
6
+ import { TrackBoxAdapter } from "./TrackBoxAdapter";
7
+ import { BoxAdapters } from "../BoxAdapters";
8
+ import { TrackType } from "./TrackType";
9
+ export interface ParameterTracks extends Terminable {
10
+ create(type: TrackType, target: Vertex<Pointers.Automation | Pointers>, index?: int): TrackBox;
11
+ controls(target: Vertex<Pointers.Automation | Pointers>): Option<TrackBoxAdapter>;
12
+ delete(adapter: TrackBoxAdapter): void;
13
+ values(): ReadonlyArray<TrackBoxAdapter>;
14
+ get collection(): IndexedBoxAdapterCollection<TrackBoxAdapter, Pointers.TrackCollection>;
15
+ catchupAndSubscribe(listener: IndexedAdapterCollectionListener<TrackBoxAdapter>): Subscription;
16
+ subscribeAnyChange(observer: Observer<void>): Subscription;
17
+ }
18
+ export declare class FieldParameterTracks implements ParameterTracks {
19
+ #private;
20
+ constructor(graph: BoxGraph, field: Field<Pointers.TrackCollection>, boxAdapters: BoxAdapters);
21
+ create(type: TrackType, target: Vertex<Pointers.Automation | Pointers>, index?: int): TrackBox;
22
+ controls(target: Vertex<Pointers.Automation | Pointers>): Option<TrackBoxAdapter>;
23
+ delete(adapter: TrackBoxAdapter): void;
24
+ get collection(): IndexedBoxAdapterCollection<TrackBoxAdapter, Pointers.TrackCollection>;
25
+ values(): ReadonlyArray<TrackBoxAdapter>;
26
+ catchupAndSubscribe(listener: IndexedAdapterCollectionListener<TrackBoxAdapter>): Subscription;
27
+ subscribeAnyChange(observer: Observer<void>): Subscription;
28
+ terminate(): void;
29
+ }
30
+ //# sourceMappingURL=ParameterTracks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ParameterTracks.d.ts","sourceRoot":"","sources":["../../src/timeline/ParameterTracks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAY,QAAQ,EAAE,MAAM,EAAoB,YAAY,EAAE,UAAU,EAAO,MAAM,kBAAkB,CAAA;AAClH,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAC,gCAAgC,EAAE,2BAA2B,EAAC,MAAM,gCAAgC,CAAA;AAC5G,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAIrC,MAAM,WAAW,eAAgB,SAAQ,UAAU;IAC/C,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAA;IAC9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;IACjF,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAA;IACtC,MAAM,IAAI,aAAa,CAAC,eAAe,CAAC,CAAA;IACxC,IAAI,UAAU,IAAI,2BAA2B,CAAC,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAA;IACxF,mBAAmB,CAAC,QAAQ,EAAE,gCAAgC,CAAC,eAAe,CAAC,GAAG,YAAY,CAAA;IAC9F,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY,CAAA;CAC7D;AAED,qBAAa,oBAAqB,YAAW,eAAe;;gBAS5C,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,WAAW,EAAE,WAAW;IAgB7F,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,QAAQ;IAS9F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;IAKjF,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAUtC,IAAI,UAAU,IAAI,2BAA2B,CAAC,eAAe,EAAE,QAAQ,CAAC,eAAe,CAAC,CAA0B;IAElH,MAAM,IAAI,aAAa,CAAC,eAAe,CAAC;IAExC,mBAAmB,CAAC,QAAQ,EAAE,gCAAgC,CAAC,eAAe,CAAC,GAAG,YAAY;IAI9F,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,YAAY;IAE1D,SAAS,IAAI,IAAI;CAMpB"}
@@ -0,0 +1,75 @@
1
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
+ if (kind === "m") throw new TypeError("Private method is not writable");
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
+ };
7
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
+ };
12
+ var _FieldParameterTracks_graph, _FieldParameterTracks_field, _FieldParameterTracks_regionNotifier, _FieldParameterTracks_collection, _FieldParameterTracks_subscriptions, _FieldParameterTracks_subscription;
13
+ import { Notifier, Option, panic, UUID } from "@opendaw/lib-std";
14
+ import { Pointers } from "@opendaw/studio-enums";
15
+ import { TrackBox } from "@opendaw/studio-boxes";
16
+ import { IndexedBoxAdapterCollection } from "../IndexedBoxAdapterCollection";
17
+ import { TrackBoxAdapter } from "./TrackBoxAdapter";
18
+ export class FieldParameterTracks {
19
+ constructor(graph, field, boxAdapters) {
20
+ _FieldParameterTracks_graph.set(this, void 0);
21
+ _FieldParameterTracks_field.set(this, void 0);
22
+ _FieldParameterTracks_regionNotifier.set(this, new Notifier());
23
+ _FieldParameterTracks_collection.set(this, void 0);
24
+ _FieldParameterTracks_subscriptions.set(this, void 0);
25
+ _FieldParameterTracks_subscription.set(this, void 0);
26
+ __classPrivateFieldSet(this, _FieldParameterTracks_graph, graph, "f");
27
+ __classPrivateFieldSet(this, _FieldParameterTracks_field, field, "f");
28
+ __classPrivateFieldSet(this, _FieldParameterTracks_collection, IndexedBoxAdapterCollection.create(field, box => boxAdapters.adapterFor(box, TrackBoxAdapter), Pointers.TrackCollection), "f");
29
+ __classPrivateFieldSet(this, _FieldParameterTracks_subscriptions, UUID.newSet(({ uuid }) => uuid), "f");
30
+ __classPrivateFieldSet(this, _FieldParameterTracks_subscription, __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").catchupAndSubscribe({
31
+ onAdd: (adapter) => __classPrivateFieldGet(this, _FieldParameterTracks_subscriptions, "f").add({
32
+ uuid: adapter.uuid,
33
+ subscription: adapter.regions.subscribeChanges(() => __classPrivateFieldGet(this, _FieldParameterTracks_regionNotifier, "f").notify())
34
+ }),
35
+ onRemove: ({ uuid }) => __classPrivateFieldGet(this, _FieldParameterTracks_subscriptions, "f").removeByKey(uuid).subscription.terminate(),
36
+ onReorder: (_adapter) => { }
37
+ }), "f");
38
+ }
39
+ create(type, target, index) {
40
+ return TrackBox.create(__classPrivateFieldGet(this, _FieldParameterTracks_graph, "f"), UUID.generate(), box => {
41
+ box.index.setValue(index ?? __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").getMinFreeIndex());
42
+ box.type.setValue(type);
43
+ box.tracks.refer(__classPrivateFieldGet(this, _FieldParameterTracks_field, "f"));
44
+ box.target.refer(target);
45
+ });
46
+ }
47
+ controls(target) {
48
+ return Option.wrap(__classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").adapters()
49
+ .find(adapter => adapter.target.targetVertex.contains(target), false));
50
+ }
51
+ delete(adapter) {
52
+ const adapters = __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").adapters();
53
+ const deleteIndex = adapters.indexOf(adapter);
54
+ if (deleteIndex === -1) {
55
+ return panic(`Cannot delete ${adapter}. Does not exist.`);
56
+ }
57
+ for (let index = deleteIndex + 1; index < adapters.length; index++) {
58
+ adapters[index].indexField.setValue(index - 1);
59
+ }
60
+ adapter.box.delete();
61
+ }
62
+ get collection() { return __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f"); }
63
+ values() { return __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").adapters(); }
64
+ catchupAndSubscribe(listener) {
65
+ return __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").catchupAndSubscribe(listener);
66
+ }
67
+ subscribeAnyChange(observer) { return __classPrivateFieldGet(this, _FieldParameterTracks_regionNotifier, "f").subscribe(observer); }
68
+ terminate() {
69
+ __classPrivateFieldGet(this, _FieldParameterTracks_collection, "f").terminate();
70
+ __classPrivateFieldGet(this, _FieldParameterTracks_subscription, "f").terminate();
71
+ __classPrivateFieldGet(this, _FieldParameterTracks_subscriptions, "f").forEach(({ subscription }) => subscription.terminate());
72
+ __classPrivateFieldGet(this, _FieldParameterTracks_subscriptions, "f").clear();
73
+ }
74
+ }
75
+ _FieldParameterTracks_graph = new WeakMap(), _FieldParameterTracks_field = new WeakMap(), _FieldParameterTracks_regionNotifier = new WeakMap(), _FieldParameterTracks_collection = new WeakMap(), _FieldParameterTracks_subscriptions = new WeakMap(), _FieldParameterTracks_subscription = new WeakMap();