@opendaw/studio-scripting 0.0.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.
- package/README.md +24 -0
- package/dist/Api.d.ts +259 -0
- package/dist/Api.d.ts.map +1 -0
- package/dist/Api.js +4 -0
- package/dist/Asserts.d.ts +4 -0
- package/dist/Asserts.d.ts.map +1 -0
- package/dist/Asserts.js +53 -0
- package/dist/AudioEffectFactory.d.ts +7 -0
- package/dist/AudioEffectFactory.d.ts.map +1 -0
- package/dist/AudioEffectFactory.js +23 -0
- package/dist/AudioFileBoxfactory.d.ts +6 -0
- package/dist/AudioFileBoxfactory.d.ts.map +1 -0
- package/dist/AudioFileBoxfactory.js +10 -0
- package/dist/AudioTrackWriter.d.ts +8 -0
- package/dist/AudioTrackWriter.d.ts.map +1 -0
- package/dist/AudioTrackWriter.js +39 -0
- package/dist/AudioUnitBoxFactory.d.ts +6 -0
- package/dist/AudioUnitBoxFactory.d.ts.map +1 -0
- package/dist/AudioUnitBoxFactory.js +116 -0
- package/dist/IndexRef.d.ts +5 -0
- package/dist/IndexRef.d.ts.map +1 -0
- package/dist/IndexRef.js +1 -0
- package/dist/MIDIEffectFactory.d.ts +7 -0
- package/dist/MIDIEffectFactory.d.ts.map +1 -0
- package/dist/MIDIEffectFactory.js +20 -0
- package/dist/NoteTrackWriter.d.ts +9 -0
- package/dist/NoteTrackWriter.d.ts.map +1 -0
- package/dist/NoteTrackWriter.js +45 -0
- package/dist/ProjectConverter.d.ts +6 -0
- package/dist/ProjectConverter.d.ts.map +1 -0
- package/dist/ProjectConverter.js +39 -0
- package/dist/ProjectUnpacker.d.ts +6 -0
- package/dist/ProjectUnpacker.d.ts.map +1 -0
- package/dist/ProjectUnpacker.js +14 -0
- package/dist/ScriptExecutionProtocol.d.ts +7 -0
- package/dist/ScriptExecutionProtocol.d.ts.map +1 -0
- package/dist/ScriptExecutionProtocol.js +1 -0
- package/dist/ScriptHost.d.ts +8 -0
- package/dist/ScriptHost.d.ts.map +1 -0
- package/dist/ScriptHost.js +23 -0
- package/dist/ScriptHostProtocol.d.ts +10 -0
- package/dist/ScriptHostProtocol.d.ts.map +1 -0
- package/dist/ScriptHostProtocol.js +1 -0
- package/dist/ScriptRunner.d.ts +8 -0
- package/dist/ScriptRunner.d.ts.map +1 -0
- package/dist/ScriptRunner.js +22 -0
- package/dist/ScriptWorker.d.ts +2 -0
- package/dist/ScriptWorker.d.ts.map +1 -0
- package/dist/ScriptWorker.js +21 -0
- package/dist/ValueTrackWriter.d.ts +10 -0
- package/dist/ValueTrackWriter.d.ts.map +1 -0
- package/dist/ValueTrackWriter.js +78 -0
- package/dist/impl/ApiImpl.d.ts +12 -0
- package/dist/impl/ApiImpl.d.ts.map +1 -0
- package/dist/impl/ApiImpl.js +19 -0
- package/dist/impl/AudioRegionImpl.d.ts +19 -0
- package/dist/impl/AudioRegionImpl.d.ts.map +1 -0
- package/dist/impl/AudioRegionImpl.js +27 -0
- package/dist/impl/AudioTrackImpl.d.ts +12 -0
- package/dist/impl/AudioTrackImpl.d.ts.map +1 -0
- package/dist/impl/AudioTrackImpl.js +17 -0
- package/dist/impl/AudioUnitImpl.d.ts +25 -0
- package/dist/impl/AudioUnitImpl.d.ts.map +1 -0
- package/dist/impl/AudioUnitImpl.js +73 -0
- package/dist/impl/AuxAudioUnitImpl.d.ts +13 -0
- package/dist/impl/AuxAudioUnitImpl.d.ts.map +1 -0
- package/dist/impl/AuxAudioUnitImpl.js +19 -0
- package/dist/impl/DelayEffectImpl.d.ts +14 -0
- package/dist/impl/DelayEffectImpl.d.ts.map +1 -0
- package/dist/impl/DelayEffectImpl.js +21 -0
- package/dist/impl/GroupAudioUnitImpl.d.ts +13 -0
- package/dist/impl/GroupAudioUnitImpl.d.ts.map +1 -0
- package/dist/impl/GroupAudioUnitImpl.js +19 -0
- package/dist/impl/InstrumentAudioUnitImpl.d.ts +15 -0
- package/dist/impl/InstrumentAudioUnitImpl.d.ts.map +1 -0
- package/dist/impl/InstrumentAudioUnitImpl.js +24 -0
- package/dist/impl/InstrumentImpl.d.ts +9 -0
- package/dist/impl/InstrumentImpl.d.ts.map +1 -0
- package/dist/impl/InstrumentImpl.js +10 -0
- package/dist/impl/NoteEventImpl.d.ts +11 -0
- package/dist/impl/NoteEventImpl.d.ts.map +1 -0
- package/dist/impl/NoteEventImpl.js +14 -0
- package/dist/impl/NoteRegionImpl.d.ts +21 -0
- package/dist/impl/NoteRegionImpl.d.ts.map +1 -0
- package/dist/impl/NoteRegionImpl.js +36 -0
- package/dist/impl/NoteTrackImpl.d.ts +12 -0
- package/dist/impl/NoteTrackImpl.d.ts.map +1 -0
- package/dist/impl/NoteTrackImpl.js +17 -0
- package/dist/impl/OutputAudioUnitImpl.d.ts +7 -0
- package/dist/impl/OutputAudioUnitImpl.d.ts.map +1 -0
- package/dist/impl/OutputAudioUnitImpl.js +5 -0
- package/dist/impl/PitchEffectImpl.d.ts +12 -0
- package/dist/impl/PitchEffectImpl.d.ts.map +1 -0
- package/dist/impl/PitchEffectImpl.js +15 -0
- package/dist/impl/ProjectImpl.d.ts +25 -0
- package/dist/impl/ProjectImpl.d.ts.map +1 -0
- package/dist/impl/ProjectImpl.js +42 -0
- package/dist/impl/SendImpl.d.ts +10 -0
- package/dist/impl/SendImpl.d.ts.map +1 -0
- package/dist/impl/SendImpl.js +12 -0
- package/dist/impl/ValueEventImpl.d.ts +11 -0
- package/dist/impl/ValueEventImpl.d.ts.map +1 -0
- package/dist/impl/ValueEventImpl.js +12 -0
- package/dist/impl/ValueRegionImpl.d.ts +21 -0
- package/dist/impl/ValueRegionImpl.d.ts.map +1 -0
- package/dist/impl/ValueRegionImpl.js +37 -0
- package/dist/impl/ValueTrackImpl.d.ts +14 -0
- package/dist/impl/ValueTrackImpl.d.ts.map +1 -0
- package/dist/impl/ValueTrackImpl.js +21 -0
- package/dist/impl/index.d.ts +18 -0
- package/dist/impl/index.d.ts.map +1 -0
- package/dist/impl/index.js +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +14 -0
- package/package.json +44 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { NoteTrackImpl } from "./impl";
|
|
2
|
+
import { AudioUnitBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { BoxGraph } from "@opendaw/lib-box";
|
|
4
|
+
import { IndexRef } from "./IndexRef";
|
|
5
|
+
export declare class NoteTrackWriter {
|
|
6
|
+
#private;
|
|
7
|
+
write(boxGraph: BoxGraph, audioUnitBox: AudioUnitBox, noteTracks: ReadonlyArray<NoteTrackImpl>, indexRef: IndexRef): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=NoteTrackWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NoteTrackWriter.d.ts","sourceRoot":"","sources":["../src/NoteTrackWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,aAAa,EAAC,MAAM,QAAQ,CAAA;AAEpD,OAAO,EAAC,YAAY,EAAgE,MAAM,uBAAuB,CAAA;AAEjH,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAEnC,qBAAa,eAAe;;IAGxB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,aAAa,CAAC,aAAa,CAAC,EACxC,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAyClC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { asDefined, isDefined, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { TrackType } from "@opendaw/studio-adapters";
|
|
4
|
+
export class NoteTrackWriter {
|
|
5
|
+
#map = new Map();
|
|
6
|
+
write(boxGraph, audioUnitBox, noteTracks, indexRef) {
|
|
7
|
+
noteTracks.forEach(({ enabled, regions }) => {
|
|
8
|
+
const trackBox = TrackBox.create(boxGraph, UUID.generate(), box => {
|
|
9
|
+
box.type.setValue(TrackType.Notes);
|
|
10
|
+
box.enabled.setValue(enabled);
|
|
11
|
+
box.index.setValue(indexRef.index++);
|
|
12
|
+
box.target.refer(audioUnitBox);
|
|
13
|
+
box.tracks.refer(audioUnitBox.tracks);
|
|
14
|
+
});
|
|
15
|
+
regions.forEach((region) => {
|
|
16
|
+
const { position, duration, loopDuration, loopOffset, events, hue, label, mute, mirror } = region;
|
|
17
|
+
const noteEventCollectionBox = isDefined(mirror)
|
|
18
|
+
? asDefined(this.#map.get(mirror), "mirror region not found in map")
|
|
19
|
+
: NoteEventCollectionBox.create(boxGraph, UUID.generate());
|
|
20
|
+
this.#map.set(region, noteEventCollectionBox);
|
|
21
|
+
events.forEach(event => {
|
|
22
|
+
NoteEventBox.create(boxGraph, UUID.generate(), box => {
|
|
23
|
+
box.position.setValue(event.position);
|
|
24
|
+
box.duration.setValue(event.duration);
|
|
25
|
+
box.pitch.setValue(event.pitch);
|
|
26
|
+
box.cent.setValue(event.cents); // TODO rename to plural
|
|
27
|
+
box.velocity.setValue(event.velocity);
|
|
28
|
+
box.events.refer(noteEventCollectionBox.events);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
NoteRegionBox.create(boxGraph, UUID.generate(), box => {
|
|
32
|
+
box.position.setValue(position);
|
|
33
|
+
box.duration.setValue(duration);
|
|
34
|
+
box.loopDuration.setValue(loopDuration);
|
|
35
|
+
box.loopOffset.setValue(loopOffset);
|
|
36
|
+
box.hue.setValue(hue);
|
|
37
|
+
box.label.setValue(label);
|
|
38
|
+
box.mute.setValue(mute);
|
|
39
|
+
box.regions.refer(trackBox.regions);
|
|
40
|
+
box.events.refer(noteEventCollectionBox.owners);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectConverter.d.ts","sourceRoot":"","sources":["../src/ProjectConverter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,eAAe,EAAY,MAAM,0BAA0B,CAAA;AACnE,OAAO,EAAC,WAAW,EAAC,MAAM,QAAQ,CAAA;AAIlC,yBAAiB,gBAAgB,CAAC;IACvB,MAAM,UAAU,GAAI,SAAS,WAAW,KAAG,eAgCjD,CAAA;CACJ"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { asInstanceOf, isDefined } from "@opendaw/lib-std";
|
|
2
|
+
import { AudioUnitBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { ProjectSkeleton, Validator } from "@opendaw/studio-adapters";
|
|
4
|
+
import { Asserts } from "./Asserts";
|
|
5
|
+
import { AudioUnitBoxFactory } from "./AudioUnitBoxFactory";
|
|
6
|
+
export var ProjectConverter;
|
|
7
|
+
(function (ProjectConverter) {
|
|
8
|
+
ProjectConverter.toSkeleton = (project) => {
|
|
9
|
+
Asserts.assertNoNaN(project);
|
|
10
|
+
console.time("convert");
|
|
11
|
+
const skeleton = ProjectSkeleton.empty({
|
|
12
|
+
createDefaultUser: true,
|
|
13
|
+
createOutputCompressor: false
|
|
14
|
+
});
|
|
15
|
+
const { boxGraph, mandatoryBoxes: { rootBox, timelineBox, userInterfaceBoxes: [defaultUser] } } = skeleton;
|
|
16
|
+
const { bpm, timeSignature } = project;
|
|
17
|
+
boxGraph.beginTransaction();
|
|
18
|
+
timelineBox.bpm.setValue(Validator.clampBpm(bpm));
|
|
19
|
+
const [numerator, denominator] = Validator.isTimeSignatureValid(timeSignature.numerator, timeSignature.denominator).result();
|
|
20
|
+
timelineBox.signature.nominator.setValue(numerator);
|
|
21
|
+
timelineBox.signature.denominator.setValue(denominator);
|
|
22
|
+
AudioUnitBoxFactory.create(skeleton, project);
|
|
23
|
+
// select the first audio unit as the editing device
|
|
24
|
+
const firstAudioUnitBox = rootBox.audioUnits.pointerHub.incoming()
|
|
25
|
+
.map(({ box }) => asInstanceOf(box, AudioUnitBox))
|
|
26
|
+
.sort(({ index: a }, { index: b }) => a.getValue() - b.getValue())
|
|
27
|
+
.at(0);
|
|
28
|
+
if (isDefined(firstAudioUnitBox)) {
|
|
29
|
+
defaultUser.editingDeviceChain.refer(firstAudioUnitBox.editing);
|
|
30
|
+
}
|
|
31
|
+
boxGraph.endTransaction();
|
|
32
|
+
console.timeEnd("convert");
|
|
33
|
+
boxGraph.verifyPointers();
|
|
34
|
+
if (Validator.hasOverlappingRegions(boxGraph)) {
|
|
35
|
+
throw new Error("Project contains overlapping regions");
|
|
36
|
+
}
|
|
37
|
+
return skeleton;
|
|
38
|
+
};
|
|
39
|
+
})(ProjectConverter || (ProjectConverter = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectUnpacker.d.ts","sourceRoot":"","sources":["../src/ProjectUnpacker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAC,OAAO,EAAc,MAAM,QAAQ,CAAA;AAE3C,yBAAiB,eAAe,CAAC;IACtB,MAAM,MAAM,GAAI,KAAK,OAAO,EAAE,QAAQ,eAAe,EAAE,MAAM,MAAM,KAAG,OAU5E,CAAA;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ProjectSkeleton } from "@opendaw/studio-adapters";
|
|
2
|
+
import { ProjectImpl } from "./impl";
|
|
3
|
+
export var ProjectUnpacker;
|
|
4
|
+
(function (ProjectUnpacker) {
|
|
5
|
+
ProjectUnpacker.unpack = (api, buffer, name) => {
|
|
6
|
+
const { boxGraph, mandatoryBoxes: { timelineBox } } = ProjectSkeleton.decode(buffer);
|
|
7
|
+
const project = new ProjectImpl(api, name);
|
|
8
|
+
project.bpm = timelineBox.bpm.getValue();
|
|
9
|
+
project.timeSignature.numerator = timelineBox.signature.nominator.getValue();
|
|
10
|
+
project.timeSignature.denominator = timelineBox.signature.denominator.getValue();
|
|
11
|
+
// TODO
|
|
12
|
+
return project;
|
|
13
|
+
};
|
|
14
|
+
})(ProjectUnpacker || (ProjectUnpacker = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptExecutionProtocol.d.ts","sourceRoot":"","sources":["../src/ScriptExecutionProtocol.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,sBAAsB,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAE3D,MAAM,WAAW,uBAAuB;IACpC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAChF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ScriptExecutionContext, ScriptExecutionProtocol } from "./ScriptExecutionProtocol";
|
|
2
|
+
import { ScriptHostProtocol } from "./ScriptHostProtocol";
|
|
3
|
+
export declare class ScriptHost implements ScriptExecutionProtocol {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(host: ScriptHostProtocol, scriptURL: string);
|
|
6
|
+
executeScript(script: string, context: ScriptExecutionContext): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ScriptHost.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptHost.d.ts","sourceRoot":"","sources":["../src/ScriptHost.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,sBAAsB,EAAE,uBAAuB,EAAC,MAAM,2BAA2B,CAAA;AACzF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AAEvD,qBAAa,UAAW,YAAW,uBAAuB;;gBAG1C,IAAI,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM;IAWjD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;CAStF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { RuntimeNotifier } from "@opendaw/lib-std";
|
|
2
|
+
import { Communicator, Messenger, Promises } from "@opendaw/lib-runtime";
|
|
3
|
+
export class ScriptHost {
|
|
4
|
+
#executor;
|
|
5
|
+
constructor(host, scriptURL) {
|
|
6
|
+
const messenger = Messenger.for(new Worker(scriptURL, { type: "module" }));
|
|
7
|
+
Communicator.executor(messenger.channel("scripting-host"), host);
|
|
8
|
+
this.#executor = Communicator.sender(messenger.channel("scripting-execution"), dispatcher => new class {
|
|
9
|
+
executeScript(script, context) {
|
|
10
|
+
return dispatcher.dispatchAndReturn(this.executeScript, script, context);
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
async executeScript(script, context) {
|
|
15
|
+
const progressUpdater = RuntimeNotifier.progress({ headline: "Executing Script..." });
|
|
16
|
+
const { status, error } = await Promises.tryCatch(this.#executor.executeScript(script, context));
|
|
17
|
+
progressUpdater.terminate();
|
|
18
|
+
if (status === "rejected") {
|
|
19
|
+
console.warn(error);
|
|
20
|
+
await RuntimeNotifier.info({ headline: "The script caused an error", message: String(error) });
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AudioData, Sample } from "@opendaw/studio-adapters";
|
|
2
|
+
export interface ScriptHostProtocol {
|
|
3
|
+
openProject(buffer: ArrayBufferLike, name?: string): void;
|
|
4
|
+
fetchProject(): Promise<{
|
|
5
|
+
buffer: ArrayBuffer;
|
|
6
|
+
name: string;
|
|
7
|
+
}>;
|
|
8
|
+
addSample(data: AudioData, name: string): Promise<Sample>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ScriptHostProtocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptHostProtocol.d.ts","sourceRoot":"","sources":["../src/ScriptHostProtocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAA;AAE1D,MAAM,WAAW,kBAAkB;IAC/B,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAEzD,YAAY,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,WAAW,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;IAE9D,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;CAC5D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ScriptHostProtocol } from "./ScriptHostProtocol";
|
|
2
|
+
import { ScriptExecutionContext } from "./ScriptExecutionProtocol";
|
|
3
|
+
export declare class ScriptRunner {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(protocol: ScriptHostProtocol);
|
|
6
|
+
run(jsCode: string, context: ScriptExecutionContext): Promise<void>;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=ScriptRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptRunner.d.ts","sourceRoot":"","sources":["../src/ScriptRunner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAC,sBAAsB,EAAC,MAAM,2BAA2B,CAAA;AAIhE,qBAAa,YAAY;;gBAGT,QAAQ,EAAE,kBAAkB;IAElC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB;CAc5D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Chord, dbToGain, FFT, gainToDb, Interpolation, midiToHz, PPQN } from "@opendaw/lib-dsp";
|
|
2
|
+
import { AudioPlayback } from "@opendaw/studio-enums";
|
|
3
|
+
import { ApiImpl } from "./impl";
|
|
4
|
+
export class ScriptRunner {
|
|
5
|
+
#api;
|
|
6
|
+
constructor(protocol) { this.#api = new ApiImpl(protocol); }
|
|
7
|
+
async run(jsCode, context) {
|
|
8
|
+
Object.assign(globalThis, {
|
|
9
|
+
...context,
|
|
10
|
+
openDAW: this.#api,
|
|
11
|
+
AudioPlayback, midiToHz, PPQN, FFT, Chord, Interpolation, dbToGain, gainToDb
|
|
12
|
+
});
|
|
13
|
+
const blob = new Blob([jsCode], { type: "text/javascript" });
|
|
14
|
+
const url = URL.createObjectURL(blob);
|
|
15
|
+
try {
|
|
16
|
+
await import(url);
|
|
17
|
+
}
|
|
18
|
+
finally {
|
|
19
|
+
URL.revokeObjectURL(url);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScriptWorker.d.ts","sourceRoot":"","sources":["../src/ScriptWorker.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Communicator, Messenger } from "@opendaw/lib-runtime";
|
|
2
|
+
import { ScriptRunner } from "./ScriptRunner";
|
|
3
|
+
const messenger = Messenger.for(self);
|
|
4
|
+
const hostProtocol = Communicator.sender(messenger.channel("scripting-host"), dispatcher => new class {
|
|
5
|
+
openProject(buffer, name) {
|
|
6
|
+
dispatcher.dispatchAndForget(this.openProject, buffer, name);
|
|
7
|
+
}
|
|
8
|
+
fetchProject() {
|
|
9
|
+
return dispatcher.dispatchAndReturn(this.fetchProject);
|
|
10
|
+
}
|
|
11
|
+
addSample(data, name) {
|
|
12
|
+
return dispatcher.dispatchAndReturn(this.addSample, data, name);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Communicator.executor(messenger.channel("scripting-execution"), new class {
|
|
16
|
+
#scriptExecutor = new ScriptRunner(hostProtocol);
|
|
17
|
+
// TODO We might return information about the script execution, e.g. warnings
|
|
18
|
+
executeScript(script, context) {
|
|
19
|
+
return this.#scriptExecutor.run(script, context);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValueTrackImpl } from "./impl";
|
|
2
|
+
import { AudioUnitBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { Box, BoxGraph } from "@opendaw/lib-box";
|
|
4
|
+
import { AnyDevice } from "./Api";
|
|
5
|
+
import { IndexRef } from "./IndexRef";
|
|
6
|
+
export declare class ValueTrackWriter {
|
|
7
|
+
#private;
|
|
8
|
+
write(boxGraph: BoxGraph, devices: Map<AnyDevice, Box>, audioUnitBox: AudioUnitBox, valueTracks: ReadonlyArray<ValueTrackImpl>, indexRef: IndexRef): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ValueTrackWriter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValueTrackWriter.d.ts","sourceRoot":"","sources":["../src/ValueTrackWriter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,cAAc,EAAC,MAAM,QAAQ,CAAA;AAEtE,OAAO,EAAC,YAAY,EAAmE,MAAM,uBAAuB,CAAA;AAEpH,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAC,SAAS,EAAc,MAAM,OAAO,CAAA;AAC5C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAEnC,qBAAa,gBAAgB;;IAGzB,KAAK,CAAC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,EAC5B,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,aAAa,CAAC,cAAc,CAAC,EAC1C,QAAQ,EAAE,QAAQ,GAAG,IAAI;CAsElC"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { asDefined, isDefined, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { TrackBox, ValueEventBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
|
3
|
+
import { InterpolationFieldAdapter, TrackType } from "@opendaw/studio-adapters";
|
|
4
|
+
export class ValueTrackWriter {
|
|
5
|
+
#map = new Map();
|
|
6
|
+
write(boxGraph, devices, audioUnitBox, valueTracks, indexRef) {
|
|
7
|
+
valueTracks.forEach(({ enabled, regions, device, parameter }) => {
|
|
8
|
+
const box = asDefined(devices.get(device), `Could not find ${device.constructor.name}`);
|
|
9
|
+
const field = box[parameter];
|
|
10
|
+
const trackBox = TrackBox.create(boxGraph, UUID.generate(), box => {
|
|
11
|
+
box.type.setValue(TrackType.Value);
|
|
12
|
+
box.enabled.setValue(enabled);
|
|
13
|
+
box.index.setValue(indexRef.index++);
|
|
14
|
+
box.target.refer(field);
|
|
15
|
+
box.tracks.refer(audioUnitBox.tracks);
|
|
16
|
+
});
|
|
17
|
+
regions.forEach((region) => {
|
|
18
|
+
const { position, duration, loopDuration, loopOffset, events, hue, label, mute, mirror } = region;
|
|
19
|
+
const valueEventCollectionBox = isDefined(mirror)
|
|
20
|
+
? asDefined(this.#map.get(mirror), "mirror region not found in map")
|
|
21
|
+
: ValueEventCollectionBox.create(boxGraph, UUID.generate());
|
|
22
|
+
this.#map.set(region, valueEventCollectionBox);
|
|
23
|
+
this.#orderValueEvents(events).forEach(event => {
|
|
24
|
+
const valueEvent = ValueEventBox.create(boxGraph, UUID.generate(), box => {
|
|
25
|
+
box.position.setValue(event.position);
|
|
26
|
+
box.value.setValue(event.value);
|
|
27
|
+
box.slope.setValue(NaN); // deprecated
|
|
28
|
+
box.index.setValue(event.index);
|
|
29
|
+
box.events.refer(valueEventCollectionBox.events);
|
|
30
|
+
});
|
|
31
|
+
InterpolationFieldAdapter.write(valueEvent.interpolation, event.interpolation);
|
|
32
|
+
});
|
|
33
|
+
ValueRegionBox.create(boxGraph, UUID.generate(), box => {
|
|
34
|
+
box.position.setValue(position);
|
|
35
|
+
box.duration.setValue(duration);
|
|
36
|
+
box.loopDuration.setValue(loopDuration);
|
|
37
|
+
box.loopOffset.setValue(loopOffset);
|
|
38
|
+
box.hue.setValue(hue);
|
|
39
|
+
box.label.setValue(label);
|
|
40
|
+
box.mute.setValue(mute);
|
|
41
|
+
box.regions.refer(trackBox.regions);
|
|
42
|
+
box.events.refer(valueEventCollectionBox.owners);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
#orderValueEvents(events) {
|
|
48
|
+
if (events.length === 0)
|
|
49
|
+
return [];
|
|
50
|
+
const sorted = events.toSorted((a, b) => a.position - b.position);
|
|
51
|
+
const result = [];
|
|
52
|
+
let index = 0;
|
|
53
|
+
while (index < sorted.length) {
|
|
54
|
+
const position = sorted[index].position;
|
|
55
|
+
const start = index;
|
|
56
|
+
while (index < sorted.length && sorted[index].position === position) {
|
|
57
|
+
index++;
|
|
58
|
+
}
|
|
59
|
+
const end = index - 1;
|
|
60
|
+
if (start === end) {
|
|
61
|
+
sorted[start].index = 0;
|
|
62
|
+
result.push(sorted[start]);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
if (sorted[start].value === sorted[end].value) {
|
|
66
|
+
sorted[end].index = 0;
|
|
67
|
+
result.push(sorted[end]);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
sorted[start].index = 0;
|
|
71
|
+
sorted[end].index = 1;
|
|
72
|
+
result.push(sorted[start], sorted[end]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Api, Project } from "../Api";
|
|
2
|
+
import { ScriptHostProtocol } from "../ScriptHostProtocol";
|
|
3
|
+
import { AudioData, Sample } from "@opendaw/studio-adapters";
|
|
4
|
+
export declare class ApiImpl implements Api {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(protocol: ScriptHostProtocol);
|
|
7
|
+
newProject(name?: string): Project;
|
|
8
|
+
getProject(): Promise<Project>;
|
|
9
|
+
openProject(buffer: ArrayBufferLike, name?: string): void;
|
|
10
|
+
addSample(data: AudioData, name: string): Promise<Sample>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ApiImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiImpl.d.ts","sourceRoot":"","sources":["../../src/impl/ApiImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,OAAO,EAAC,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAC,kBAAkB,EAAC,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,0BAA0B,CAAA;AAG1D,qBAAa,OAAQ,YAAW,GAAG;;gBAGnB,QAAQ,EAAE,kBAAkB;IAExC,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO;IAI5B,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAKpC,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAIzD,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAG5D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ProjectImpl } from "./ProjectImpl";
|
|
2
|
+
import { ProjectUnpacker } from "../ProjectUnpacker";
|
|
3
|
+
export class ApiImpl {
|
|
4
|
+
#protocol;
|
|
5
|
+
constructor(protocol) { this.#protocol = protocol; }
|
|
6
|
+
newProject(name) {
|
|
7
|
+
return new ProjectImpl(this, name ?? `Scripted Project`);
|
|
8
|
+
}
|
|
9
|
+
async getProject() {
|
|
10
|
+
const { buffer, name } = await this.#protocol.fetchProject();
|
|
11
|
+
return ProjectUnpacker.unpack(this, buffer, name);
|
|
12
|
+
}
|
|
13
|
+
openProject(buffer, name) {
|
|
14
|
+
this.#protocol.openProject(buffer, name);
|
|
15
|
+
}
|
|
16
|
+
addSample(data, name) {
|
|
17
|
+
return this.#protocol.addSample(data, name);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AudioRegion, AudioTrack } from "../Api";
|
|
2
|
+
import { ppqn } from "@opendaw/lib-dsp";
|
|
3
|
+
import { int } from "@opendaw/lib-std";
|
|
4
|
+
import { Sample } from "@opendaw/studio-adapters";
|
|
5
|
+
import { AudioPlayback } from "@opendaw/studio-enums";
|
|
6
|
+
export declare class AudioRegionImpl implements AudioRegion {
|
|
7
|
+
readonly track: AudioTrack;
|
|
8
|
+
sample: Sample;
|
|
9
|
+
playback: AudioPlayback.NoSync | AudioPlayback.Pitch;
|
|
10
|
+
position: ppqn;
|
|
11
|
+
duration: ppqn;
|
|
12
|
+
mute: boolean;
|
|
13
|
+
label: string;
|
|
14
|
+
hue: int;
|
|
15
|
+
loopDuration: ppqn;
|
|
16
|
+
loopOffset: ppqn;
|
|
17
|
+
constructor(track: AudioTrack, sample: Sample, props?: Partial<AudioRegion>);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=AudioRegionImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioRegionImpl.d.ts","sourceRoot":"","sources":["../../src/impl/AudioRegionImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAA;AAC9C,OAAO,EAAO,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAa,MAAM,EAAY,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AAEnD,qBAAa,eAAgB,YAAW,WAAW;IAC/C,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;IAE1B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,aAAa,CAAC,MAAM,GAAG,aAAa,CAAC,KAAK,CAAA;IAEpD,QAAQ,EAAE,IAAI,CAAA;IACd,QAAQ,EAAE,IAAI,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,GAAG,CAAA;IACR,YAAY,EAAE,IAAI,CAAA;IAClB,UAAU,EAAE,IAAI,CAAA;gBAEJ,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC;CAY9E"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PPQN } from "@opendaw/lib-dsp";
|
|
2
|
+
import { ColorCodes, TrackType } from "@opendaw/studio-adapters";
|
|
3
|
+
import { AudioPlayback } from "@opendaw/studio-enums";
|
|
4
|
+
export class AudioRegionImpl {
|
|
5
|
+
track;
|
|
6
|
+
sample;
|
|
7
|
+
playback;
|
|
8
|
+
position;
|
|
9
|
+
duration;
|
|
10
|
+
mute;
|
|
11
|
+
label;
|
|
12
|
+
hue;
|
|
13
|
+
loopDuration;
|
|
14
|
+
loopOffset;
|
|
15
|
+
constructor(track, sample, props) {
|
|
16
|
+
this.track = track;
|
|
17
|
+
this.sample = sample;
|
|
18
|
+
this.playback = props?.playback ?? AudioPlayback.Pitch;
|
|
19
|
+
this.position = props?.position ?? 0.0;
|
|
20
|
+
this.duration = props?.duration ?? PPQN.Bar;
|
|
21
|
+
this.loopDuration = props?.loopDuration ?? this.duration;
|
|
22
|
+
this.loopOffset = props?.loopOffset ?? 0.0;
|
|
23
|
+
this.mute = props?.mute ?? false;
|
|
24
|
+
this.label = props?.label ?? "";
|
|
25
|
+
this.hue = props?.hue ?? ColorCodes.forTrackType(TrackType.Audio);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AudioRegion, AudioTrack, AudioUnit } from "../Api";
|
|
2
|
+
import { AudioRegionImpl } from "./AudioRegionImpl";
|
|
3
|
+
import { AudioUnitImpl } from "./AudioUnitImpl";
|
|
4
|
+
export declare class AudioTrackImpl implements AudioTrack {
|
|
5
|
+
#private;
|
|
6
|
+
readonly audioUnit: AudioUnit;
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
constructor(audioUnit: AudioUnitImpl, props?: Partial<AudioTrack>);
|
|
9
|
+
addRegion(sample: Sample, props?: Partial<AudioRegion>): AudioRegion;
|
|
10
|
+
get regions(): ReadonlyArray<AudioRegionImpl>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=AudioTrackImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioTrackImpl.d.ts","sourceRoot":"","sources":["../../src/impl/AudioTrackImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,qBAAa,cAAe,YAAW,UAAU;;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;IAG7B,OAAO,EAAE,OAAO,CAAA;gBAEJ,SAAS,EAAE,aAAa,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC;IAOjE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,WAAW;IAMpE,IAAI,OAAO,IAAI,aAAa,CAAC,eAAe,CAAC,CAAuB;CACvE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AudioRegionImpl } from "./AudioRegionImpl";
|
|
2
|
+
export class AudioTrackImpl {
|
|
3
|
+
audioUnit;
|
|
4
|
+
#regions;
|
|
5
|
+
enabled;
|
|
6
|
+
constructor(audioUnit, props) {
|
|
7
|
+
this.audioUnit = audioUnit;
|
|
8
|
+
this.#regions = [];
|
|
9
|
+
this.enabled = props?.enabled ?? true;
|
|
10
|
+
}
|
|
11
|
+
addRegion(sample, props) {
|
|
12
|
+
const region = new AudioRegionImpl(this, sample, props);
|
|
13
|
+
this.#regions.push(region);
|
|
14
|
+
return region;
|
|
15
|
+
}
|
|
16
|
+
get regions() { return this.#regions; }
|
|
17
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AnyDevice, AudioEffects, AudioTrack, AudioUnit, GroupAudioUnit, MIDIEffects, NoteTrack, OutputAudioUnit, ValueTrack } from "../Api";
|
|
2
|
+
import { NoteTrackImpl } from "./NoteTrackImpl";
|
|
3
|
+
import { ValueTrackImpl } from "./ValueTrackImpl";
|
|
4
|
+
import { bipolar, Nullable } from "@opendaw/lib-std";
|
|
5
|
+
import { AudioTrackImpl } from "./AudioTrackImpl";
|
|
6
|
+
export declare abstract class AudioUnitImpl implements AudioUnit {
|
|
7
|
+
#private;
|
|
8
|
+
output?: Nullable<OutputAudioUnit | GroupAudioUnit>;
|
|
9
|
+
volume: number;
|
|
10
|
+
panning: bipolar;
|
|
11
|
+
mute: boolean;
|
|
12
|
+
solo: boolean;
|
|
13
|
+
protected constructor(props?: Partial<AudioUnit>);
|
|
14
|
+
addMIDIEffect<T extends keyof MIDIEffects>(type: T, props?: Partial<MIDIEffects[T]>): MIDIEffects[T];
|
|
15
|
+
addAudioEffect<T extends keyof AudioEffects>(type: T, props?: Partial<AudioEffects[T]>): AudioEffects[T];
|
|
16
|
+
addNoteTrack(props?: Partial<NoteTrack>): NoteTrack;
|
|
17
|
+
addAudioTrack(props?: Partial<AudioTrack>): AudioTrack;
|
|
18
|
+
addValueTrack<DEVICE extends AnyDevice, PARAMETER extends keyof DEVICE>(device: DEVICE, parameter: PARAMETER, props?: Partial<ValueTrack>): ValueTrack;
|
|
19
|
+
get audioEffects(): ReadonlyArray<AudioEffects[keyof AudioEffects]>;
|
|
20
|
+
get midiEffects(): ReadonlyArray<MIDIEffects[keyof MIDIEffects]>;
|
|
21
|
+
get noteTracks(): ReadonlyArray<NoteTrackImpl>;
|
|
22
|
+
get audioTracks(): ReadonlyArray<AudioTrackImpl>;
|
|
23
|
+
get valueTracks(): ReadonlyArray<ValueTrackImpl>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=AudioUnitImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AudioUnitImpl.d.ts","sourceRoot":"","sources":["../../src/impl/AudioUnitImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,SAAS,EACT,YAAY,EACZ,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACb,MAAM,QAAQ,CAAA;AAEf,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAG/C,OAAO,EAAC,OAAO,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAE/C,8BAAsB,aAAc,YAAW,SAAS;;IAOpD,MAAM,CAAC,EAAE,QAAQ,CAAC,eAAe,GAAG,cAAc,CAAC,CAAA;IACnD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,EAAE,OAAO,CAAA;IAEb,SAAS,aAAa,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC;IAchD,aAAa,CAAC,CAAC,SAAS,MAAM,WAAW,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAapG,cAAc,CAAC,CAAC,SAAS,MAAM,YAAY,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;IAaxG,YAAY,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS;IAMnD,aAAa,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;IAMtD,aAAa,CAAC,MAAM,SAAS,SAAS,EAAE,SAAS,SAAS,MAAM,MAAM,EAClE,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU;IAMlE,IAAI,YAAY,IAAI,aAAa,CAAC,YAAY,CAAC,MAAM,YAAY,CAAC,CAAC,CAA4B;IAC/F,IAAI,WAAW,IAAI,aAAa,CAAC,WAAW,CAAC,MAAM,WAAW,CAAC,CAAC,CAA2B;IAC3F,IAAI,UAAU,IAAI,aAAa,CAAC,aAAa,CAAC,CAA0B;IACxE,IAAI,WAAW,IAAI,aAAa,CAAC,cAAc,CAAC,CAA2B;IAC3E,IAAI,WAAW,IAAI,aAAa,CAAC,cAAc,CAAC,CAA2B;CAC9E"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { NoteTrackImpl } from "./NoteTrackImpl";
|
|
2
|
+
import { ValueTrackImpl } from "./ValueTrackImpl";
|
|
3
|
+
import { DelayEffectImpl } from "./DelayEffectImpl";
|
|
4
|
+
import { PitchEffectImpl } from "./PitchEffectImpl";
|
|
5
|
+
import { AudioTrackImpl } from "./AudioTrackImpl";
|
|
6
|
+
export class AudioUnitImpl {
|
|
7
|
+
#audioEffects;
|
|
8
|
+
#midiEffects;
|
|
9
|
+
#noteTracks;
|
|
10
|
+
#valueTracks;
|
|
11
|
+
#audioTracks;
|
|
12
|
+
output;
|
|
13
|
+
volume;
|
|
14
|
+
panning;
|
|
15
|
+
mute;
|
|
16
|
+
solo;
|
|
17
|
+
constructor(props) {
|
|
18
|
+
this.#audioEffects = [];
|
|
19
|
+
this.#midiEffects = [];
|
|
20
|
+
this.#noteTracks = [];
|
|
21
|
+
this.#audioTracks = [];
|
|
22
|
+
this.#valueTracks = [];
|
|
23
|
+
this.output = props?.output;
|
|
24
|
+
this.volume = props?.volume ?? 0.0;
|
|
25
|
+
this.panning = props?.panning ?? 0.0;
|
|
26
|
+
this.mute = props?.mute ?? false;
|
|
27
|
+
this.solo = props?.solo ?? false;
|
|
28
|
+
}
|
|
29
|
+
addMIDIEffect(type, props) {
|
|
30
|
+
let effect;
|
|
31
|
+
switch (type) {
|
|
32
|
+
case "pitch":
|
|
33
|
+
effect = new PitchEffectImpl(props);
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
throw new Error(`Unknown MIDI effect type: ${type}`);
|
|
37
|
+
}
|
|
38
|
+
this.#midiEffects.push(effect);
|
|
39
|
+
return effect;
|
|
40
|
+
}
|
|
41
|
+
addAudioEffect(type, props) {
|
|
42
|
+
let effect;
|
|
43
|
+
switch (type) {
|
|
44
|
+
case "delay":
|
|
45
|
+
effect = new DelayEffectImpl(props);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(`Unknown Audio effect type: ${type}`);
|
|
49
|
+
}
|
|
50
|
+
this.#audioEffects.push(effect);
|
|
51
|
+
return effect;
|
|
52
|
+
}
|
|
53
|
+
addNoteTrack(props) {
|
|
54
|
+
const track = new NoteTrackImpl(this, props);
|
|
55
|
+
this.#noteTracks.push(track);
|
|
56
|
+
return track;
|
|
57
|
+
}
|
|
58
|
+
addAudioTrack(props) {
|
|
59
|
+
const track = new AudioTrackImpl(this, props);
|
|
60
|
+
this.#audioTracks.push(track);
|
|
61
|
+
return track;
|
|
62
|
+
}
|
|
63
|
+
addValueTrack(device, parameter, props) {
|
|
64
|
+
const track = new ValueTrackImpl(this, device, parameter, props);
|
|
65
|
+
this.#valueTracks.push(track);
|
|
66
|
+
return track;
|
|
67
|
+
}
|
|
68
|
+
get audioEffects() { return this.#audioEffects; }
|
|
69
|
+
get midiEffects() { return this.#midiEffects; }
|
|
70
|
+
get noteTracks() { return this.#noteTracks; }
|
|
71
|
+
get audioTracks() { return this.#audioTracks; }
|
|
72
|
+
get valueTracks() { return this.#valueTracks; }
|
|
73
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AuxAudioUnit, GroupAudioUnit, Send } from "../Api";
|
|
2
|
+
import { AudioUnitImpl } from "./AudioUnitImpl";
|
|
3
|
+
import { SendImpl } from "./SendImpl";
|
|
4
|
+
export declare class AuxAudioUnitImpl extends AudioUnitImpl implements AuxAudioUnit {
|
|
5
|
+
#private;
|
|
6
|
+
readonly kind: "auxiliary";
|
|
7
|
+
label: string;
|
|
8
|
+
constructor(props?: Partial<GroupAudioUnit>);
|
|
9
|
+
addSend(target: AuxAudioUnit | GroupAudioUnit, props?: Partial<Send>): Send;
|
|
10
|
+
removeSend(send: Send): void;
|
|
11
|
+
get sends(): ReadonlyArray<SendImpl>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=AuxAudioUnitImpl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuxAudioUnitImpl.d.ts","sourceRoot":"","sources":["../../src/impl/AuxAudioUnitImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,cAAc,EAAE,IAAI,EAAC,MAAM,QAAQ,CAAA;AACzD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AAGnC,qBAAa,gBAAiB,SAAQ,aAAc,YAAW,YAAY;;IACvE,QAAQ,CAAC,IAAI,EAAG,WAAW,CAAS;IAIpC,KAAK,EAAE,MAAM,CAAA;gBAED,KAAK,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC;IAM3C,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,cAAc,EAAE,KAAK,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAM3E,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAE5B,IAAI,KAAK,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAqB;CAC5D"}
|