@opendaw/studio-adapters 0.0.99 → 0.0.101
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AutomatableParameterFieldAdapter.d.ts +6 -1
- package/dist/AutomatableParameterFieldAdapter.d.ts.map +1 -1
- package/dist/AutomatableParameterFieldAdapter.js +24 -6
- package/dist/BoxAdapters.d.ts.map +1 -1
- package/dist/BoxAdapters.js +6 -0
- package/dist/DeviceManualUrls.d.ts +3 -0
- package/dist/DeviceManualUrls.d.ts.map +1 -1
- package/dist/DeviceManualUrls.js +3 -0
- package/dist/NoteStreamReceiver.d.ts +2 -1
- package/dist/NoteStreamReceiver.d.ts.map +1 -1
- package/dist/NoteStreamReceiver.js +25 -13
- package/dist/ParameterAdapterSet.d.ts +1 -1
- package/dist/ParameterAdapterSet.d.ts.map +1 -1
- package/dist/ParameterAdapterSet.js +2 -2
- package/dist/ParameterFieldAdapters.d.ts +10 -0
- package/dist/ParameterFieldAdapters.d.ts.map +1 -1
- package/dist/ParameterFieldAdapters.js +30 -3
- package/dist/ScriptCompiler.d.ts +23 -0
- package/dist/ScriptCompiler.d.ts.map +1 -0
- package/dist/ScriptCompiler.js +190 -0
- package/dist/ScriptDeclaration.d.ts +37 -0
- package/dist/ScriptDeclaration.d.ts.map +1 -0
- package/dist/ScriptDeclaration.js +209 -0
- package/dist/audio-unit/AudioUnitTracks.d.ts +1 -0
- package/dist/audio-unit/AudioUnitTracks.d.ts.map +1 -1
- package/dist/audio-unit/AudioUnitTracks.js +1 -0
- package/dist/devices/audio-effects/WerkstattDeviceBoxAdapter.d.ts +31 -0
- package/dist/devices/audio-effects/WerkstattDeviceBoxAdapter.d.ts.map +1 -0
- package/dist/devices/audio-effects/WerkstattDeviceBoxAdapter.js +55 -0
- package/dist/devices/instruments/ApparatDeviceBoxAdapter.d.ts +32 -0
- package/dist/devices/instruments/ApparatDeviceBoxAdapter.d.ts.map +1 -0
- package/dist/devices/instruments/ApparatDeviceBoxAdapter.js +57 -0
- package/dist/devices/midi-effects/SpielwerkDeviceBoxAdapter.d.ts +29 -0
- package/dist/devices/midi-effects/SpielwerkDeviceBoxAdapter.d.ts.map +1 -0
- package/dist/devices/midi-effects/SpielwerkDeviceBoxAdapter.js +52 -0
- package/dist/factories/DeviceFactory.d.ts +1 -0
- package/dist/factories/DeviceFactory.d.ts.map +1 -1
- package/dist/factories/InstrumentBox.d.ts +2 -2
- package/dist/factories/InstrumentBox.d.ts.map +1 -1
- package/dist/factories/InstrumentFactories.d.ts +7 -5
- package/dist/factories/InstrumentFactories.d.ts.map +1 -1
- package/dist/factories/InstrumentFactories.js +21 -2
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/offline-renderer.d.ts +1 -0
- package/dist/offline-renderer.d.ts.map +1 -1
- package/dist/preset/PresetDecoder.js +1 -1
- package/dist/preset/PresetEncoder.js +1 -1
- package/dist/project/ProjectSkeleton.d.ts +1 -1
- package/dist/project/ProjectSkeleton.d.ts.map +1 -1
- package/dist/project/ProjectSkeleton.js +5 -6
- package/dist/protocols.d.ts +1 -0
- package/dist/protocols.d.ts.map +1 -1
- package/dist/selection/VertexSelection.d.ts.map +1 -1
- package/dist/selection/VertexSelection.js +2 -1
- package/dist/timeline/TrackBoxAdapter.d.ts.map +1 -1
- package/dist/timeline/TrackBoxAdapter.js +31 -1
- package/package.json +9 -9
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { asInstanceOf, isDefined, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { WerkstattParameterBox, WerkstattSampleBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { ScriptDeclaration } from "./ScriptDeclaration";
|
|
4
|
+
const COMPILER_VERSION = 1;
|
|
5
|
+
const createHeaderPattern = (tag) => new RegExp(`^// @${tag} (\\w+) (\\d+) (\\d+)\n`);
|
|
6
|
+
const parseHeader = (source, pattern) => {
|
|
7
|
+
const match = source.match(pattern);
|
|
8
|
+
return match !== null ? {
|
|
9
|
+
userCode: source.slice(match[0].length),
|
|
10
|
+
update: parseInt(match[3])
|
|
11
|
+
} : {
|
|
12
|
+
userCode: source,
|
|
13
|
+
update: 0
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
const cachedParamDeclarations = new WeakMap();
|
|
17
|
+
const reconcileParameters = (deviceBox, declared, order) => {
|
|
18
|
+
const boxGraph = deviceBox.graph;
|
|
19
|
+
const previousDeclarations = cachedParamDeclarations.get(deviceBox) ?? new Map();
|
|
20
|
+
const existingPointers = deviceBox.parameters.pointerHub.filter();
|
|
21
|
+
const existingByLabel = new Map();
|
|
22
|
+
for (const pointer of existingPointers) {
|
|
23
|
+
const paramBox = asInstanceOf(pointer.box, WerkstattParameterBox);
|
|
24
|
+
existingByLabel.set(paramBox.label.getValue(), paramBox);
|
|
25
|
+
}
|
|
26
|
+
const seen = new Set();
|
|
27
|
+
for (const { label } of declared) {
|
|
28
|
+
seen.add(label);
|
|
29
|
+
}
|
|
30
|
+
for (const [label, paramBox] of existingByLabel) {
|
|
31
|
+
if (!seen.has(label)) {
|
|
32
|
+
paramBox.delete();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
seen.clear();
|
|
36
|
+
const newDeclarations = new Map();
|
|
37
|
+
for (const declaration of declared) {
|
|
38
|
+
if (seen.has(declaration.label)) {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
seen.add(declaration.label);
|
|
42
|
+
const unifiedIndex = order.get(declaration.label) ?? 0;
|
|
43
|
+
const existing = existingByLabel.get(declaration.label);
|
|
44
|
+
const previous = previousDeclarations.get(declaration.label);
|
|
45
|
+
const declarationChanged = !isDefined(previous) || !ScriptDeclaration.isEqual(previous, declaration);
|
|
46
|
+
if (isDefined(existing) && declarationChanged) {
|
|
47
|
+
existing.delete();
|
|
48
|
+
existingByLabel.delete(declaration.label);
|
|
49
|
+
}
|
|
50
|
+
const current = existingByLabel.get(declaration.label);
|
|
51
|
+
if (isDefined(current)) {
|
|
52
|
+
if (current.index.getValue() !== unifiedIndex) {
|
|
53
|
+
current.index.setValue(unifiedIndex);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
WerkstattParameterBox.create(boxGraph, UUID.generate(), paramBox => {
|
|
58
|
+
paramBox.owner.refer(deviceBox.parameters);
|
|
59
|
+
paramBox.label.setValue(declaration.label);
|
|
60
|
+
paramBox.index.setValue(unifiedIndex);
|
|
61
|
+
paramBox.value.setValue(declaration.defaultValue);
|
|
62
|
+
paramBox.defaultValue.setValue(declaration.defaultValue);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
newDeclarations.set(declaration.label, declaration);
|
|
66
|
+
}
|
|
67
|
+
cachedParamDeclarations.set(deviceBox, newDeclarations);
|
|
68
|
+
};
|
|
69
|
+
const reconcileSamples = (deviceBox, declared, order) => {
|
|
70
|
+
const boxGraph = deviceBox.graph;
|
|
71
|
+
const existingPointers = deviceBox.samples.pointerHub.filter();
|
|
72
|
+
const existingByLabel = new Map();
|
|
73
|
+
for (const pointer of existingPointers) {
|
|
74
|
+
const sampleBox = asInstanceOf(pointer.box, WerkstattSampleBox);
|
|
75
|
+
existingByLabel.set(sampleBox.label.getValue(), sampleBox);
|
|
76
|
+
}
|
|
77
|
+
const seen = new Set();
|
|
78
|
+
for (const { label } of declared) {
|
|
79
|
+
seen.add(label);
|
|
80
|
+
}
|
|
81
|
+
for (const [label, sampleBox] of existingByLabel) {
|
|
82
|
+
if (!seen.has(label)) {
|
|
83
|
+
sampleBox.file.targetVertex.ifSome(({ box: fileBox }) => {
|
|
84
|
+
const mustDelete = fileBox.pointerHub.size() === 1;
|
|
85
|
+
sampleBox.file.defer();
|
|
86
|
+
if (mustDelete) {
|
|
87
|
+
fileBox.delete();
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
sampleBox.delete();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
seen.clear();
|
|
94
|
+
for (const declaration of declared) {
|
|
95
|
+
if (seen.has(declaration.label)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
seen.add(declaration.label);
|
|
99
|
+
const unifiedIndex = order.get(declaration.label) ?? 0;
|
|
100
|
+
const existing = existingByLabel.get(declaration.label);
|
|
101
|
+
if (isDefined(existing)) {
|
|
102
|
+
if (existing.index.getValue() !== unifiedIndex) {
|
|
103
|
+
existing.index.setValue(unifiedIndex);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
WerkstattSampleBox.create(boxGraph, UUID.generate(), sampleBox => {
|
|
108
|
+
sampleBox.owner.refer(deviceBox.samples);
|
|
109
|
+
sampleBox.label.setValue(declaration.label);
|
|
110
|
+
sampleBox.index.setValue(unifiedIndex);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
const wrapCode = (config, uuid, update, userCode) => `
|
|
116
|
+
if (typeof globalThis.openDAW === "undefined") { globalThis.openDAW = {} }
|
|
117
|
+
if (typeof globalThis.openDAW.${config.registryName} === "undefined") { globalThis.openDAW.${config.registryName} = {} }
|
|
118
|
+
globalThis.openDAW.${config.registryName}["${uuid}"] = {
|
|
119
|
+
update: ${update},
|
|
120
|
+
create: (function ${config.functionName}() {
|
|
121
|
+
${userCode}
|
|
122
|
+
return Processor
|
|
123
|
+
})()
|
|
124
|
+
}
|
|
125
|
+
`;
|
|
126
|
+
const validateCode = (wrappedCode) => { new Function(wrappedCode); };
|
|
127
|
+
const registerWorklet = async (audioContext, wrappedCode) => {
|
|
128
|
+
const blob = new Blob([wrappedCode], { type: "application/javascript" });
|
|
129
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
130
|
+
try {
|
|
131
|
+
await audioContext.audioWorklet.addModule(blobUrl);
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
URL.revokeObjectURL(blobUrl);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
export var ScriptCompiler;
|
|
138
|
+
(function (ScriptCompiler) {
|
|
139
|
+
ScriptCompiler.create = (config) => {
|
|
140
|
+
const headerPattern = createHeaderPattern(config.headerTag);
|
|
141
|
+
const createHeader = (update) => `// @${config.headerTag} js ${COMPILER_VERSION} ${update}\n`;
|
|
142
|
+
let maxUpdate = 0;
|
|
143
|
+
return {
|
|
144
|
+
stripHeader: (source) => parseHeader(source, headerPattern).userCode,
|
|
145
|
+
load: async (audioContext, deviceBox) => {
|
|
146
|
+
const { userCode, update } = parseHeader(deviceBox.code.getValue(), headerPattern);
|
|
147
|
+
if (update === 0) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const params = ScriptDeclaration.parseParams(userCode);
|
|
151
|
+
const declMap = new Map();
|
|
152
|
+
for (const declaration of params) {
|
|
153
|
+
declMap.set(declaration.label, declaration);
|
|
154
|
+
}
|
|
155
|
+
cachedParamDeclarations.set(deviceBox, declMap);
|
|
156
|
+
const uuid = UUID.toString(deviceBox.address.uuid);
|
|
157
|
+
const wrappedCode = wrapCode(config, uuid, update, userCode);
|
|
158
|
+
validateCode(wrappedCode);
|
|
159
|
+
return registerWorklet(audioContext, wrappedCode);
|
|
160
|
+
},
|
|
161
|
+
compile: async (audioContext, editing, deviceBox, source, append = false) => {
|
|
162
|
+
const userCode = parseHeader(source, headerPattern).userCode;
|
|
163
|
+
const currentUpdate = parseHeader(deviceBox.code.getValue(), headerPattern).update;
|
|
164
|
+
maxUpdate = Math.max(maxUpdate, currentUpdate);
|
|
165
|
+
const newUpdate = maxUpdate + 1;
|
|
166
|
+
maxUpdate = newUpdate;
|
|
167
|
+
const uuid = UUID.toString(deviceBox.address.uuid);
|
|
168
|
+
const params = ScriptDeclaration.parseParams(userCode);
|
|
169
|
+
const samples = ScriptDeclaration.parseSamples(userCode);
|
|
170
|
+
const order = ScriptDeclaration.parseDeclarationOrder(userCode);
|
|
171
|
+
const wrappedCode = wrapCode(config, uuid, newUpdate, userCode);
|
|
172
|
+
validateCode(wrappedCode);
|
|
173
|
+
const label = ScriptDeclaration.parseLabel(userCode);
|
|
174
|
+
const modifier = () => {
|
|
175
|
+
deviceBox.code.setValue(createHeader(newUpdate) + userCode);
|
|
176
|
+
label.ifSome(name => deviceBox.label.setValue(name));
|
|
177
|
+
reconcileParameters(deviceBox, params, order);
|
|
178
|
+
reconcileSamples(deviceBox, samples, order);
|
|
179
|
+
};
|
|
180
|
+
if (append) {
|
|
181
|
+
editing.append(modifier);
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
editing.modify(modifier);
|
|
185
|
+
}
|
|
186
|
+
return registerWorklet(audioContext, wrappedCode);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
})(ScriptCompiler || (ScriptCompiler = {}));
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Observable, Option, StringMapping, Terminable, ValueMapping } from "@opendaw/lib-std";
|
|
2
|
+
import { Field, StringField } from "@opendaw/lib-box";
|
|
3
|
+
import { Pointers } from "@opendaw/studio-enums";
|
|
4
|
+
import { ParameterAdapterSet } from "./ParameterAdapterSet";
|
|
5
|
+
export type ParamMapping = "unipolar" | "linear" | "exp" | "int" | "bool";
|
|
6
|
+
export interface ParamDeclaration {
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly defaultValue: number;
|
|
9
|
+
readonly min: number;
|
|
10
|
+
readonly max: number;
|
|
11
|
+
readonly mapping: ParamMapping;
|
|
12
|
+
readonly unit: string;
|
|
13
|
+
}
|
|
14
|
+
export interface SampleDeclaration {
|
|
15
|
+
readonly label: string;
|
|
16
|
+
}
|
|
17
|
+
export declare namespace ScriptDeclaration {
|
|
18
|
+
export const isEqual: (a: ParamDeclaration, b: ParamDeclaration) => boolean;
|
|
19
|
+
export const parseLabel: (code: string) => Option<string>;
|
|
20
|
+
export const parseParams: (code: string) => ReadonlyArray<ParamDeclaration>;
|
|
21
|
+
export const parseSamples: (code: string) => ReadonlyArray<SampleDeclaration>;
|
|
22
|
+
export const parseDeclarationOrder: (code: string) => Map<string, number>;
|
|
23
|
+
export const resolveValueMapping: (declaration: ParamDeclaration) => ValueMapping<number>;
|
|
24
|
+
export const resolveStringMapping: (declaration: ParamDeclaration) => StringMapping<number>;
|
|
25
|
+
type ParamMapping = {
|
|
26
|
+
valueMapping: ValueMapping<number>;
|
|
27
|
+
stringMapping: StringMapping<number>;
|
|
28
|
+
};
|
|
29
|
+
export const resolveParamMappings: (declaration: ParamDeclaration) => ParamMapping;
|
|
30
|
+
export type ScriptParamsBinding = {
|
|
31
|
+
readonly terminable: Terminable;
|
|
32
|
+
readonly codeChanged: Observable<void>;
|
|
33
|
+
};
|
|
34
|
+
export const subscribeScriptParams: (parametric: ParameterAdapterSet, codeField: StringField, parametersField: Field<Pointers.Parameter>) => ScriptParamsBinding;
|
|
35
|
+
export {};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=ScriptDeclaration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptDeclaration.d.ts","sourceRoot":"","sources":["../src/ScriptDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8C,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAA;AACzI,OAAO,EAAC,KAAK,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AAEzD,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAAA;AAEzE,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAA;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAA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AAC,MAAM,qBAAqB,GAAI,YAAY,mBAAmB,EAC/B,WAAW,WAAW,EACtB,iBAAiB,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAG,mBA0ClF,CAAA;;CACJ"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { asInstanceOf, isDefined, Notifier, Option, StringMapping, Terminable, ValueMapping } from "@opendaw/lib-std";
|
|
2
|
+
import { WerkstattParameterBox } from "@opendaw/studio-boxes";
|
|
3
|
+
const LABEL_LINE = /^\/\/ @label .+$/m;
|
|
4
|
+
const PARAM_LINE = /^\/\/ @param .+$/gm;
|
|
5
|
+
const SAMPLE_LINE = /^\/\/ @sample .+$/gm;
|
|
6
|
+
const DECLARATION_LINE = /^\/\/ @(?:param|sample) \S+/gm;
|
|
7
|
+
const FLOAT_TOLERANCE = 1e-6;
|
|
8
|
+
const VALID_MAPPINGS = ["linear", "exp", "int", "bool"];
|
|
9
|
+
const BoolStringMapping = new class {
|
|
10
|
+
x(y) {
|
|
11
|
+
return { value: y >= 0.5 ? "On" : "Off", unit: "" };
|
|
12
|
+
}
|
|
13
|
+
y(x) {
|
|
14
|
+
const lower = x.trim().toLowerCase();
|
|
15
|
+
return { type: "explicit", value: (lower === "on" || lower === "true" || lower === "yes") ? 1 : 0 };
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const parseSingleParam = (line) => {
|
|
19
|
+
const tokens = line.replace(/^\/\/ @param\s+/, "").replace(/\s+\/\/.*$/, "").trim().split(/\s+/);
|
|
20
|
+
if (tokens.length === 0) {
|
|
21
|
+
throw new Error(`Malformed @param: '${line}'`);
|
|
22
|
+
}
|
|
23
|
+
const label = tokens[0];
|
|
24
|
+
if (tokens.length === 1) {
|
|
25
|
+
return { label, defaultValue: 0, min: 0, max: 1, mapping: "unipolar", unit: "" };
|
|
26
|
+
}
|
|
27
|
+
const second = tokens[1];
|
|
28
|
+
if (second === "true" || second === "false") {
|
|
29
|
+
return { label, defaultValue: second === "true" ? 1 : 0, min: 0, max: 1, mapping: "bool", unit: "" };
|
|
30
|
+
}
|
|
31
|
+
if (second === "bool") {
|
|
32
|
+
return { label, defaultValue: 0, min: 0, max: 1, mapping: "bool", unit: "" };
|
|
33
|
+
}
|
|
34
|
+
const defaultValue = parseFloat(second);
|
|
35
|
+
if (isNaN(defaultValue)) {
|
|
36
|
+
throw new Error(`Malformed @param: '${line}' — '${second}' is not a valid number`);
|
|
37
|
+
}
|
|
38
|
+
if (tokens.length === 2) {
|
|
39
|
+
return { label, defaultValue, min: 0, max: 1, mapping: "unipolar", unit: "" };
|
|
40
|
+
}
|
|
41
|
+
if (tokens.length === 3 && tokens[2] === "bool") {
|
|
42
|
+
return { label, defaultValue: defaultValue >= 0.5 ? 1 : 0, min: 0, max: 1, mapping: "bool", unit: "" };
|
|
43
|
+
}
|
|
44
|
+
if (tokens.length === 4) {
|
|
45
|
+
const min = parseFloat(tokens[2]);
|
|
46
|
+
const max = parseFloat(tokens[3]);
|
|
47
|
+
if (isNaN(min) || isNaN(max)) {
|
|
48
|
+
throw new Error(`Malformed @param: '${line}' — min/max must be numbers`);
|
|
49
|
+
}
|
|
50
|
+
if (max - min < FLOAT_TOLERANCE) {
|
|
51
|
+
throw new Error(`Malformed @param: '${line}' — min (${min}) must be less than max (${max})`);
|
|
52
|
+
}
|
|
53
|
+
if (defaultValue < min - FLOAT_TOLERANCE || defaultValue > max + FLOAT_TOLERANCE) {
|
|
54
|
+
throw new Error(`Malformed @param: '${line}' — default (${defaultValue}) must be within [${min}, ${max}]`);
|
|
55
|
+
}
|
|
56
|
+
return { label, defaultValue, min, max, mapping: "linear", unit: "" };
|
|
57
|
+
}
|
|
58
|
+
if (tokens.length < 5) {
|
|
59
|
+
throw new Error(`Malformed @param: '${line}' — expected: // @param <name> <default> <min> <max> [type] [unit]`);
|
|
60
|
+
}
|
|
61
|
+
const min = parseFloat(tokens[2]);
|
|
62
|
+
const max = parseFloat(tokens[3]);
|
|
63
|
+
const mapping = tokens[4];
|
|
64
|
+
const unit = tokens.length >= 6 ? tokens[5] : "";
|
|
65
|
+
if (isNaN(min) || isNaN(max)) {
|
|
66
|
+
throw new Error(`Malformed @param: '${line}' — min/max must be numbers`);
|
|
67
|
+
}
|
|
68
|
+
if (!VALID_MAPPINGS.includes(mapping)) {
|
|
69
|
+
throw new Error(`Malformed @param: '${line}' — unknown mapping '${mapping}' (expected: linear, exp, int, bool)`);
|
|
70
|
+
}
|
|
71
|
+
if (mapping !== "bool" && max - min < FLOAT_TOLERANCE) {
|
|
72
|
+
throw new Error(`Malformed @param: '${line}' — min (${min}) must be less than max (${max})`);
|
|
73
|
+
}
|
|
74
|
+
if (defaultValue < min - FLOAT_TOLERANCE || defaultValue > max + FLOAT_TOLERANCE) {
|
|
75
|
+
throw new Error(`Malformed @param: '${line}' — default (${defaultValue}) must be within [${min}, ${max}]`);
|
|
76
|
+
}
|
|
77
|
+
return { label, defaultValue, min, max, mapping, unit };
|
|
78
|
+
};
|
|
79
|
+
const declarationEquals = (a, b) => a.mapping === b.mapping && a.min === b.min && a.max === b.max && a.unit === b.unit;
|
|
80
|
+
const declarationFullEquals = (a, b) => declarationEquals(a, b) && Math.abs(a.defaultValue - b.defaultValue) < 1e-6;
|
|
81
|
+
export var ScriptDeclaration;
|
|
82
|
+
(function (ScriptDeclaration) {
|
|
83
|
+
ScriptDeclaration.isEqual = declarationFullEquals;
|
|
84
|
+
ScriptDeclaration.parseLabel = (code) => {
|
|
85
|
+
const match = LABEL_LINE.exec(code);
|
|
86
|
+
if (match === null) {
|
|
87
|
+
return Option.None;
|
|
88
|
+
}
|
|
89
|
+
const label = match[0].replace(/^\/\/ @label\s+/, "").trim();
|
|
90
|
+
if (label.length === 0) {
|
|
91
|
+
throw new Error("Malformed @label: expected: // @label <name>");
|
|
92
|
+
}
|
|
93
|
+
return Option.wrap(label);
|
|
94
|
+
};
|
|
95
|
+
ScriptDeclaration.parseParams = (code) => {
|
|
96
|
+
const params = [];
|
|
97
|
+
let match;
|
|
98
|
+
PARAM_LINE.lastIndex = 0;
|
|
99
|
+
while ((match = PARAM_LINE.exec(code)) !== null) {
|
|
100
|
+
params.push(parseSingleParam(match[0]));
|
|
101
|
+
}
|
|
102
|
+
return params;
|
|
103
|
+
};
|
|
104
|
+
ScriptDeclaration.parseSamples = (code) => {
|
|
105
|
+
const samples = [];
|
|
106
|
+
let match;
|
|
107
|
+
SAMPLE_LINE.lastIndex = 0;
|
|
108
|
+
while ((match = SAMPLE_LINE.exec(code)) !== null) {
|
|
109
|
+
const tokens = match[0].replace(/^\/\/ @sample\s+/, "").replace(/\s+\/\/.*$/, "").trim().split(/\s+/);
|
|
110
|
+
if (tokens.length === 0 || tokens[0].length === 0) {
|
|
111
|
+
throw new Error(`Malformed @sample: '${match[0]}' — expected: // @sample <name>`);
|
|
112
|
+
}
|
|
113
|
+
if (tokens.length > 1) {
|
|
114
|
+
throw new Error(`Malformed @sample: '${match[0]}' — expected: // @sample <name>`);
|
|
115
|
+
}
|
|
116
|
+
samples.push({ label: tokens[0] });
|
|
117
|
+
}
|
|
118
|
+
return samples;
|
|
119
|
+
};
|
|
120
|
+
ScriptDeclaration.parseDeclarationOrder = (code) => {
|
|
121
|
+
const order = new Map();
|
|
122
|
+
let match;
|
|
123
|
+
DECLARATION_LINE.lastIndex = 0;
|
|
124
|
+
let index = 0;
|
|
125
|
+
while ((match = DECLARATION_LINE.exec(code)) !== null) {
|
|
126
|
+
const label = match[0].replace(/^\/\/ @(?:param|sample)\s+/, "").split(/\s+/)[0];
|
|
127
|
+
if (!order.has(label)) {
|
|
128
|
+
order.set(label, index++);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return order;
|
|
132
|
+
};
|
|
133
|
+
ScriptDeclaration.resolveValueMapping = (declaration) => {
|
|
134
|
+
switch (declaration.mapping) {
|
|
135
|
+
case "unipolar":
|
|
136
|
+
return ValueMapping.unipolar();
|
|
137
|
+
case "linear":
|
|
138
|
+
return ValueMapping.linear(declaration.min, declaration.max);
|
|
139
|
+
case "exp":
|
|
140
|
+
return ValueMapping.exponential(declaration.min, declaration.max);
|
|
141
|
+
case "int":
|
|
142
|
+
return ValueMapping.linearInteger(declaration.min, declaration.max);
|
|
143
|
+
case "bool":
|
|
144
|
+
return ValueMapping.linearInteger(0, 1);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
ScriptDeclaration.resolveStringMapping = (declaration) => {
|
|
148
|
+
switch (declaration.mapping) {
|
|
149
|
+
case "unipolar":
|
|
150
|
+
return StringMapping.percent();
|
|
151
|
+
case "linear":
|
|
152
|
+
return StringMapping.numeric({ unit: declaration.unit, fractionDigits: 2 });
|
|
153
|
+
case "exp":
|
|
154
|
+
return StringMapping.numeric({ unit: declaration.unit, fractionDigits: 2 });
|
|
155
|
+
case "int":
|
|
156
|
+
return StringMapping.numeric({ unit: declaration.unit, fractionDigits: 0 });
|
|
157
|
+
case "bool":
|
|
158
|
+
return BoolStringMapping;
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
ScriptDeclaration.resolveParamMappings = (declaration) => ({
|
|
162
|
+
valueMapping: ScriptDeclaration.resolveValueMapping(declaration),
|
|
163
|
+
stringMapping: ScriptDeclaration.resolveStringMapping(declaration)
|
|
164
|
+
});
|
|
165
|
+
ScriptDeclaration.subscribeScriptParams = (parametric, codeField, parametersField) => {
|
|
166
|
+
const cachedDeclarations = new Map();
|
|
167
|
+
const codeChangedNotifier = new Notifier();
|
|
168
|
+
const terminable = Terminable.many(parametersField.pointerHub.catchupAndSubscribe({
|
|
169
|
+
onAdded: (({ box: parameterBox }) => {
|
|
170
|
+
const paramBox = asInstanceOf(parameterBox, WerkstattParameterBox);
|
|
171
|
+
const label = paramBox.label.getValue();
|
|
172
|
+
const declarations = ScriptDeclaration.parseParams(codeField.getValue());
|
|
173
|
+
const declaration = declarations.find(decl => decl.label === label);
|
|
174
|
+
const { valueMapping, stringMapping } = isDefined(declaration)
|
|
175
|
+
? ScriptDeclaration.resolveParamMappings(declaration)
|
|
176
|
+
: {
|
|
177
|
+
valueMapping: ValueMapping.unipolar(),
|
|
178
|
+
stringMapping: StringMapping.percent({ fractionDigits: 1 })
|
|
179
|
+
};
|
|
180
|
+
parametric.createParameter(paramBox.value, valueMapping, stringMapping, label, undefined, paramBox.defaultValue.getValue());
|
|
181
|
+
if (isDefined(declaration)) {
|
|
182
|
+
cachedDeclarations.set(label, declaration);
|
|
183
|
+
}
|
|
184
|
+
}),
|
|
185
|
+
onRemoved: (({ box }) => {
|
|
186
|
+
const paramBox = asInstanceOf(box, WerkstattParameterBox);
|
|
187
|
+
cachedDeclarations.delete(paramBox.label.getValue());
|
|
188
|
+
parametric.removeParameter(paramBox.value.address);
|
|
189
|
+
})
|
|
190
|
+
}), codeField.subscribe(() => {
|
|
191
|
+
const declarations = ScriptDeclaration.parseParams(codeField.getValue());
|
|
192
|
+
for (const adapter of parametric.parameters()) {
|
|
193
|
+
const newDeclaration = declarations.find(decl => decl.label === adapter.name);
|
|
194
|
+
if (!isDefined(newDeclaration)) {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
const oldDeclaration = cachedDeclarations.get(adapter.name);
|
|
198
|
+
if (isDefined(oldDeclaration) && declarationEquals(oldDeclaration, newDeclaration)) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const { valueMapping, stringMapping } = ScriptDeclaration.resolveParamMappings(newDeclaration);
|
|
202
|
+
adapter.updateMappings(valueMapping, stringMapping);
|
|
203
|
+
cachedDeclarations.set(adapter.name, newDeclaration);
|
|
204
|
+
}
|
|
205
|
+
codeChangedNotifier.notify();
|
|
206
|
+
}), codeChangedNotifier);
|
|
207
|
+
return { terminable, codeChanged: codeChangedNotifier };
|
|
208
|
+
};
|
|
209
|
+
})(ScriptDeclaration || (ScriptDeclaration = {}));
|
|
@@ -12,6 +12,7 @@ export declare class AudioUnitTracks implements Terminable {
|
|
|
12
12
|
create(type: TrackType, target: Vertex<Pointers.Automation | Pointers>, index?: int): void;
|
|
13
13
|
controls(target: Vertex<Pointers.Automation | Pointers>): Option<TrackBoxAdapter>;
|
|
14
14
|
delete(adapter: TrackBoxAdapter): void;
|
|
15
|
+
get audioUnitBox(): AudioUnitBoxAdapter["box"];
|
|
15
16
|
get collection(): IndexedBoxAdapterCollection<TrackBoxAdapter, Pointers.TrackCollection>;
|
|
16
17
|
values(): ReadonlyArray<TrackBoxAdapter>;
|
|
17
18
|
catchupAndSubscribe(listener: IndexedAdapterCollectionListener<TrackBoxAdapter>): Subscription;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AudioUnitTracks.d.ts","sourceRoot":"","sources":["../../src/audio-unit/AudioUnitTracks.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;AAE9C,OAAO,EAAC,MAAM,EAAC,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAA;AACzD,OAAO,EAAC,gCAAgC,EAAE,2BAA2B,EAAC,MAAM,gCAAgC,CAAA;AAC5G,OAAO,EAAC,eAAe,EAAC,MAAM,6BAA6B,CAAA;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAA;AAC1C,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,qBAAa,eAAgB,YAAW,UAAU;;gBAQlC,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,WAAW;IAelE,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAW1F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,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EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,GAAG,QAAQ,CAAC,GAAG,MAAM,CAAC,eAAe,CAAC;IAKjF,MAAM,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IAUtC,IAAI,YAAY,IAAI,mBAAmB,CAAC,KAAK,CAAC,CAA2B;IACzE,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"}
|
|
@@ -59,6 +59,7 @@ export class AudioUnitTracks {
|
|
|
59
59
|
}
|
|
60
60
|
adapter.box.delete();
|
|
61
61
|
}
|
|
62
|
+
get audioUnitBox() { return __classPrivateFieldGet(this, _AudioUnitTracks_adapter, "f").box; }
|
|
62
63
|
get collection() { return __classPrivateFieldGet(this, _AudioUnitTracks_collection, "f"); }
|
|
63
64
|
values() { return __classPrivateFieldGet(this, _AudioUnitTracks_collection, "f").adapters(); }
|
|
64
65
|
catchupAndSubscribe(listener) {
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Observable, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { Address, BooleanField, Int32Field, PointerField, StringField } from "@opendaw/lib-box";
|
|
3
|
+
import { WerkstattDeviceBox } from "@opendaw/studio-boxes";
|
|
4
|
+
import { Pointers } from "@opendaw/studio-enums";
|
|
5
|
+
import { AudioEffectDeviceAdapter, DeviceHost } from "../../DeviceAdapter";
|
|
6
|
+
import { LabeledAudioOutput } from "../../LabeledAudioOutputsOwner";
|
|
7
|
+
import { BoxAdaptersContext } from "../../BoxAdaptersContext";
|
|
8
|
+
import { AudioUnitBoxAdapter } from "../../audio-unit/AudioUnitBoxAdapter";
|
|
9
|
+
import { ParameterAdapterSet } from "../../ParameterAdapterSet";
|
|
10
|
+
export declare class WerkstattDeviceBoxAdapter implements AudioEffectDeviceAdapter {
|
|
11
|
+
#private;
|
|
12
|
+
readonly type = "audio-effect";
|
|
13
|
+
readonly accepts = "audio";
|
|
14
|
+
readonly manualUrl = "manuals/devices/audio/werkstatt";
|
|
15
|
+
constructor(context: BoxAdaptersContext, box: WerkstattDeviceBox);
|
|
16
|
+
get box(): WerkstattDeviceBox;
|
|
17
|
+
get uuid(): UUID.Bytes;
|
|
18
|
+
get address(): Address;
|
|
19
|
+
get indexField(): Int32Field;
|
|
20
|
+
get labelField(): StringField;
|
|
21
|
+
get enabledField(): BooleanField;
|
|
22
|
+
get minimizedField(): BooleanField;
|
|
23
|
+
get host(): PointerField<Pointers.AudioEffectHost>;
|
|
24
|
+
get parameters(): ParameterAdapterSet;
|
|
25
|
+
get codeChanged(): Observable<void>;
|
|
26
|
+
deviceHost(): DeviceHost;
|
|
27
|
+
audioUnitBoxAdapter(): AudioUnitBoxAdapter;
|
|
28
|
+
labeledAudioOutputs(): Iterable<LabeledAudioOutput>;
|
|
29
|
+
terminate(): void;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=WerkstattDeviceBoxAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WerkstattDeviceBoxAdapter.d.ts","sourceRoot":"","sources":["../../../src/devices/audio-effects/WerkstattDeviceBoxAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAsB,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAC,wBAAwB,EAAE,UAAU,EAAU,MAAM,qBAAqB,CAAA;AACjF,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,sCAAsC,CAAA;AACxE,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAA;AAG7D,qBAAa,yBAA0B,YAAW,wBAAwB;;IAGtE,QAAQ,CAAC,IAAI,kBAAiB;IAC9B,QAAQ,CAAC,OAAO,WAAU;IAC1B,QAAQ,CAAC,SAAS,qCAA6B;gBAOnC,OAAO,EAAE,kBAAkB,EAAE,GAAG,EAAE,kBAAkB;IAShE,IAAI,GAAG,IAAI,kBAAkB,CAAmB;IAChD,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAgC;IACtD,IAAI,OAAO,IAAI,OAAO,CAA2B;IACjD,IAAI,UAAU,IAAI,UAAU,CAAyB;IACrD,IAAI,UAAU,IAAI,WAAW,CAAyB;IACtD,IAAI,YAAY,IAAI,YAAY,CAA2B;IAC3D,IAAI,cAAc,IAAI,YAAY,CAA6B;IAC/D,IAAI,IAAI,IAAI,YAAY,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAwB;IAC1E,IAAI,UAAU,IAAI,mBAAmB,CAA0B;IAC/D,IAAI,WAAW,IAAI,UAAU,CAAC,IAAI,CAAC,CAA2B;IAE9D,UAAU,IAAI,UAAU;IAKxB,mBAAmB,IAAI,mBAAmB;IAEzC,mBAAmB,IAAI,QAAQ,CAAC,kBAAkB,CAAC;IAIpD,SAAS,IAAI,IAAI;CACpB"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 _WerkstattDeviceBoxAdapter_terminator, _WerkstattDeviceBoxAdapter_context, _WerkstattDeviceBoxAdapter_box, _WerkstattDeviceBoxAdapter_parametric, _WerkstattDeviceBoxAdapter_codeChanged;
|
|
13
|
+
import { Option, Terminator } from "@opendaw/lib-std";
|
|
14
|
+
import { Devices } from "../../DeviceAdapter";
|
|
15
|
+
import { DeviceManualUrls } from "../../DeviceManualUrls";
|
|
16
|
+
import { ParameterAdapterSet } from "../../ParameterAdapterSet";
|
|
17
|
+
import { ScriptDeclaration } from "../../ScriptDeclaration";
|
|
18
|
+
export class WerkstattDeviceBoxAdapter {
|
|
19
|
+
constructor(context, box) {
|
|
20
|
+
_WerkstattDeviceBoxAdapter_terminator.set(this, new Terminator());
|
|
21
|
+
this.type = "audio-effect";
|
|
22
|
+
this.accepts = "audio";
|
|
23
|
+
this.manualUrl = DeviceManualUrls.Werkstatt;
|
|
24
|
+
_WerkstattDeviceBoxAdapter_context.set(this, void 0);
|
|
25
|
+
_WerkstattDeviceBoxAdapter_box.set(this, void 0);
|
|
26
|
+
_WerkstattDeviceBoxAdapter_parametric.set(this, void 0);
|
|
27
|
+
_WerkstattDeviceBoxAdapter_codeChanged.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _WerkstattDeviceBoxAdapter_context, context, "f");
|
|
29
|
+
__classPrivateFieldSet(this, _WerkstattDeviceBoxAdapter_box, box, "f");
|
|
30
|
+
__classPrivateFieldSet(this, _WerkstattDeviceBoxAdapter_parametric, __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_terminator, "f").own(new ParameterAdapterSet(__classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_context, "f"))), "f");
|
|
31
|
+
const { terminable, codeChanged } = ScriptDeclaration.subscribeScriptParams(__classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_parametric, "f"), box.code, box.parameters);
|
|
32
|
+
__classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_terminator, "f").own(terminable);
|
|
33
|
+
__classPrivateFieldSet(this, _WerkstattDeviceBoxAdapter_codeChanged, codeChanged, "f");
|
|
34
|
+
}
|
|
35
|
+
get box() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f"); }
|
|
36
|
+
get uuid() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").address.uuid; }
|
|
37
|
+
get address() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").address; }
|
|
38
|
+
get indexField() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").index; }
|
|
39
|
+
get labelField() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").label; }
|
|
40
|
+
get enabledField() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").enabled; }
|
|
41
|
+
get minimizedField() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").minimized; }
|
|
42
|
+
get host() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").host; }
|
|
43
|
+
get parameters() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_parametric, "f"); }
|
|
44
|
+
get codeChanged() { return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_codeChanged, "f"); }
|
|
45
|
+
deviceHost() {
|
|
46
|
+
return __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_context, "f").boxAdapters
|
|
47
|
+
.adapterFor(__classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_box, "f").host.targetVertex.unwrap("no device-host").box, Devices.isHost);
|
|
48
|
+
}
|
|
49
|
+
audioUnitBoxAdapter() { return this.deviceHost().audioUnitBoxAdapter(); }
|
|
50
|
+
*labeledAudioOutputs() {
|
|
51
|
+
yield { address: this.address, label: this.labelField.getValue(), children: () => Option.None };
|
|
52
|
+
}
|
|
53
|
+
terminate() { __classPrivateFieldGet(this, _WerkstattDeviceBoxAdapter_terminator, "f").terminate(); }
|
|
54
|
+
}
|
|
55
|
+
_WerkstattDeviceBoxAdapter_terminator = new WeakMap(), _WerkstattDeviceBoxAdapter_context = new WeakMap(), _WerkstattDeviceBoxAdapter_box = new WeakMap(), _WerkstattDeviceBoxAdapter_parametric = new WeakMap(), _WerkstattDeviceBoxAdapter_codeChanged = new WeakMap();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Observable, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { Address, BooleanField, StringField } from "@opendaw/lib-box";
|
|
3
|
+
import { ApparatDeviceBox } from "@opendaw/studio-boxes";
|
|
4
|
+
import { DeviceHost, InstrumentDeviceBoxAdapter } from "../../DeviceAdapter";
|
|
5
|
+
import { LabeledAudioOutput } from "../../LabeledAudioOutputsOwner";
|
|
6
|
+
import { BoxAdaptersContext } from "../../BoxAdaptersContext";
|
|
7
|
+
import { ParameterAdapterSet } from "../../ParameterAdapterSet";
|
|
8
|
+
import { TrackType } from "../../timeline/TrackType";
|
|
9
|
+
import { AudioUnitBoxAdapter } from "../../audio-unit/AudioUnitBoxAdapter";
|
|
10
|
+
export declare class ApparatDeviceBoxAdapter implements InstrumentDeviceBoxAdapter {
|
|
11
|
+
#private;
|
|
12
|
+
readonly type = "instrument";
|
|
13
|
+
readonly accepts = "midi";
|
|
14
|
+
readonly manualUrl = "manuals/devices/instruments/apparat";
|
|
15
|
+
constructor(context: BoxAdaptersContext, box: ApparatDeviceBox);
|
|
16
|
+
get box(): ApparatDeviceBox;
|
|
17
|
+
get uuid(): UUID.Bytes;
|
|
18
|
+
get address(): Address;
|
|
19
|
+
get labelField(): StringField;
|
|
20
|
+
get iconField(): StringField;
|
|
21
|
+
get defaultTrackType(): TrackType;
|
|
22
|
+
get enabledField(): BooleanField;
|
|
23
|
+
get minimizedField(): BooleanField;
|
|
24
|
+
get acceptsMidiEvents(): boolean;
|
|
25
|
+
get parameters(): ParameterAdapterSet;
|
|
26
|
+
get codeChanged(): Observable<void>;
|
|
27
|
+
deviceHost(): DeviceHost;
|
|
28
|
+
audioUnitBoxAdapter(): AudioUnitBoxAdapter;
|
|
29
|
+
labeledAudioOutputs(): Iterable<LabeledAudioOutput>;
|
|
30
|
+
terminate(): void;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=ApparatDeviceBoxAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApparatDeviceBoxAdapter.d.ts","sourceRoot":"","sources":["../../../src/devices/instruments/ApparatDeviceBoxAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAsB,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrE,OAAO,EAAC,OAAO,EAAE,YAAY,EAAE,WAAW,EAAC,MAAM,kBAAkB,CAAA;AACnE,OAAO,EAAC,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAC,UAAU,EAAW,0BAA0B,EAAC,MAAM,qBAAqB,CAAA;AACnF,OAAO,EAAC,kBAAkB,EAAC,MAAM,gCAAgC,CAAA;AACjE,OAAO,EAAC,kBAAkB,EAAC,MAAM,0BAA0B,CAAA;AAE3D,OAAO,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAA;AAC7D,OAAO,EAAC,SAAS,EAAC,MAAM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