@opendaw/studio-core 0.0.11 → 0.0.13
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 +39 -11
- package/dist/ProjectApi.d.ts.map +1 -1
- package/dist/ProjectApi.js +78 -43
- 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,41 @@
|
|
1
|
-
import { int, Option } from "@opendaw/lib-std";
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
1
|
+
import { float, int, Option } from "@opendaw/lib-std";
|
2
|
+
import { PointerField } from "@opendaw/lib-box";
|
3
|
+
import { AudioUnitType, Pointers } from "@opendaw/studio-enums";
|
4
|
+
import { AudioBusBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
5
|
+
import { AnyClipBox, AudioUnitBoxAdapter, DeviceHost, IconSymbol } from "@opendaw/studio-adapters";
|
5
6
|
import { Project } from "./Project";
|
6
7
|
import { InstrumentFactory } from "./InstrumentFactory";
|
7
8
|
import { InstrumentProduct } from "./InstrumentProduct";
|
8
9
|
import { InstrumentOptions } from "./InstrumentOptions";
|
9
10
|
import { EffectFactory } from "./EffectFactory";
|
10
11
|
import { ppqn } from "@opendaw/lib-dsp";
|
12
|
+
export type ClipRegionOptions = {
|
13
|
+
name?: string;
|
14
|
+
hue?: number;
|
15
|
+
};
|
16
|
+
export type NoteEventParams = {
|
17
|
+
owner: {
|
18
|
+
events: PointerField<Pointers.NoteEventCollection>;
|
19
|
+
};
|
20
|
+
position: ppqn;
|
21
|
+
duration: ppqn;
|
22
|
+
pitch: int;
|
23
|
+
cent?: number;
|
24
|
+
velocity?: float;
|
25
|
+
chance?: int;
|
26
|
+
};
|
27
|
+
export type NoteRegionParams = {
|
28
|
+
trackBox: TrackBox;
|
29
|
+
position: ppqn;
|
30
|
+
duration: ppqn;
|
31
|
+
loopOffset?: ppqn;
|
32
|
+
loopDuration?: ppqn;
|
33
|
+
eventOffset?: ppqn;
|
34
|
+
eventCollection?: NoteEventCollectionBox;
|
35
|
+
mute?: boolean;
|
36
|
+
name?: string;
|
37
|
+
hue?: number;
|
38
|
+
};
|
11
39
|
export declare class ProjectApi {
|
12
40
|
#private;
|
13
41
|
static readonly AudioUnitOrdering: {
|
@@ -19,14 +47,14 @@ export declare class ProjectApi {
|
|
19
47
|
constructor(project: Project);
|
20
48
|
createInstrument({ create, defaultIcon, defaultName, trackType }: InstrumentFactory, { name, icon, index }?: InstrumentOptions): InstrumentProduct;
|
21
49
|
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
50
|
createAudioBus(name: string, icon: IconSymbol, type: AudioUnitType, color: string): AudioBusBox;
|
51
|
+
createNoteTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
52
|
+
createAudioTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
53
|
+
createAutomationTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
|
54
|
+
createClip(trackBox: TrackBox, clipIndex: int, { name, hue }?: ClipRegionOptions): Option<AnyClipBox>;
|
55
|
+
createNoteRegion({ trackBox, position, duration, loopOffset, loopDuration, eventOffset, eventCollection, mute, name, hue }: NoteRegionParams): NoteRegionBox;
|
56
|
+
createTrackRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
|
57
|
+
createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBox;
|
30
58
|
deleteAudioUnit(adapter: AudioUnitBoxAdapter): void;
|
31
59
|
}
|
32
60
|
//# 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;AACjF,OAAO,EAAQ,YAAY,EAAC,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAC,aAAa,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC7D,OAAO,EACH,WAAW,EAGX,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,QAAQ,EAGR,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,UAAU,EACV,mBAAmB,EACnB,UAAU,EAGV,UAAU,EAGb,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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IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,MAAM,GAAG,WAAW;IAsB1C,eAAe,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,GAAE,GAAO,GAAG,QAAQ;IAIvE,gBAAgB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,GAAE,GAAO,GAAG,QAAQ;IAIxE,qBAAqB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,GAAE,GAAO,GAAG,QAAQ;IAI7E,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,EAAE,EAAC,IAAI,EAAE,GAAG,EAAC,GAAE,iBAAsB,GAAG,MAAM,CAAC,UAAU,CAAC;IAgCvG,gBAAgB,CAAC,EACI,QAAQ,EACR,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,YAAY,EACxB,WAAW,EAAE,eAAe,EAC5B,IAAI,EAAE,IAAI,EAAE,GAAG,EAClB,EAAE,gBAAgB,GAAG,aAAa;IAiBpD,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAC,IAAI,EAAE,GAAG,EAAC,GAAE,iBAAsB;IAkCzG,eAAe,CAAC,EAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAC,EAAE,eAAe,GAAG,YAAY;IAe1G,eAAe,CAAC,OAAO,EAAE,mBAAmB,GAAG,IAAI;CAmDtD"}
|
package/dist/ProjectApi.js
CHANGED
@@ -1,6 +1,6 @@
|
|
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";
|
3
|
+
import { AudioBusBox, AudioUnitBox, NoteClipBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueClipBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
4
4
|
import { AudioUnitBoxAdapter, IconSymbol, TrackType } from "@opendaw/studio-adapters";
|
5
5
|
import { ColorCodes } from "./ColorCodes";
|
6
6
|
import { PPQN } from "@opendaw/lib-dsp";
|
@@ -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);
|
63
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);
|
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
|
}
|
@@ -86,32 +104,48 @@ export class ProjectApi {
|
|
86
104
|
const events = ValueEventCollectionBox.create(boxGraph, UUID.generate());
|
87
105
|
return Option.wrap(ValueClipBox.create(boxGraph, UUID.generate(), box => {
|
88
106
|
box.index.setValue(clipIndex);
|
89
|
-
box.label.setValue(name ?? "
|
90
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
107
|
+
box.label.setValue(name ?? "Automation");
|
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
|
-
|
118
|
+
createNoteRegion({ trackBox, position, duration, loopOffset, loopDuration, eventOffset, eventCollection, mute, name, hue }) {
|
101
119
|
const { boxGraph } = this.#project;
|
102
|
-
const
|
120
|
+
const events = eventCollection ?? NoteEventCollectionBox.create(boxGraph, UUID.generate());
|
121
|
+
return NoteRegionBox.create(boxGraph, UUID.generate(), box => {
|
122
|
+
box.position.setValue(position);
|
123
|
+
box.label.setValue(name ?? "Notes");
|
124
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(trackBox.type.getValue()));
|
125
|
+
box.mute.setValue(mute ?? false);
|
126
|
+
box.duration.setValue(duration);
|
127
|
+
box.loopDuration.setValue(loopOffset ?? 0);
|
128
|
+
box.loopDuration.setValue(loopDuration ?? duration);
|
129
|
+
box.eventOffset.setValue(eventOffset ?? 0);
|
130
|
+
box.events.refer(events.owners);
|
131
|
+
box.regions.refer(trackBox.regions);
|
132
|
+
});
|
133
|
+
}
|
134
|
+
createTrackRegion(trackBox, position, duration, { name, hue } = {}) {
|
135
|
+
const { boxGraph } = this.#project;
|
136
|
+
const type = trackBox.type.getValue();
|
103
137
|
switch (type) {
|
104
138
|
case TrackType.Notes: {
|
105
139
|
const events = NoteEventCollectionBox.create(boxGraph, UUID.generate());
|
106
140
|
return Option.wrap(NoteRegionBox.create(boxGraph, UUID.generate(), box => {
|
107
141
|
box.position.setValue(Math.max(position, 0));
|
108
142
|
box.label.setValue(name ?? "Notes");
|
109
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
143
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
110
144
|
box.mute.setValue(false);
|
111
145
|
box.duration.setValue(duration);
|
112
146
|
box.loopDuration.setValue(PPQN.Bar);
|
113
147
|
box.events.refer(events.owners);
|
114
|
-
box.regions.refer(
|
148
|
+
box.regions.refer(trackBox.regions);
|
115
149
|
}));
|
116
150
|
}
|
117
151
|
case TrackType.Value: {
|
@@ -119,37 +153,30 @@ export class ProjectApi {
|
|
119
153
|
return Option.wrap(ValueRegionBox.create(boxGraph, UUID.generate(), box => {
|
120
154
|
box.position.setValue(Math.max(position, 0));
|
121
155
|
box.label.setValue(name ?? "Automation");
|
122
|
-
box.hue.setValue(ColorCodes.forTrackType(type));
|
156
|
+
box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
|
123
157
|
box.mute.setValue(false);
|
124
158
|
box.duration.setValue(duration);
|
125
159
|
box.loopDuration.setValue(PPQN.Bar);
|
126
160
|
box.events.refer(events.owners);
|
127
|
-
box.regions.refer(
|
161
|
+
box.regions.refer(trackBox.regions);
|
128
162
|
}));
|
129
163
|
}
|
130
164
|
}
|
131
165
|
return Option.None;
|
132
166
|
}
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
box.
|
140
|
-
box.
|
141
|
-
box.
|
142
|
-
box.
|
143
|
-
|
144
|
-
|
145
|
-
TrackBox.create(boxGraph, UUID.generate(), box => {
|
146
|
-
box.tracks.refer(audioUnitBox.tracks);
|
147
|
-
box.target.refer(audioUnitBox);
|
148
|
-
box.index.setValue(0);
|
149
|
-
box.type.setValue(TrackType.Undefined);
|
167
|
+
createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }) {
|
168
|
+
const { boxGraph } = this.#project;
|
169
|
+
return NoteEventBox.create(boxGraph, UUID.generate(), box => {
|
170
|
+
box.position.setValue(position);
|
171
|
+
box.duration.setValue(duration);
|
172
|
+
box.velocity.setValue(velocity ?? 1.0);
|
173
|
+
box.pitch.setValue(pitch);
|
174
|
+
box.chance.setValue(chance ?? 100.0);
|
175
|
+
box.cent.setValue(cent ?? 0.0);
|
176
|
+
box.events.refer(owner.events.targetVertex
|
177
|
+
.unwrap("Owner has no event-collection").box
|
178
|
+
.asBox(NoteEventCollectionBox).events);
|
150
179
|
});
|
151
|
-
audioBusBox.output.refer(audioUnitBox.input);
|
152
|
-
return audioBusBox;
|
153
180
|
}
|
154
181
|
deleteAudioUnit(adapter) {
|
155
182
|
const { rootBoxAdapter } = this.#project;
|
@@ -180,6 +207,14 @@ export class ProjectApi {
|
|
180
207
|
box.type.setValue(type);
|
181
208
|
});
|
182
209
|
}
|
210
|
+
#createTrack(adapter, trackType, index = 0) {
|
211
|
+
return TrackBox.create(this.#project.boxGraph, UUID.generate(), box => {
|
212
|
+
box.index.setValue(index);
|
213
|
+
box.type.setValue(trackType);
|
214
|
+
box.tracks.refer(adapter.tracksField);
|
215
|
+
box.target.refer(adapter.audioUnitBoxAdapter().box);
|
216
|
+
});
|
217
|
+
}
|
183
218
|
#pushAudioUnitsIndices(rootBoxAdapter, type, count = 1) {
|
184
219
|
const adapters = rootBoxAdapter.audioUnits.adapters();
|
185
220
|
const order = ProjectApi.AudioUnitOrdering[type];
|