@opendaw/studio-core 0.0.11 → 0.0.12
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/ProjectApi.d.ts +22 -10
- package/dist/ProjectApi.d.ts.map +1 -1
- package/dist/ProjectApi.js +63 -44
- package/dist/processors.js +2 -2
- package/dist/processors.js.map +3 -3
- package/dist/workers.js +2 -2
- package/dist/workers.js.map +3 -3
- package/package.json +16 -16
package/dist/ProjectApi.d.ts
CHANGED
@@ -1,13 +1,26 @@
|
|
1
|
-
import { int, Option } from "@opendaw/lib-std";
|
1
|
+
import { float, int, Option } from "@opendaw/lib-std";
|
2
2
|
import { AudioUnitType } from "@opendaw/studio-enums";
|
3
|
-
import { AudioBusBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
4
|
-
import { AnyClipBox, AudioUnitBoxAdapter, DeviceHost, IconSymbol,
|
3
|
+
import { AudioBusBox, NoteClipBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
4
|
+
import { AnyClipBox, AudioUnitBoxAdapter, DeviceHost, IconSymbol, NoteEventBoxAdapter } from "@opendaw/studio-adapters";
|
5
5
|
import { Project } from "./Project";
|
6
6
|
import { InstrumentFactory } from "./InstrumentFactory";
|
7
7
|
import { InstrumentProduct } from "./InstrumentProduct";
|
8
8
|
import { InstrumentOptions } from "./InstrumentOptions";
|
9
9
|
import { EffectFactory } from "./EffectFactory";
|
10
10
|
import { ppqn } from "@opendaw/lib-dsp";
|
11
|
+
export type ClipRegionOptions = {
|
12
|
+
name?: string;
|
13
|
+
hue?: number;
|
14
|
+
};
|
15
|
+
export type NoteEventParams = {
|
16
|
+
owner: NoteRegionBox | NoteClipBox;
|
17
|
+
position: ppqn;
|
18
|
+
duration: ppqn;
|
19
|
+
pitch: int;
|
20
|
+
cent?: number;
|
21
|
+
velocity?: float;
|
22
|
+
chance?: int;
|
23
|
+
};
|
11
24
|
export declare class ProjectApi {
|
12
25
|
#private;
|
13
26
|
static readonly AudioUnitOrdering: {
|
@@ -19,14 +32,13 @@ export declare class ProjectApi {
|
|
19
32
|
constructor(project: Project);
|
20
33
|
createInstrument({ create, defaultIcon, defaultName, trackType }: InstrumentFactory, { name, icon, index }?: InstrumentOptions): InstrumentProduct;
|
21
34
|
createEffect(host: DeviceHost, factory: EffectFactory, newIndex: int): import("@opendaw/lib-box").Box<import("@opendaw/lib-box").PointerTypes, any>;
|
22
|
-
createTrack(adapter: AudioUnitBoxAdapter, trackType: TrackType, index?: int): TrackBox;
|
23
|
-
createClip({ collection, trackBoxAdapter }: TrackClips, clipIndex: int, { name }?: {
|
24
|
-
name?: string;
|
25
|
-
}): Option<AnyClipBox>;
|
26
|
-
createRegion({ trackBoxAdapter }: TrackRegions, position: ppqn, duration: ppqn, { name }?: {
|
27
|
-
name?: string;
|
28
|
-
}): Option<NoteRegionBox> | Option<ValueRegionBox>;
|
29
35
|
createAudioBus(name: string, icon: IconSymbol, type: AudioUnitType, color: string): AudioBusBox;
|
36
|
+
createNoteTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
37
|
+
createAudioTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
38
|
+
createAutomationTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
39
|
+
createClip(trackBox: TrackBox, clipIndex: int, { name, hue }?: ClipRegionOptions): Option<AnyClipBox>;
|
40
|
+
createRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
|
41
|
+
createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBoxAdapter;
|
30
42
|
deleteAudioUnit(adapter: AudioUnitBoxAdapter): void;
|
31
43
|
}
|
32
44
|
//# sourceMappingURL=ProjectApi.d.ts.map
|
package/dist/ProjectApi.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ProjectApi.d.ts","sourceRoot":"","sources":["../src/ProjectApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,GAAG,EAAE,MAAM,EAAuB,MAAM,kBAAkB,CAAA;
|
1
|
+
{"version":3,"file":"ProjectApi.d.ts","sourceRoot":"","sources":["../src/ProjectApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAuB,MAAM,kBAAkB,CAAA;AAEjF,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EACH,WAAW,EAEX,WAAW,EAGX,aAAa,EACb,QAAQ,EAGR,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,UAAU,EACV,mBAAmB,EACnB,UAAU,EAGV,UAAU,EACV,mBAAmB,EAGtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,OAAO,EAAC,IAAI,EAAO,MAAM,kBAAkB,CAAA;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,KAAK,EAAE,aAAa,GAAG,WAAW,CAAA;IAClC,QAAQ,EAAE,IAAI,CAAA;IACd,QAAQ,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,GAAG,CAAA;IACV,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,KAAK,CAAA;IAChB,MAAM,CAAC,EAAE,GAAG,CAAA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HANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { assert, Option, panic, Strings, UUID } from "@opendaw/lib-std";
|
2
2
|
import { AudioUnitType } from "@opendaw/studio-enums";
|
3
|
-
import { AudioBusBox, AudioUnitBox, NoteClipBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueClipBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
4
|
-
import { AudioUnitBoxAdapter, IconSymbol, TrackType } from "@opendaw/studio-adapters";
|
3
|
+
import { AudioBusBox, AudioUnitBox, NoteClipBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueClipBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
4
|
+
import { AudioUnitBoxAdapter, IconSymbol, NoteEventBoxAdapter, TrackType } from "@opendaw/studio-adapters";
|
5
5
|
import { ColorCodes } from "./ColorCodes";
|
6
6
|
import { PPQN } from "@opendaw/lib-dsp";
|
7
7
|
export class ProjectApi {
|
@@ -54,31 +54,49 @@ export class ProjectApi {
|
|
54
54
|
}
|
55
55
|
return box;
|
56
56
|
}
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
57
|
+
createAudioBus(name, icon, type, color) {
|
58
|
+
console.debug(`createAudioBus '${name}', type: ${type}, color: ${color}`);
|
59
|
+
const { rootBox, boxGraph } = this.#project;
|
60
|
+
assert(rootBox.audioBusses.isAttached(), "rootBox not attached");
|
61
|
+
const uuid = UUID.generate();
|
62
|
+
const audioBusBox = AudioBusBox.create(boxGraph, uuid, box => {
|
63
|
+
box.collection.refer(rootBox.audioBusses);
|
64
|
+
box.label.setValue(name);
|
65
|
+
box.icon.setValue(IconSymbol.toName(icon));
|
66
|
+
box.color.setValue(color);
|
67
|
+
});
|
68
|
+
const audioUnitBox = this.#createAudioUnit(type);
|
69
|
+
TrackBox.create(boxGraph, UUID.generate(), box => {
|
70
|
+
box.tracks.refer(audioUnitBox.tracks);
|
71
|
+
box.target.refer(audioUnitBox);
|
72
|
+
box.index.setValue(0);
|
73
|
+
box.type.setValue(TrackType.Undefined);
|
63
74
|
});
|
75
|
+
audioBusBox.output.refer(audioUnitBox.input);
|
76
|
+
return audioBusBox;
|
64
77
|
}
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
78
|
+
createNoteTrack(adapter, index = 0) {
|
79
|
+
return this.#createTrack(adapter, TrackType.Notes, index);
|
80
|
+
}
|
81
|
+
createAudioTrack(adapter, index = 0) {
|
82
|
+
return this.#createTrack(adapter, TrackType.Audio, index);
|
83
|
+
}
|
84
|
+
createAutomationTrack(adapter, index = 0) {
|
85
|
+
return this.#createTrack(adapter, TrackType.Value, index);
|
86
|
+
}
|
87
|
+
createClip(trackBox, clipIndex, { name, hue } = {}) {
|
70
88
|
const { boxGraph } = this.#project;
|
71
|
-
const type =
|
89
|
+
const type = trackBox.type.getValue();
|
72
90
|
switch (type) {
|
73
91
|
case TrackType.Notes: {
|
74
92
|
const events = NoteEventCollectionBox.create(boxGraph, UUID.generate());
|
75
93
|
return Option.wrap(NoteClipBox.create(boxGraph, UUID.generate(), box => {
|
76
94
|
box.index.setValue(clipIndex);
|
77
95
|
box.label.setValue(name ?? "Notes");
|
78
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
96
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
79
97
|
box.mute.setValue(false);
|
80
98
|
box.duration.setValue(PPQN.Bar);
|
81
|
-
box.clips.refer(
|
99
|
+
box.clips.refer(trackBox.clips);
|
82
100
|
box.events.refer(events.owners);
|
83
101
|
}));
|
84
102
|
}
|
@@ -87,31 +105,31 @@ export class ProjectApi {
|
|
87
105
|
return Option.wrap(ValueClipBox.create(boxGraph, UUID.generate(), box => {
|
88
106
|
box.index.setValue(clipIndex);
|
89
107
|
box.label.setValue(name ?? "CV");
|
90
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
108
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
91
109
|
box.mute.setValue(false);
|
92
110
|
box.duration.setValue(PPQN.Bar);
|
93
111
|
box.events.refer(events.owners);
|
94
|
-
box.clips.refer(
|
112
|
+
box.clips.refer(trackBox.clips);
|
95
113
|
}));
|
96
114
|
}
|
97
115
|
}
|
98
116
|
return Option.None;
|
99
117
|
}
|
100
|
-
createRegion(
|
118
|
+
createRegion(trackBox, position, duration, { name, hue } = {}) {
|
101
119
|
const { boxGraph } = this.#project;
|
102
|
-
const type =
|
120
|
+
const type = trackBox.type.getValue();
|
103
121
|
switch (type) {
|
104
122
|
case TrackType.Notes: {
|
105
123
|
const events = NoteEventCollectionBox.create(boxGraph, UUID.generate());
|
106
124
|
return Option.wrap(NoteRegionBox.create(boxGraph, UUID.generate(), box => {
|
107
125
|
box.position.setValue(Math.max(position, 0));
|
108
126
|
box.label.setValue(name ?? "Notes");
|
109
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
127
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
110
128
|
box.mute.setValue(false);
|
111
129
|
box.duration.setValue(duration);
|
112
130
|
box.loopDuration.setValue(PPQN.Bar);
|
113
131
|
box.events.refer(events.owners);
|
114
|
-
box.regions.refer(
|
132
|
+
box.regions.refer(trackBox.regions);
|
115
133
|
}));
|
116
134
|
}
|
117
135
|
case TrackType.Value: {
|
@@ -119,37 +137,30 @@ export class ProjectApi {
|
|
119
137
|
return Option.wrap(ValueRegionBox.create(boxGraph, UUID.generate(), box => {
|
120
138
|
box.position.setValue(Math.max(position, 0));
|
121
139
|
box.label.setValue(name ?? "Automation");
|
122
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
140
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
123
141
|
box.mute.setValue(false);
|
124
142
|
box.duration.setValue(duration);
|
125
143
|
box.loopDuration.setValue(PPQN.Bar);
|
126
144
|
box.events.refer(events.owners);
|
127
|
-
box.regions.refer(
|
145
|
+
box.regions.refer(trackBox.regions);
|
128
146
|
}));
|
129
147
|
}
|
130
148
|
}
|
131
149
|
return Option.None;
|
132
150
|
}
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
box.
|
140
|
-
box.
|
141
|
-
box.
|
142
|
-
box.
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
box.tracks.refer(audioUnitBox.tracks);
|
147
|
-
box.target.refer(audioUnitBox);
|
148
|
-
box.index.setValue(0);
|
149
|
-
box.type.setValue(TrackType.Undefined);
|
150
|
-
});
|
151
|
-
audioBusBox.output.refer(audioUnitBox.input);
|
152
|
-
return audioBusBox;
|
151
|
+
createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }) {
|
152
|
+
const { boxAdapters, boxGraph } = this.#project;
|
153
|
+
return boxAdapters.adapterFor(NoteEventBox.create(boxGraph, UUID.generate(), box => {
|
154
|
+
box.position.setValue(position);
|
155
|
+
box.duration.setValue(duration);
|
156
|
+
box.velocity.setValue(velocity ?? 1.0);
|
157
|
+
box.pitch.setValue(pitch);
|
158
|
+
box.chance.setValue(chance ?? 100.0);
|
159
|
+
box.cent.setValue(cent ?? 0.0);
|
160
|
+
box.events.refer(owner.events.targetVertex
|
161
|
+
.unwrap("Owner has no event-collection").box
|
162
|
+
.asBox(NoteEventCollectionBox).events);
|
163
|
+
}), NoteEventBoxAdapter);
|
153
164
|
}
|
154
165
|
deleteAudioUnit(adapter) {
|
155
166
|
const { rootBoxAdapter } = this.#project;
|
@@ -180,6 +191,14 @@ export class ProjectApi {
|
|
180
191
|
box.type.setValue(type);
|
181
192
|
});
|
182
193
|
}
|
194
|
+
#createTrack(adapter, trackType, index = 0) {
|
195
|
+
return TrackBox.create(this.#project.boxGraph, UUID.generate(), box => {
|
196
|
+
box.index.setValue(index);
|
197
|
+
box.type.setValue(trackType);
|
198
|
+
box.tracks.refer(adapter.tracksField);
|
199
|
+
box.target.refer(adapter.audioUnitBoxAdapter().box);
|
200
|
+
});
|
201
|
+
}
|
183
202
|
#pushAudioUnitsIndices(rootBoxAdapter, type, count = 1) {
|
184
203
|
const adapters = rootBoxAdapter.audioUnits.adapters();
|
185
204
|
const order = ProjectApi.AudioUnitOrdering[type];
|