@opendaw/studio-core 0.0.19 → 0.0.20
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/AudioInputDevices.d.ts +8 -0
- package/dist/AudioInputDevices.d.ts.map +1 -0
- package/dist/AudioInputDevices.js +30 -0
- package/dist/AudioUnitOrdering.d.ts +3 -0
- package/dist/AudioUnitOrdering.d.ts.map +1 -0
- package/dist/AudioUnitOrdering.js +7 -0
- package/dist/EffectBox.d.ts +2 -2
- package/dist/EffectBox.d.ts.map +1 -1
- package/dist/Engine.d.ts +31 -10
- package/dist/Engine.d.ts.map +1 -1
- package/dist/EngineFacade.d.ts +22 -11
- package/dist/EngineFacade.d.ts.map +1 -1
- package/dist/EngineFacade.js +39 -22
- package/dist/EngineWorklet.d.ts +22 -13
- package/dist/EngineWorklet.d.ts.map +1 -1
- package/dist/EngineWorklet.js +47 -56
- package/dist/MeterWorklet.d.ts.map +1 -1
- package/dist/MeterWorklet.js +2 -2
- package/dist/Project.d.ts +4 -2
- package/dist/Project.d.ts.map +1 -1
- package/dist/Project.js +6 -3
- package/dist/ProjectApi.d.ts +0 -1
- package/dist/ProjectApi.d.ts.map +1 -1
- package/dist/ProjectApi.js +16 -11
- package/dist/ProjectEnv.d.ts +1 -0
- package/dist/ProjectEnv.d.ts.map +1 -1
- package/dist/ProjectMigration.d.ts.map +1 -1
- package/dist/ProjectMigration.js +20 -3
- package/dist/RecordingWorklet.d.ts +15 -3
- package/dist/RecordingWorklet.d.ts.map +1 -1
- package/dist/RecordingWorklet.js +111 -16
- package/dist/WorkerAgents.d.ts +2 -2
- package/dist/WorkerAgents.d.ts.map +1 -1
- package/dist/Worklets.d.ts +1 -1
- package/dist/Worklets.d.ts.map +1 -1
- package/dist/Worklets.js +2 -2
- package/dist/capture/Capture.d.ts +22 -0
- package/dist/capture/Capture.d.ts.map +1 -0
- package/dist/capture/Capture.js +32 -0
- package/dist/capture/CaptureAudio.d.ts +17 -0
- package/dist/capture/CaptureAudio.d.ts.map +1 -0
- package/dist/capture/CaptureAudio.js +106 -0
- package/dist/capture/CaptureManager.d.ts +12 -0
- package/dist/capture/CaptureManager.d.ts.map +1 -0
- package/dist/capture/CaptureManager.js +38 -0
- package/dist/capture/CaptureMidi.d.ts +13 -0
- package/dist/capture/CaptureMidi.d.ts.map +1 -0
- package/dist/capture/CaptureMidi.js +50 -0
- package/dist/capture/RecordAudio.d.ts +21 -0
- package/dist/capture/RecordAudio.d.ts.map +1 -0
- package/dist/capture/RecordAudio.js +66 -0
- package/dist/capture/RecordMidi.d.ts +15 -0
- package/dist/capture/RecordMidi.d.ts.map +1 -0
- package/dist/capture/RecordMidi.js +85 -0
- package/dist/capture/RecordTrack.d.ts +7 -0
- package/dist/capture/RecordTrack.d.ts.map +1 -0
- package/dist/capture/RecordTrack.js +23 -0
- package/dist/capture/Recording.d.ts +9 -0
- package/dist/capture/Recording.d.ts.map +1 -0
- package/dist/capture/Recording.js +65 -0
- package/dist/capture/RecordingContext.d.ts +14 -0
- package/dist/capture/RecordingContext.d.ts.map +1 -0
- package/dist/capture/RecordingContext.js +1 -0
- package/dist/dawproject/AudioUnitExportLayout.d.ts +10 -0
- package/dist/dawproject/AudioUnitExportLayout.d.ts.map +1 -0
- package/dist/dawproject/AudioUnitExportLayout.js +64 -0
- package/dist/dawproject/BuiltinDevices.d.ts +9 -0
- package/dist/dawproject/BuiltinDevices.d.ts.map +1 -0
- package/dist/dawproject/BuiltinDevices.js +70 -0
- package/dist/dawproject/{DawProjectIO.d.ts → DawProject.d.ts} +6 -4
- package/dist/dawproject/DawProject.d.ts.map +1 -0
- package/dist/dawproject/{DawProjectIO.js → DawProject.js} +23 -5
- package/dist/dawproject/DawProjectExporter.d.ts +7 -6
- package/dist/dawproject/DawProjectExporter.d.ts.map +1 -1
- package/dist/dawproject/DawProjectExporter.js +245 -22
- package/dist/dawproject/DawProjectExporter.test.js +39 -6
- package/dist/dawproject/DawProjectImport.d.ts +12 -0
- package/dist/dawproject/DawProjectImport.d.ts.map +1 -0
- package/dist/dawproject/DawProjectImport.js +389 -0
- package/dist/dawproject/DawProjectImport.test.js +6 -7
- package/dist/dawproject/DeviceIO.d.ts +8 -0
- package/dist/dawproject/DeviceIO.d.ts.map +1 -0
- package/dist/dawproject/DeviceIO.js +63 -0
- package/dist/index.d.ts +11 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/processors.js +3 -3
- package/dist/processors.js.map +4 -4
- package/dist/samples/MainThreadSampleLoader.d.ts +1 -0
- package/dist/samples/MainThreadSampleLoader.d.ts.map +1 -1
- package/dist/samples/MainThreadSampleLoader.js +10 -6
- package/dist/samples/MainThreadSampleManager.d.ts +5 -5
- package/dist/samples/MainThreadSampleManager.d.ts.map +1 -1
- package/dist/samples/MainThreadSampleManager.js +1 -0
- package/dist/samples/SampleProvider.d.ts +2 -2
- package/dist/samples/SampleProvider.d.ts.map +1 -1
- package/dist/samples/SampleStorage.d.ts.map +1 -1
- package/dist/samples/SampleStorage.js +2 -3
- package/dist/workers.js +2 -2
- package/dist/workers.js.map +4 -4
- package/package.json +15 -15
- package/dist/dawproject/DawProjectIO.d.ts.map +0 -1
- package/dist/dawproject/DawProjectImporter.d.ts +0 -12
- package/dist/dawproject/DawProjectImporter.d.ts.map +0 -1
- package/dist/dawproject/DawProjectImporter.js +0 -273
- package/dist/samples/SamplePeaks.d.ts +0 -6
- package/dist/samples/SamplePeaks.d.ts.map +0 -1
- package/dist/samples/SamplePeaks.js +0 -9
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@opendaw/studio-core",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.20",
|
4
4
|
"license": "LGPL-3.0-or-later",
|
5
5
|
"publishConfig": {
|
6
6
|
"access": "public"
|
@@ -26,23 +26,23 @@
|
|
26
26
|
"test": "vitest run --config vitest.config.ts"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"@opendaw/lib-box": "^0.0.
|
30
|
-
"@opendaw/lib-dawproject": "^0.0.
|
31
|
-
"@opendaw/lib-dom": "^0.0.
|
32
|
-
"@opendaw/lib-dsp": "^0.0.
|
33
|
-
"@opendaw/lib-fusion": "^0.0.
|
34
|
-
"@opendaw/lib-runtime": "^0.0.
|
35
|
-
"@opendaw/lib-std": "^0.0.
|
36
|
-
"@opendaw/studio-adapters": "^0.0.
|
37
|
-
"@opendaw/studio-boxes": "^0.0.
|
38
|
-
"@opendaw/studio-enums": "^0.0.
|
29
|
+
"@opendaw/lib-box": "^0.0.20",
|
30
|
+
"@opendaw/lib-dawproject": "^0.0.6",
|
31
|
+
"@opendaw/lib-dom": "^0.0.20",
|
32
|
+
"@opendaw/lib-dsp": "^0.0.20",
|
33
|
+
"@opendaw/lib-fusion": "^0.0.20",
|
34
|
+
"@opendaw/lib-runtime": "^0.0.20",
|
35
|
+
"@opendaw/lib-std": "^0.0.20",
|
36
|
+
"@opendaw/studio-adapters": "^0.0.20",
|
37
|
+
"@opendaw/studio-boxes": "^0.0.20",
|
38
|
+
"@opendaw/studio-enums": "^0.0.20"
|
39
39
|
},
|
40
40
|
"devDependencies": {
|
41
41
|
"@opendaw/eslint-config": "^0.0.18",
|
42
|
-
"@opendaw/studio-core-processors": "^0.0.
|
43
|
-
"@opendaw/studio-core-workers": "^0.0.
|
44
|
-
"@opendaw/studio-forge-boxes": "^0.0.
|
42
|
+
"@opendaw/studio-core-processors": "^0.0.20",
|
43
|
+
"@opendaw/studio-core-workers": "^0.0.14",
|
44
|
+
"@opendaw/studio-forge-boxes": "^0.0.20",
|
45
45
|
"@opendaw/typescript-config": "^0.0.19"
|
46
46
|
},
|
47
|
-
"gitHead": "
|
47
|
+
"gitHead": "de891be4fc9e418776b3a6c433748e287abab912"
|
48
48
|
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DawProjectIO.d.ts","sourceRoot":"","sources":["../../src/dawproject/DawProjectIO.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAC,cAAc,EAAE,aAAa,EAAC,MAAM,yBAAyB,CAAA;AAErE,yBAAiB,YAAY,CAAC;IAC1B,KAAY,QAAQ,GAAG;QAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,WAAW,CAAA;KAAE,CAAA;IAE7F,UAAiB,SAAS;QACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAA;QAChC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAA;KACxC;IAEM,MAAM,MAAM,GAAU,QAAQ,WAAW,GAAG,eAAe,KAAG,OAAO,CAAC;QACzE,QAAQ,EAAE,cAAc,CAAC;QACzB,OAAO,EAAE,aAAa,CAAC;QACvB,SAAS,EAAE,SAAS,CAAA;KACvB,CAyBA,CAAA;CACJ"}
|
@@ -1,12 +0,0 @@
|
|
1
|
-
import { SortedSet, UUID } from "@opendaw/lib-std";
|
2
|
-
import { ProjectSchema } from "@opendaw/lib-dawproject";
|
3
|
-
import { ProjectDecoder } from "@opendaw/studio-adapters";
|
4
|
-
import { DawProjectIO } from "./DawProjectIO";
|
5
|
-
export declare class DawProjectImporter {
|
6
|
-
#private;
|
7
|
-
static importProject(schema: ProjectSchema, resources: DawProjectIO.Resources): Promise<DawProjectImporter>;
|
8
|
-
private constructor();
|
9
|
-
get audioIDs(): SortedSet<UUID.Format, UUID.Format>;
|
10
|
-
get skeleton(): ProjectDecoder.Skeleton;
|
11
|
-
}
|
12
|
-
//# sourceMappingURL=DawProjectImporter.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"DawProjectImporter.d.ts","sourceRoot":"","sources":["../../src/dawproject/DawProjectImporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAWH,SAAS,EACT,IAAI,EAEP,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAQH,aAAa,EAMhB,MAAM,yBAAyB,CAAA;AAkBhC,OAAO,EAAa,cAAc,EAAY,MAAM,0BAA0B,CAAA;AAC9E,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAI3C,qBAAa,kBAAkB;;WACd,aAAa,CAAC,MAAM,EAAE,aAAa,EACrB,SAAS,EAAE,YAAY,CAAC,SAAS,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAiB1F,OAAO;IAgDP,IAAI,QAAQ,IAAI,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAwB;IAC3E,IAAI,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAWtC;CAwMJ"}
|
@@ -1,273 +0,0 @@
|
|
1
|
-
import { asDefined, assert, identity, isInstanceOf, isUndefined, Option, panic, UUID, ValueMapping } from "@opendaw/lib-std";
|
2
|
-
import { BoxGraph } from "@opendaw/lib-box";
|
3
|
-
import { gainToDb, PPQN } from "@opendaw/lib-dsp";
|
4
|
-
import { ClipsSchema, LanesSchema, NotesSchema, SendType, TrackSchema, WarpsSchema } from "@opendaw/lib-dawproject";
|
5
|
-
import { AudioSendRouting, AudioUnitType } from "@opendaw/studio-enums";
|
6
|
-
import { AudioBusBox, AudioFileBox, AudioRegionBox, AudioUnitBox, AuxSendBox, BoxIO, GrooveShuffleBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, RootBox, TimelineBox, TrackBox, UserInterfaceBox } from "@opendaw/studio-boxes";
|
7
|
-
import { IconSymbol, TrackType } from "@opendaw/studio-adapters";
|
8
|
-
import { ColorCodes } from "../ColorCodes";
|
9
|
-
import { InstrumentFactories } from "../InstrumentFactories";
|
10
|
-
export class DawProjectImporter {
|
11
|
-
static async importProject(schema, resources) {
|
12
|
-
return new DawProjectImporter(schema, resources).#read();
|
13
|
-
}
|
14
|
-
#schema;
|
15
|
-
#resources;
|
16
|
-
#mapTrackBoxes;
|
17
|
-
#audioIDs;
|
18
|
-
#boxGraph;
|
19
|
-
#rootBox;
|
20
|
-
#masterBusBox;
|
21
|
-
#masterAudioUnit;
|
22
|
-
#timelineBox;
|
23
|
-
#userInterfaceBox;
|
24
|
-
constructor(schema, resources) {
|
25
|
-
this.#schema = schema;
|
26
|
-
this.#resources = resources;
|
27
|
-
this.#mapTrackBoxes = new Map();
|
28
|
-
this.#audioIDs = UUID.newSet(identity);
|
29
|
-
const isoString = new Date().toISOString();
|
30
|
-
console.debug(`New Project imported on ${isoString}`);
|
31
|
-
this.#boxGraph = new BoxGraph(Option.wrap(BoxIO.create));
|
32
|
-
this.#boxGraph.beginTransaction();
|
33
|
-
const grooveShuffleBox = GrooveShuffleBox.create(this.#boxGraph, UUID.generate(), box => {
|
34
|
-
box.label.setValue("Groove Shuffle");
|
35
|
-
});
|
36
|
-
this.#timelineBox = TimelineBox.create(this.#boxGraph, UUID.generate());
|
37
|
-
this.#rootBox = RootBox.create(this.#boxGraph, UUID.generate(), box => {
|
38
|
-
box.groove.refer(grooveShuffleBox);
|
39
|
-
box.created.setValue(isoString);
|
40
|
-
box.timeline.refer(this.#timelineBox.root);
|
41
|
-
});
|
42
|
-
this.#masterBusBox = AudioBusBox.create(this.#boxGraph, UUID.generate(), box => {
|
43
|
-
box.collection.refer(this.#rootBox.audioBusses);
|
44
|
-
box.label.setValue("Output");
|
45
|
-
box.icon.setValue(IconSymbol.toName(IconSymbol.SpeakerHeadphone));
|
46
|
-
box.color.setValue("hsl(189, 100%, 65%)");
|
47
|
-
});
|
48
|
-
this.#masterAudioUnit = AudioUnitBox.create(this.#boxGraph, UUID.generate(), box => {
|
49
|
-
box.type.setValue(AudioUnitType.Output);
|
50
|
-
box.collection.refer(this.#rootBox.audioUnits);
|
51
|
-
box.output.refer(this.#rootBox.outputDevice);
|
52
|
-
box.index.setValue(0);
|
53
|
-
});
|
54
|
-
this.#masterBusBox.output.refer(this.#masterAudioUnit.input);
|
55
|
-
this.#userInterfaceBox = UserInterfaceBox.create(this.#boxGraph, UUID.generate(), box => box.root.refer(this.#rootBox.users));
|
56
|
-
}
|
57
|
-
async #read() {
|
58
|
-
this.#readTransport();
|
59
|
-
this.#readStructure();
|
60
|
-
await this.#readArrangement();
|
61
|
-
this.#boxGraph.endTransaction();
|
62
|
-
this.#boxGraph.verifyPointers();
|
63
|
-
return this;
|
64
|
-
}
|
65
|
-
get audioIDs() { return this.#audioIDs; }
|
66
|
-
get skeleton() {
|
67
|
-
return {
|
68
|
-
boxGraph: this.#boxGraph,
|
69
|
-
mandatoryBoxes: {
|
70
|
-
rootBox: this.#rootBox,
|
71
|
-
timelineBox: this.#timelineBox,
|
72
|
-
masterBusBox: this.#masterBusBox,
|
73
|
-
masterAudioUnit: this.#masterAudioUnit,
|
74
|
-
userInterfaceBox: this.#userInterfaceBox
|
75
|
-
}
|
76
|
-
};
|
77
|
-
}
|
78
|
-
#readTransport() {
|
79
|
-
const { transport } = this.#schema;
|
80
|
-
if (isUndefined(transport)) {
|
81
|
-
return;
|
82
|
-
}
|
83
|
-
this.#timelineBox.bpm.setValue(transport.tempo?.value ?? 120.0);
|
84
|
-
this.#timelineBox.signature.nominator.setValue(transport.timeSignature?.numerator ?? 4);
|
85
|
-
this.#timelineBox.signature.denominator.setValue(transport.timeSignature?.denominator ?? 4);
|
86
|
-
}
|
87
|
-
#readStructure() {
|
88
|
-
const resolveSendTargets = [];
|
89
|
-
const effectTargetMap = new Map();
|
90
|
-
const readChannel = (audioUnitBox, channel) => {
|
91
|
-
audioUnitBox.volume.setValue(gainToDb(channel.volume?.value ?? 1.0));
|
92
|
-
audioUnitBox.panning.setValue(ValueMapping.bipolar().y(channel.pan?.value ?? 0.5));
|
93
|
-
audioUnitBox.mute.setValue(channel.mute?.value === true);
|
94
|
-
audioUnitBox.solo.setValue(channel.solo === true);
|
95
|
-
channel.sends?.forEach((send) => {
|
96
|
-
// bitwig does not set enabled if it is enabled 🤥
|
97
|
-
const enable = isUndefined(send?.enable?.value) || send.enable.value;
|
98
|
-
if (enable) {
|
99
|
-
resolveSendTargets.push(() => AuxSendBox.create(this.#boxGraph, UUID.generate(), box => {
|
100
|
-
const type = send.type;
|
101
|
-
const destination = asDefined(send.destination, "destination is undefined");
|
102
|
-
box.routing.setValue(type === SendType.PRE ? AudioSendRouting.Pre : AudioSendRouting.Post);
|
103
|
-
box.sendGain.setValue(gainToDb(send.volume?.value ?? 1.0));
|
104
|
-
box.sendPan.setValue(ValueMapping.bipolar().y(send.pan?.value ?? 0.5));
|
105
|
-
box.targetBus.refer(asDefined(effectTargetMap.get(destination), "Cannot find destination").input);
|
106
|
-
box.audioUnit.refer(audioUnitBox.auxSends);
|
107
|
-
}));
|
108
|
-
}
|
109
|
-
});
|
110
|
-
};
|
111
|
-
const { structure } = this.#schema;
|
112
|
-
let audioUnitIndex = 0;
|
113
|
-
structure.forEach((lane) => {
|
114
|
-
if (isInstanceOf(lane, TrackSchema)) {
|
115
|
-
const trackType = this.#contentToTrackType(lane.contentType);
|
116
|
-
const channel = asDefined(lane.channel, "Track has no Channel");
|
117
|
-
// TODO devices
|
118
|
-
if (channel.role === "regular") {
|
119
|
-
const audioUnitBox = AudioUnitBox.create(this.#boxGraph, UUID.generate(), box => {
|
120
|
-
box.index.setValue(audioUnitIndex);
|
121
|
-
box.type.setValue(AudioUnitType.Instrument);
|
122
|
-
box.output.refer(this.#masterBusBox.input);
|
123
|
-
box.collection.refer(this.#rootBox.audioUnits);
|
124
|
-
readChannel(box, channel);
|
125
|
-
});
|
126
|
-
const trackBox = TrackBox.create(this.#boxGraph, UUID.generate(), box => {
|
127
|
-
box.type.setValue(trackType);
|
128
|
-
box.index.setValue(0);
|
129
|
-
box.tracks.refer(audioUnitBox.tracks);
|
130
|
-
box.target.refer(audioUnitBox);
|
131
|
-
});
|
132
|
-
this.#mapTrackBoxes.set(asDefined(lane.id, "Track must have an id."), trackBox);
|
133
|
-
if (trackType === TrackType.Notes) {
|
134
|
-
InstrumentFactories.Vaporisateur
|
135
|
-
.create(this.#boxGraph, audioUnitBox.input, lane.name ?? "", IconSymbol.Piano);
|
136
|
-
}
|
137
|
-
else if (trackType === TrackType.Audio) {
|
138
|
-
InstrumentFactories.Tape
|
139
|
-
.create(this.#boxGraph, audioUnitBox.input, lane.name ?? "", IconSymbol.Waveform);
|
140
|
-
}
|
141
|
-
}
|
142
|
-
else if (channel.role === "effect") {
|
143
|
-
const audioUnitBox = AudioUnitBox.create(this.#boxGraph, UUID.generate(), box => {
|
144
|
-
box.index.setValue(audioUnitIndex);
|
145
|
-
box.type.setValue(AudioUnitType.Aux);
|
146
|
-
box.output.refer(this.#masterBusBox.input);
|
147
|
-
box.collection.refer(this.#rootBox.audioUnits);
|
148
|
-
readChannel(box, channel);
|
149
|
-
});
|
150
|
-
const audioBusBox = AudioBusBox.create(this.#boxGraph, UUID.generate(), box => {
|
151
|
-
box.collection.refer(this.#rootBox.audioBusses);
|
152
|
-
box.label.setValue(lane.name ?? "Aux");
|
153
|
-
box.color.setValue(ColorCodes.forAudioType(AudioUnitType.Aux));
|
154
|
-
box.icon.setValue(IconSymbol.toName(IconSymbol.Effects));
|
155
|
-
box.output.refer(audioUnitBox.input);
|
156
|
-
});
|
157
|
-
const trackBox = TrackBox.create(this.#boxGraph, UUID.generate(), box => {
|
158
|
-
box.type.setValue(TrackType.Undefined);
|
159
|
-
box.index.setValue(0);
|
160
|
-
box.tracks.refer(audioUnitBox.tracks);
|
161
|
-
box.target.refer(audioUnitBox);
|
162
|
-
});
|
163
|
-
effectTargetMap.set(asDefined(channel.id, "Effect-channel must have id."), audioBusBox);
|
164
|
-
this.#mapTrackBoxes.set(asDefined(lane.id, "Track must have an id."), trackBox);
|
165
|
-
}
|
166
|
-
else if (channel.role === "master") {
|
167
|
-
readChannel(this.#masterAudioUnit, channel);
|
168
|
-
}
|
169
|
-
else {
|
170
|
-
return panic(`Unknown channel role: ${channel.role}`);
|
171
|
-
}
|
172
|
-
audioUnitIndex++;
|
173
|
-
}
|
174
|
-
});
|
175
|
-
this.#masterAudioUnit.index.setValue(audioUnitIndex);
|
176
|
-
resolveSendTargets.forEach(exec => exec());
|
177
|
-
resolveSendTargets.length = 0;
|
178
|
-
}
|
179
|
-
#readArrangement() {
|
180
|
-
const { arrangement } = this.#schema;
|
181
|
-
const readRegions = ({ clips }, track) => Promise.all(clips.map(clip => readAnyRegion(clip, track)));
|
182
|
-
const readLane = (lane) => {
|
183
|
-
const track = lane.track; // links to track in structure
|
184
|
-
return Promise.all(lane?.lanes?.filter(timeline => isInstanceOf(timeline, ClipsSchema))
|
185
|
-
.map(clips => readRegions(clips, asDefined(track, "Region(Clips) must have an id."))) ?? []);
|
186
|
-
};
|
187
|
-
const readAnyRegion = (clip, trackId) => {
|
188
|
-
const trackBox = asDefined(this.#mapTrackBoxes.get(trackId), `Could not find track for ${trackId}`);
|
189
|
-
return Promise.all(clip.content?.map(async (content) => {
|
190
|
-
if (isInstanceOf(content, ClipsSchema)) {
|
191
|
-
await readAnyRegionContent(clip, content, trackBox);
|
192
|
-
}
|
193
|
-
else if (isInstanceOf(content, NotesSchema)) {
|
194
|
-
readNoteRegionContent(clip, content, trackBox);
|
195
|
-
}
|
196
|
-
}) ?? []);
|
197
|
-
};
|
198
|
-
const readNoteRegionContent = (clip, notes, trackBox) => {
|
199
|
-
const collectionBox = NoteEventCollectionBox.create(this.#boxGraph, UUID.generate());
|
200
|
-
NoteRegionBox.create(this.#boxGraph, UUID.generate(), box => {
|
201
|
-
const position = asDefined(clip.time, "Time not defined");
|
202
|
-
const duration = asDefined(clip.duration, "Duration not defined");
|
203
|
-
const loopDuration = clip.loopEnd ?? duration;
|
204
|
-
box.position.setValue(position * PPQN.Quarter);
|
205
|
-
box.duration.setValue(duration * PPQN.Quarter);
|
206
|
-
box.label.setValue(clip.name ?? "");
|
207
|
-
box.loopDuration.setValue(loopDuration * PPQN.Quarter);
|
208
|
-
box.mute.setValue(clip.enable === false);
|
209
|
-
box.events.refer(collectionBox.owners);
|
210
|
-
box.regions.refer(trackBox.regions);
|
211
|
-
});
|
212
|
-
notes.notes?.forEach(note => {
|
213
|
-
NoteEventBox.create(this.#boxGraph, UUID.generate(), box => {
|
214
|
-
box.position.setValue(note.time * PPQN.Quarter);
|
215
|
-
box.duration.setValue(note.duration * PPQN.Quarter);
|
216
|
-
box.pitch.setValue(note.key);
|
217
|
-
box.velocity.setValue(note.vel ?? 1.0);
|
218
|
-
box.events.refer(collectionBox.events);
|
219
|
-
});
|
220
|
-
});
|
221
|
-
};
|
222
|
-
const readAnyRegionContent = async (clip, content, trackBox) => {
|
223
|
-
const contentClip = content.clips.at(0);
|
224
|
-
if (isUndefined(contentClip)) {
|
225
|
-
console.warn(clip, "audio-clip without content-clip?");
|
226
|
-
return;
|
227
|
-
}
|
228
|
-
const innerContent = contentClip.content?.at(0);
|
229
|
-
// TODO Double-check: From which point is it guaranteed that this is an audio region?
|
230
|
-
if (isInstanceOf(innerContent, WarpsSchema)) {
|
231
|
-
const { warps, content } = innerContent;
|
232
|
-
const audio = content?.at(0);
|
233
|
-
const warp0 = warps.at(0);
|
234
|
-
const warpN = warps.at(-1);
|
235
|
-
const warpDistance = asDefined(warpN?.time) - asDefined(warp0?.time);
|
236
|
-
if (isUndefined(audio)) {
|
237
|
-
return;
|
238
|
-
}
|
239
|
-
const { path, external } = audio.file;
|
240
|
-
assert(external !== true, "File cannot be external");
|
241
|
-
const { uuid, name } = this.#resources.fromPath(path);
|
242
|
-
const audioFileBox = this.#boxGraph.findBox(uuid)
|
243
|
-
.unwrapOrElse(() => AudioFileBox.create(this.#boxGraph, uuid, box => box.fileName.setValue(name)));
|
244
|
-
this.#audioIDs.add(uuid, true);
|
245
|
-
AudioRegionBox.create(this.#boxGraph, UUID.generate(), box => {
|
246
|
-
const position = asDefined(clip.time, "Time not defined");
|
247
|
-
const duration = asDefined(clip.duration, "Duration not defined");
|
248
|
-
const loopDuration = clip.loopEnd ?? warpDistance;
|
249
|
-
box.position.setValue(position * PPQN.Quarter);
|
250
|
-
box.duration.setValue(duration * PPQN.Quarter);
|
251
|
-
box.label.setValue(clip.name ?? "");
|
252
|
-
box.loopOffset.setValue((-(contentClip.time ?? 0.0)) * PPQN.Quarter);
|
253
|
-
box.loopDuration.setValue(loopDuration * PPQN.Quarter);
|
254
|
-
box.mute.setValue(clip.enable === false);
|
255
|
-
box.regions.refer(trackBox.regions);
|
256
|
-
box.file.refer(audioFileBox);
|
257
|
-
});
|
258
|
-
}
|
259
|
-
};
|
260
|
-
return Promise.all(arrangement?.lanes?.lanes?.filter(timeline => isInstanceOf(timeline, LanesSchema))
|
261
|
-
.map(readLane) ?? []);
|
262
|
-
}
|
263
|
-
#contentToTrackType(contentType) {
|
264
|
-
switch (contentType) {
|
265
|
-
case "audio":
|
266
|
-
return TrackType.Audio;
|
267
|
-
case "notes":
|
268
|
-
return TrackType.Notes;
|
269
|
-
default:
|
270
|
-
return TrackType.Undefined;
|
271
|
-
}
|
272
|
-
}
|
273
|
-
}
|
@@ -1,6 +0,0 @@
|
|
1
|
-
import { ProgressHandler } from "@opendaw/lib-std";
|
2
|
-
import { AudioData } from "@opendaw/studio-adapters";
|
3
|
-
export declare namespace SamplePeaks {
|
4
|
-
const generate: (audio: AudioData, progress: ProgressHandler) => Promise<ArrayBuffer>;
|
5
|
-
}
|
6
|
-
//# sourceMappingURL=SamplePeaks.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"SamplePeaks.d.ts","sourceRoot":"","sources":["../../src/samples/SamplePeaks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,kBAAkB,CAAA;AAEhD,OAAO,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAGlD,yBAAiB,WAAW,CAAC;IAClB,MAAM,QAAQ,GAAU,OAAO,SAAS,EAAE,UAAU,eAAe,KAAG,OAAO,CAAC,WAAW,CAQ/F,CAAA;CACJ"}
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { Peaks } from "@opendaw/lib-fusion";
|
2
|
-
import { WorkerAgents } from "../WorkerAgents";
|
3
|
-
export var SamplePeaks;
|
4
|
-
(function (SamplePeaks) {
|
5
|
-
SamplePeaks.generate = async (audio, progress) => {
|
6
|
-
const shifts = Peaks.findBestFit(audio.numberOfFrames);
|
7
|
-
return await WorkerAgents.Peak.generateAsync(progress, shifts, audio.frames, audio.numberOfFrames, audio.numberOfChannels);
|
8
|
-
};
|
9
|
-
})(SamplePeaks || (SamplePeaks = {}));
|