@opendaw/studio-core 0.0.48 → 0.0.50
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/AudioOfflineRenderer.d.ts +2 -2
- package/dist/AudioOfflineRenderer.d.ts.map +1 -1
- package/dist/AudioOfflineRenderer.js +5 -68
- package/dist/Engine.d.ts +2 -2
- package/dist/Engine.d.ts.map +1 -1
- package/dist/ffmpeg/FFmpegConverter.d.ts +6 -0
- package/dist/ffmpeg/FFmpegConverter.d.ts.map +1 -0
- package/dist/ffmpeg/FFmpegConverter.js +1 -0
- package/dist/ffmpeg/FFmpegWorker.d.ts +18 -0
- package/dist/ffmpeg/FFmpegWorker.d.ts.map +1 -0
- package/dist/ffmpeg/FFmpegWorker.js +115 -0
- package/dist/ffmpeg/flac.d.ts +12 -0
- package/dist/ffmpeg/flac.d.ts.map +1 -0
- package/dist/ffmpeg/flac.js +32 -0
- package/dist/ffmpeg/index.d.ts +3 -0
- package/dist/ffmpeg/index.d.ts.map +1 -0
- package/dist/ffmpeg/index.js +2 -0
- package/dist/ffmpeg/mp3.d.ts +13 -0
- package/dist/ffmpeg/mp3.d.ts.map +1 -0
- package/dist/ffmpeg/mp3.js +37 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/processors.js +14 -14
- package/dist/processors.js.map +4 -4
- package/dist/project/ProjectApi.d.ts +1 -9
- package/dist/project/ProjectApi.d.ts.map +1 -1
- package/dist/project/ProjectApi.js +3 -67
- package/dist/project/ProjectUtils.d.ts +12 -0
- package/dist/project/ProjectUtils.d.ts.map +1 -0
- package/dist/project/ProjectUtils.js +145 -0
- package/dist/project/index.d.ts +1 -0
- package/dist/project/index.d.ts.map +1 -1
- package/dist/project/index.js +1 -0
- package/dist/workers-main.js +2 -2
- package/dist/workers-main.js.map +2 -2
- package/package.json +21 -15
|
@@ -3,7 +3,7 @@ import { ppqn } from "@opendaw/lib-dsp";
|
|
|
3
3
|
import { Field, PointerField } from "@opendaw/lib-box";
|
|
4
4
|
import { AudioUnitType, Pointers } from "@opendaw/studio-enums";
|
|
5
5
|
import { AudioBusBox, AudioUnitBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
|
6
|
-
import { AnyClipBox,
|
|
6
|
+
import { AnyClipBox, AudioUnitBoxAdapter, EffectPointerType, IconSymbol, IndexedAdapterCollectionListener } from "@opendaw/studio-adapters";
|
|
7
7
|
import { Project } from "./Project";
|
|
8
8
|
import { InstrumentFactory } from "../InstrumentFactory";
|
|
9
9
|
import { InstrumentProduct } from "../InstrumentProduct";
|
|
@@ -54,13 +54,5 @@ export declare class ProjectApi {
|
|
|
54
54
|
createTrackRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
|
|
55
55
|
createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBox;
|
|
56
56
|
deleteAudioUnit(audioUnitBox: AudioUnitBox): void;
|
|
57
|
-
extractIntoNew(audioUnits: ReadonlyArray<AudioUnitBox>, option?: {
|
|
58
|
-
includeAux?: boolean;
|
|
59
|
-
includeBus?: boolean;
|
|
60
|
-
}): Project;
|
|
61
|
-
mergeInto(...sources: ReadonlyArray<{
|
|
62
|
-
source: Project | AnyRegionBox;
|
|
63
|
-
insertAt: ppqn;
|
|
64
|
-
}>): Promise<void>;
|
|
65
57
|
}
|
|
66
58
|
//# sourceMappingURL=ProjectApi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectApi.d.ts","sourceRoot":"","sources":["../../src/project/ProjectApi.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ProjectApi.d.ts","sourceRoot":"","sources":["../../src/project/ProjectApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,K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B,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,WAAW,GAAE,GAA6B,GAAG,QAAQ;IAI3I,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;IAoBpD,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,YAAY,EAAE,YAAY,GAAG,IAAI;CA2DpD"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { asDefined, asInstanceOf, assert, clamp, Option, Strings, UUID } from "@opendaw/lib-std";
|
|
2
2
|
import { PPQN } from "@opendaw/lib-dsp";
|
|
3
|
-
import { IndexedBox,
|
|
3
|
+
import { IndexedBox, StringField } from "@opendaw/lib-box";
|
|
4
4
|
import { AudioUnitType } from "@opendaw/studio-enums";
|
|
5
|
-
import { AudioBusBox,
|
|
5
|
+
import { AudioBusBox, AudioUnitBox, CaptureAudioBox, CaptureMidiBox, NoteClipBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueClipBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
|
|
6
6
|
import { IconSymbol, TrackType } from "@opendaw/studio-adapters";
|
|
7
|
-
import { Project } from "./Project";
|
|
8
7
|
import { ColorCodes } from "../ColorCodes";
|
|
9
8
|
import { AudioUnitOrdering } from "../AudioUnitOrdering";
|
|
10
9
|
// noinspection JSUnusedGlobalSymbols
|
|
@@ -179,69 +178,6 @@ export class ProjectApi {
|
|
|
179
178
|
IndexedBox.removeOrder(rootBox.audioUnits, audioUnitBox.index.getValue());
|
|
180
179
|
audioUnitBox.delete();
|
|
181
180
|
}
|
|
182
|
-
// This version ignores selected items, buses and aux-sends. All outputs will be redirected to the primary output.
|
|
183
|
-
extractIntoNew(audioUnits, option = {}) {
|
|
184
|
-
console.time("extractIntoNew");
|
|
185
|
-
assert(Arrays.satisfy(audioUnits, (a, b) => a.graph === b.graph), "AudioUnits must share the same BoxGraph");
|
|
186
|
-
// TODO Implement include options.
|
|
187
|
-
assert(!option.includeAux && !option.includeBus, "Options are not yet implemented");
|
|
188
|
-
const targetProject = Project.new(this.#project.env);
|
|
189
|
-
const { boxGraph, masterBusBox, masterAudioUnit, rootBox } = targetProject;
|
|
190
|
-
const dependencies = audioUnits
|
|
191
|
-
.flatMap(box => Array.from(box.graph.dependenciesOf(box).boxes))
|
|
192
|
-
.filter(box => box.name !== SelectionBox.ClassName && box.name !== AuxSendBox.ClassName);
|
|
193
|
-
const uuidMap = UUID.newSet(({ source }) => source);
|
|
194
|
-
const allAdded = uuidMap.addMany([
|
|
195
|
-
...audioUnits
|
|
196
|
-
.filter(({ output: { targetAddress } }) => targetAddress.nonEmpty())
|
|
197
|
-
.map(box => ({
|
|
198
|
-
source: box.output.targetAddress.unwrap().uuid,
|
|
199
|
-
target: masterBusBox.address.uuid
|
|
200
|
-
})),
|
|
201
|
-
...audioUnits
|
|
202
|
-
.map(box => ({
|
|
203
|
-
source: box.collection.targetAddress.unwrap("AudioUnitBox was not connect to a RootBox").uuid,
|
|
204
|
-
target: rootBox.audioUnits.address.uuid
|
|
205
|
-
})),
|
|
206
|
-
...audioUnits
|
|
207
|
-
.map(box => ({ source: box.address.uuid, target: UUID.generate() })),
|
|
208
|
-
...dependencies
|
|
209
|
-
.map(({ address: { uuid }, name }) => ({ source: uuid, target: name === AudioFileBox.ClassName ? uuid : UUID.generate() }))
|
|
210
|
-
]);
|
|
211
|
-
assert(allAdded, "Some mapping are redundant");
|
|
212
|
-
boxGraph.beginTransaction();
|
|
213
|
-
PointerField.decodeWith({
|
|
214
|
-
map: (_pointer, newAddress) => newAddress.map(address => uuidMap.opt(address.uuid).match({
|
|
215
|
-
none: () => address,
|
|
216
|
-
some: ({ target }) => address.moveTo(target)
|
|
217
|
-
}))
|
|
218
|
-
}, () => {
|
|
219
|
-
audioUnits
|
|
220
|
-
.toSorted((a, b) => a.index.getValue() - b.index.getValue())
|
|
221
|
-
.forEach((source, index) => {
|
|
222
|
-
const input = new ByteArrayInput(source.toArrayBuffer());
|
|
223
|
-
const key = source.name;
|
|
224
|
-
const uuid = uuidMap.get(source.address.uuid).target;
|
|
225
|
-
const copy = boxGraph.createBox(key, uuid, box => box.read(input));
|
|
226
|
-
copy.index.setValue(index);
|
|
227
|
-
});
|
|
228
|
-
masterAudioUnit.index.setValue(audioUnits.length);
|
|
229
|
-
dependencies
|
|
230
|
-
.forEach((source) => {
|
|
231
|
-
const input = new ByteArrayInput(source.toArrayBuffer());
|
|
232
|
-
const key = source.name;
|
|
233
|
-
const uuid = uuidMap.get(source.address.uuid).target;
|
|
234
|
-
boxGraph.createBox(key, uuid, box => box.read(input));
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
boxGraph.endTransaction();
|
|
238
|
-
boxGraph.verifyPointers();
|
|
239
|
-
console.timeEnd("extractIntoNew");
|
|
240
|
-
return targetProject;
|
|
241
|
-
}
|
|
242
|
-
mergeInto(...sources) {
|
|
243
|
-
return Promise.reject("Not implemented");
|
|
244
|
-
}
|
|
245
181
|
#createAudioUnit(type, capture, index) {
|
|
246
182
|
const { boxGraph, rootBox, masterBusBox } = this.#project;
|
|
247
183
|
const insertIndex = index ?? this.#sortAudioUnitOrdering(type);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ppqn } from "@opendaw/lib-dsp";
|
|
2
|
+
import { AnyRegionBox } from "@opendaw/studio-adapters";
|
|
3
|
+
import { Project } from "./Project";
|
|
4
|
+
import { AudioUnitBox } from "@opendaw/studio-boxes";
|
|
5
|
+
export declare namespace ProjectUtils {
|
|
6
|
+
const extractAudioUnits: (audioUnitBoxes: ReadonlyArray<AudioUnitBox>, targetProject: Project, options?: {
|
|
7
|
+
includeAux?: boolean;
|
|
8
|
+
includeBus?: boolean;
|
|
9
|
+
}) => void;
|
|
10
|
+
const extractRegions: (regionBoxes: ReadonlyArray<AnyRegionBox>, targetProject: Project, insertPosition?: ppqn) => void;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ProjectUtils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectUtils.d.ts","sourceRoot":"","sources":["../../src/project/ProjectUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAAC,YAAY,EAAgB,MAAM,0BAA0B,CAAA;AACpE,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAcjC,OAAO,EAEH,YAAY,EAOf,MAAM,uBAAuB,CAAA;AAI9B,yBAAiB,YAAY,CAAC;IAMnB,MAAM,iBAAiB,GAAI,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,eAAe,OAAO,EACtB,UAAS;QAAE,UAAU,CAAC,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAO,KAAG,IAehG,CAAA;IAEM,MAAM,cAAc,GAAI,aAAa,aAAa,CAAC,YAAY,CAAC,EACxC,eAAe,OAAO,EACtB,iBAAgB,IAAU,KAAG,IAkD3D,CAAA;CAmFJ"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { UnionBoxTypes } from "@opendaw/studio-adapters";
|
|
2
|
+
import { Arrays, asInstanceOf, assert, ByteArrayInput, isInstanceOf, SetMultimap, UUID } from "@opendaw/lib-std";
|
|
3
|
+
import { AudioFileBox, AudioUnitBox, AuxSendBox, SelectionBox, SoundfontFileBox, TrackBox } from "@opendaw/studio-boxes";
|
|
4
|
+
import { IndexedBox, PointerField } from "@opendaw/lib-box";
|
|
5
|
+
import { AudioUnitOrdering } from "../AudioUnitOrdering";
|
|
6
|
+
export var ProjectUtils;
|
|
7
|
+
(function (ProjectUtils) {
|
|
8
|
+
const isSameGraph = ({ graph: a }, { graph: b }) => a === b;
|
|
9
|
+
const compareIndex = (a, b) => a.index.getValue() - b.index.getValue();
|
|
10
|
+
ProjectUtils.extractAudioUnits = (audioUnitBoxes, targetProject, options = {}) => {
|
|
11
|
+
assert(Arrays.satisfy(audioUnitBoxes, isSameGraph), "AudioUnits must share the same BoxGraph");
|
|
12
|
+
// TODO Implement include options.
|
|
13
|
+
assert(!options.includeAux && !options.includeBus, "Options are not yet implemented");
|
|
14
|
+
const { boxGraph, masterBusBox, masterAudioUnit, rootBox } = targetProject;
|
|
15
|
+
const dependencies = audioUnitBoxes
|
|
16
|
+
.flatMap(box => Array.from(box.graph.dependenciesOf(box, { alwaysFollowMandatory: true }).boxes))
|
|
17
|
+
.filter(box => box.name !== SelectionBox.ClassName && box.name !== AuxSendBox.ClassName);
|
|
18
|
+
const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
|
|
19
|
+
boxGraph.beginTransaction();
|
|
20
|
+
copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
|
|
21
|
+
reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
|
|
22
|
+
boxGraph.endTransaction();
|
|
23
|
+
boxGraph.verifyPointers();
|
|
24
|
+
};
|
|
25
|
+
ProjectUtils.extractRegions = (regionBoxes, targetProject, insertPosition = 0.0) => {
|
|
26
|
+
assert(Arrays.satisfy(regionBoxes, isSameGraph), "Region smust be from the same BoxGraph");
|
|
27
|
+
const regionBoxSet = new Set(regionBoxes);
|
|
28
|
+
const trackBoxSet = new Set();
|
|
29
|
+
const audioUnitBoxSet = new SetMultimap();
|
|
30
|
+
// Collect AudioUnits and Tracks
|
|
31
|
+
regionBoxes.forEach(regionBox => {
|
|
32
|
+
const trackBox = asInstanceOf(regionBox.regions.targetVertex.unwrap().box, TrackBox);
|
|
33
|
+
trackBoxSet.add(trackBox);
|
|
34
|
+
const audioUnitBox = asInstanceOf(trackBox.tracks.targetVertex.unwrap().box, AudioUnitBox);
|
|
35
|
+
audioUnitBoxSet.add(audioUnitBox, trackBox);
|
|
36
|
+
});
|
|
37
|
+
console.debug(`Found ${audioUnitBoxSet.keyCount()} audioUnits`);
|
|
38
|
+
console.debug(`Found ${trackBoxSet.size} tracks`);
|
|
39
|
+
const audioUnitBoxes = [...audioUnitBoxSet.keys()];
|
|
40
|
+
const { boxGraph, masterBusBox, masterAudioUnit, rootBox } = targetProject;
|
|
41
|
+
const excludeBox = box => (isInstanceOf(box, TrackBox) && !trackBoxSet.has(box))
|
|
42
|
+
|| (UnionBoxTypes.isRegionBox(box) && !regionBoxSet.has(box));
|
|
43
|
+
const dependencies = audioUnitBoxes
|
|
44
|
+
.flatMap(box => Array.from(box.graph.dependenciesOf(box, { excludeBox, alwaysFollowMandatory: true }).boxes))
|
|
45
|
+
.filter(box => box.name !== SelectionBox.ClassName && box.name !== AuxSendBox.ClassName);
|
|
46
|
+
const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
|
|
47
|
+
boxGraph.beginTransaction();
|
|
48
|
+
copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
|
|
49
|
+
reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
|
|
50
|
+
// reorder track indices
|
|
51
|
+
audioUnitBoxSet.forEach((_, trackBoxes) => [...trackBoxes]
|
|
52
|
+
.sort(compareIndex)
|
|
53
|
+
.forEach((source, index) => {
|
|
54
|
+
const box = boxGraph
|
|
55
|
+
.findBox(uuidMap.get(source.address.uuid).target)
|
|
56
|
+
.unwrap("Target Track has not been copied");
|
|
57
|
+
asInstanceOf(box, TrackBox).index.setValue(index);
|
|
58
|
+
}));
|
|
59
|
+
// move new regions to the target position
|
|
60
|
+
const minPosition = regionBoxes.reduce((min, region) => Math.min(min, region.position.getValue()), Number.MAX_VALUE);
|
|
61
|
+
const delta = insertPosition - minPosition;
|
|
62
|
+
regionBoxes.forEach((source) => {
|
|
63
|
+
const box = boxGraph
|
|
64
|
+
.findBox(uuidMap.get(source.address.uuid).target)
|
|
65
|
+
.unwrap("Target Track has not been copied");
|
|
66
|
+
const position = UnionBoxTypes.asRegionBox(box).position;
|
|
67
|
+
position.setValue(position.getValue() + delta);
|
|
68
|
+
});
|
|
69
|
+
boxGraph.endTransaction();
|
|
70
|
+
boxGraph.verifyPointers();
|
|
71
|
+
};
|
|
72
|
+
const generateTransferMap = (audioUnitBoxes, dependencies, rootBoxUUID, masterBusBoxUUID) => {
|
|
73
|
+
const uuidMap = UUID.newSet(({ source }) => source);
|
|
74
|
+
uuidMap.addMany([
|
|
75
|
+
...audioUnitBoxes
|
|
76
|
+
.filter(({ output: { targetAddress } }) => targetAddress.nonEmpty())
|
|
77
|
+
.map(box => ({
|
|
78
|
+
source: box.output.targetAddress.unwrap().uuid,
|
|
79
|
+
target: masterBusBoxUUID
|
|
80
|
+
})),
|
|
81
|
+
...audioUnitBoxes
|
|
82
|
+
.map(box => ({
|
|
83
|
+
source: box.collection.targetAddress.unwrap("AudioUnitBox was not connected to a RootBox").uuid,
|
|
84
|
+
target: rootBoxUUID
|
|
85
|
+
})),
|
|
86
|
+
...audioUnitBoxes
|
|
87
|
+
.map(box => ({
|
|
88
|
+
source: box.address.uuid,
|
|
89
|
+
target: UUID.generate()
|
|
90
|
+
})),
|
|
91
|
+
...dependencies
|
|
92
|
+
.map(({ address: { uuid }, name }) => ({
|
|
93
|
+
source: uuid,
|
|
94
|
+
target: name === AudioFileBox.ClassName || name === SoundfontFileBox.ClassName
|
|
95
|
+
? uuid
|
|
96
|
+
: UUID.generate()
|
|
97
|
+
}))
|
|
98
|
+
]);
|
|
99
|
+
return uuidMap;
|
|
100
|
+
};
|
|
101
|
+
const copy = (uuidMap, boxGraph, audioUnitBoxes, dependencies) => {
|
|
102
|
+
PointerField.decodeWith({
|
|
103
|
+
map: (_pointer, newAddress) => newAddress.map(address => uuidMap.opt(address.uuid).match({
|
|
104
|
+
none: () => address,
|
|
105
|
+
some: ({ target }) => address.moveTo(target)
|
|
106
|
+
}))
|
|
107
|
+
}, () => {
|
|
108
|
+
audioUnitBoxes
|
|
109
|
+
.forEach((source) => {
|
|
110
|
+
const input = new ByteArrayInput(source.toArrayBuffer());
|
|
111
|
+
const key = source.name;
|
|
112
|
+
const uuid = uuidMap.get(source.address.uuid).target;
|
|
113
|
+
boxGraph.createBox(key, uuid, box => box.read(input));
|
|
114
|
+
});
|
|
115
|
+
dependencies
|
|
116
|
+
.forEach((source) => {
|
|
117
|
+
const input = new ByteArrayInput(source.toArrayBuffer());
|
|
118
|
+
const key = source.name;
|
|
119
|
+
const uuid = uuidMap.get(source.address.uuid).target;
|
|
120
|
+
boxGraph.createBox(key, uuid, box => box.read(input));
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const reorderAudioUnits = (uuidMap, audioUnitBoxes, rootBox) => {
|
|
125
|
+
audioUnitBoxes
|
|
126
|
+
.toSorted(compareIndex)
|
|
127
|
+
.forEach((box) => {
|
|
128
|
+
const boxes = IndexedBox.collectIndexedBoxes(rootBox.audioUnits, AudioUnitBox);
|
|
129
|
+
const order = AudioUnitOrdering[box.type.getValue()];
|
|
130
|
+
let index = 0 | 0;
|
|
131
|
+
for (; index < boxes.length; index++) {
|
|
132
|
+
if (AudioUnitOrdering[boxes[index].type.getValue()] > order) {
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const insertIndex = index;
|
|
137
|
+
while (index < boxes.length) {
|
|
138
|
+
boxes[index].index.setValue(++index);
|
|
139
|
+
}
|
|
140
|
+
asInstanceOf(rootBox.graph
|
|
141
|
+
.findBox(uuidMap.get(box.address.uuid).target)
|
|
142
|
+
.unwrap("Target Track has not been copied"), AudioUnitBox).index.setValue(insertIndex);
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
})(ProjectUtils || (ProjectUtils = {}));
|
package/dist/project/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/project/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,eAAe,CAAA;AAC7B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
|