@opendaw/studio-adapters 0.3.3 → 0.3.5
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/BoxAdapters.d.ts.map +1 -1
- package/dist/BoxAdapters.js +8 -0
- package/dist/DeviceAdapter.d.ts +17 -1
- package/dist/DeviceAdapter.d.ts.map +1 -1
- package/dist/DeviceManualUrls.d.ts +3 -0
- package/dist/DeviceManualUrls.d.ts.map +1 -1
- package/dist/DeviceManualUrls.js +3 -0
- package/dist/Validator.d.ts.map +1 -1
- package/dist/Validator.js +4 -19
- package/dist/audio-unit/AudioUnitBoxAdapter.d.ts +2 -1
- package/dist/audio-unit/AudioUnitBoxAdapter.d.ts.map +1 -1
- package/dist/audio-unit/AudioUnitBoxAdapter.js +1 -0
- package/dist/audio-unit/AuxSendBoxAdapter.d.ts +1 -0
- package/dist/audio-unit/AuxSendBoxAdapter.d.ts.map +1 -1
- package/dist/audio-unit/AuxSendBoxAdapter.js +1 -0
- package/dist/devices/audio-effects/AudioEffectComposite/AudioCompositeAdapter.d.ts +2 -1
- package/dist/devices/audio-effects/AudioEffectComposite/AudioCompositeAdapter.d.ts.map +1 -1
- package/dist/devices/audio-effects/AudioEffectComposite/AudioEffectCompositeCellBoxAdapter.d.ts +8 -5
- package/dist/devices/audio-effects/AudioEffectComposite/AudioEffectCompositeCellBoxAdapter.d.ts.map +1 -1
- package/dist/devices/audio-effects/AudioEffectComposite/AudioEffectCompositeCellBoxAdapter.js +9 -3
- package/dist/devices/audio-effects/AudioEffectCompositeBoxAdapter.d.ts +2 -0
- package/dist/devices/audio-effects/AudioEffectCompositeBoxAdapter.d.ts.map +1 -1
- package/dist/devices/audio-effects/AudioEffectCompositeBoxAdapter.js +1 -0
- package/dist/devices/audio-effects/AudioSinkDeviceBoxAdapter.d.ts +33 -0
- package/dist/devices/audio-effects/AudioSinkDeviceBoxAdapter.d.ts.map +1 -0
- package/dist/devices/audio-effects/AudioSinkDeviceBoxAdapter.js +60 -0
- package/dist/devices/audio-effects/CrusherDeviceBoxAdapter.js +1 -1
- package/dist/devices/audio-effects/FrequencySplitBoxAdapter.d.ts +3 -0
- package/dist/devices/audio-effects/FrequencySplitBoxAdapter.d.ts.map +1 -1
- package/dist/devices/audio-effects/FrequencySplitBoxAdapter.js +8 -0
- package/dist/devices/audio-effects/StereoCompositeBoxAdapter.d.ts +2 -0
- package/dist/devices/audio-effects/StereoCompositeBoxAdapter.d.ts.map +1 -1
- package/dist/devices/audio-effects/StereoCompositeBoxAdapter.js +1 -0
- package/dist/devices/instruments/Cubed/CubedStep.js +1 -1
- package/dist/devices/instruments/InstrumentComposite/InstrumentCompositeCellBoxAdapter.d.ts +49 -0
- package/dist/devices/instruments/InstrumentComposite/InstrumentCompositeCellBoxAdapter.d.ts.map +1 -0
- package/dist/devices/instruments/InstrumentComposite/InstrumentCompositeCellBoxAdapter.js +88 -0
- package/dist/devices/instruments/InstrumentCompositeBoxAdapter.d.ts +33 -0
- package/dist/devices/instruments/InstrumentCompositeBoxAdapter.d.ts.map +1 -0
- package/dist/devices/instruments/InstrumentCompositeBoxAdapter.js +55 -0
- package/dist/devices/instruments/NanoDeviceBoxAdapter.d.ts +14 -1
- package/dist/devices/instruments/NanoDeviceBoxAdapter.d.ts.map +1 -1
- package/dist/devices/instruments/NanoDeviceBoxAdapter.js +28 -5
- package/dist/devices/instruments/Playfield/PlayfieldSampleBoxAdapter.d.ts +2 -1
- package/dist/devices/instruments/Playfield/PlayfieldSampleBoxAdapter.d.ts.map +1 -1
- package/dist/devices/instruments/Playfield/PlayfieldSampleBoxAdapter.js +1 -0
- package/dist/devices/instruments/Tubular/Dx7Sysex.d.ts +23 -0
- package/dist/devices/instruments/Tubular/Dx7Sysex.d.ts.map +1 -0
- package/dist/devices/instruments/Tubular/Dx7Sysex.js +159 -0
- package/dist/devices/instruments/Tubular/TubularPreset.d.ts +6 -0
- package/dist/devices/instruments/Tubular/TubularPreset.d.ts.map +1 -0
- package/dist/devices/instruments/Tubular/TubularPreset.js +39 -0
- package/dist/devices/instruments/TubularDeviceBoxAdapter.d.ts +100 -0
- package/dist/devices/instruments/TubularDeviceBoxAdapter.d.ts.map +1 -0
- package/dist/devices/instruments/TubularDeviceBoxAdapter.js +177 -0
- package/dist/factories/InstrumentBox.d.ts +2 -2
- package/dist/factories/InstrumentBox.d.ts.map +1 -1
- package/dist/factories/InstrumentFactories.d.ts +9 -2
- package/dist/factories/InstrumentFactories.d.ts.map +1 -1
- package/dist/factories/InstrumentFactories.js +40 -4
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/preset/PresetDecoder.d.ts +3 -2
- package/dist/preset/PresetDecoder.d.ts.map +1 -1
- package/dist/preset/PresetDecoder.js +51 -6
- package/dist/preset/PresetEncoder.d.ts +1 -0
- package/dist/preset/PresetEncoder.d.ts.map +1 -1
- package/dist/preset/PresetEncoder.js +36 -0
- package/dist/timeline/RegionOverlap.d.ts +13 -0
- package/dist/timeline/RegionOverlap.d.ts.map +1 -0
- package/dist/timeline/RegionOverlap.js +32 -0
- package/dist/transfer/TransferUtils.d.ts +4 -1
- package/dist/transfer/TransferUtils.d.ts.map +1 -1
- package/dist/transfer/TransferUtils.js +18 -0
- package/package.json +11 -11
|
@@ -7,9 +7,10 @@ import { TransferUtils } from "../transfer";
|
|
|
7
7
|
import { PresetHeader } from "./PresetHeader";
|
|
8
8
|
import { TrackType } from "../timeline/TrackType";
|
|
9
9
|
import { isModulatorBox } from "../modulation/ModulatorBoxAdapter";
|
|
10
|
+
import { InstrumentFactories } from "../factories/InstrumentFactories";
|
|
10
11
|
export var PresetDecoder;
|
|
11
12
|
(function (PresetDecoder) {
|
|
12
|
-
PresetDecoder.decode = (bytes, target) => {
|
|
13
|
+
PresetDecoder.decode = (bytes, target, insertIndex) => {
|
|
13
14
|
const header = new ByteArrayInput(bytes.slice(0, 8));
|
|
14
15
|
if (header.readInt() !== PresetHeader.MAGIC_HEADER_OPEN) {
|
|
15
16
|
RuntimeNotifier.notify({ message: "Invalid preset file.", icon: "Warning" });
|
|
@@ -47,7 +48,9 @@ export var PresetDecoder;
|
|
|
47
48
|
const { mandatoryBoxes: { rootBox, primaryAudioBusBox } } = target;
|
|
48
49
|
const uuidMap = TransferUtils.generateMap(sourceAudioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBusBox.address.uuid);
|
|
49
50
|
TransferUtils.copyBoxes(uuidMap, target.boxGraph, sourceAudioUnitBoxes, dependencies);
|
|
50
|
-
|
|
51
|
+
// A slot is a place among the instruments; a rack that carries buses keeps the by-type placement.
|
|
52
|
+
const allInstruments = sourceAudioUnitBoxes.every(box => box.type.getValue() === AudioUnitType.Instrument);
|
|
53
|
+
TransferUtils.reorderAudioUnits(uuidMap, sourceAudioUnitBoxes, rootBox, allInstruments ? insertIndex : undefined);
|
|
51
54
|
const importedAudioUnits = sourceAudioUnitBoxes
|
|
52
55
|
.map(source => asInstanceOf(rootBox.graph
|
|
53
56
|
.findBox(uuidMap.get(source.address.uuid, "uuid mapping").target)
|
|
@@ -214,7 +217,7 @@ export var PresetDecoder;
|
|
|
214
217
|
});
|
|
215
218
|
return Attempts.Ok;
|
|
216
219
|
};
|
|
217
|
-
|
|
220
|
+
const readSourceUnit = (bytes) => {
|
|
218
221
|
if (bytes.byteLength < 8) {
|
|
219
222
|
return Attempts.err("Invalid preset header");
|
|
220
223
|
}
|
|
@@ -235,9 +238,14 @@ export var PresetDecoder;
|
|
|
235
238
|
.filter(box => isInstanceOf(box, AudioUnitBox))
|
|
236
239
|
.map(box => asInstanceOf(box, AudioUnitBox))
|
|
237
240
|
.find(box => box.type.getValue() !== AudioUnitType.Output);
|
|
238
|
-
|
|
239
|
-
|
|
241
|
+
return isAbsent(sourceAudioUnit) ? Attempts.err("Preset contains no audio unit") : Attempts.ok(sourceAudioUnit);
|
|
242
|
+
};
|
|
243
|
+
PresetDecoder.insertEffectChain = (bytes, targetField, insertIndex, kind) => {
|
|
244
|
+
const source = readSourceUnit(bytes);
|
|
245
|
+
if (source.isFailure()) {
|
|
246
|
+
return Attempts.err(source.failureReason());
|
|
240
247
|
}
|
|
248
|
+
const sourceAudioUnit = source.result();
|
|
241
249
|
const sourceField = kind === PresetHeader.ChainKind.Audio
|
|
242
250
|
? sourceAudioUnit.audioEffects
|
|
243
251
|
: sourceAudioUnit.midiEffects;
|
|
@@ -263,7 +271,7 @@ export var PresetDecoder;
|
|
|
263
271
|
|| TransferUtils.excludeTimelinePredicate(box)
|
|
264
272
|
|| box instanceof AudioUnitBox;
|
|
265
273
|
const effectSet = new Set(effects);
|
|
266
|
-
const dependencies = TransferUtils.withModulators(Array.from(
|
|
274
|
+
const dependencies = TransferUtils.withModulators(Array.from(sourceAudioUnit.graph.dependenciesOf(effects, {
|
|
267
275
|
alwaysFollowMandatory: true,
|
|
268
276
|
stopAtResources: true,
|
|
269
277
|
excludeBox
|
|
@@ -322,4 +330,41 @@ export var PresetDecoder;
|
|
|
322
330
|
});
|
|
323
331
|
return Attempts.Ok;
|
|
324
332
|
};
|
|
333
|
+
// only the instrument travels: the layer keeps its strip and chains
|
|
334
|
+
PresetDecoder.replaceLayerInstrument = (bytes, cellBox) => {
|
|
335
|
+
const source = readSourceUnit(bytes);
|
|
336
|
+
if (source.isFailure()) {
|
|
337
|
+
return Attempts.err(source.failureReason());
|
|
338
|
+
}
|
|
339
|
+
const sourceAudioUnit = source.result();
|
|
340
|
+
const instrument = sourceAudioUnit.input.pointerHub.incoming().at(0)?.box;
|
|
341
|
+
if (isAbsent(instrument) || instrument.tags.deviceType !== "instrument") {
|
|
342
|
+
return Attempts.err("Preset contains no instrument");
|
|
343
|
+
}
|
|
344
|
+
const factoryKey = InstrumentFactories.keyOfBox(instrument);
|
|
345
|
+
if (!isDefined(factoryKey) || !InstrumentFactories.isLayerInstrument(InstrumentFactories.Named[factoryKey])) {
|
|
346
|
+
return Attempts.err(`${instrument.name} cannot be used as a layer`);
|
|
347
|
+
}
|
|
348
|
+
const targetGraph = cellBox.graph;
|
|
349
|
+
const targetFieldAddress = cellBox.instrument.address;
|
|
350
|
+
const dependencies = TransferUtils.deviceDependencies(instrument);
|
|
351
|
+
const uuidMap = TransferUtils.mapUuids([instrument, ...dependencies]);
|
|
352
|
+
const fresh = dependencies.filter(source => !TransferUtils.keepsIdentity(source) || targetGraph.findBox(source.address.uuid).isEmpty());
|
|
353
|
+
cellBox.instrument.pointerHub.incoming().forEach(({ box }) => box.delete());
|
|
354
|
+
PointerField.decodeWith({
|
|
355
|
+
map: (pointer, address) => {
|
|
356
|
+
const internal = address.flatMap(addr => uuidMap.opt(addr.uuid).map(({ target }) => addr.moveTo(target)));
|
|
357
|
+
if (internal.nonEmpty()) {
|
|
358
|
+
return internal;
|
|
359
|
+
}
|
|
360
|
+
if (pointer.pointerType === Pointers.InstrumentHost) {
|
|
361
|
+
return Option.wrap(targetFieldAddress);
|
|
362
|
+
}
|
|
363
|
+
return address.flatMap(addr => targetGraph.findBox(addr.uuid).nonEmpty()
|
|
364
|
+
? Option.wrap(addr)
|
|
365
|
+
: TransferUtils.mapModulatorCollection(pointer, targetGraph));
|
|
366
|
+
}
|
|
367
|
+
}, () => TransferUtils.cloneBoxes([instrument, ...fresh], uuidMap, targetGraph));
|
|
368
|
+
return Attempts.Ok;
|
|
369
|
+
};
|
|
325
370
|
})(PresetDecoder || (PresetDecoder = {}));
|
|
@@ -6,6 +6,7 @@ export declare namespace PresetEncoder {
|
|
|
6
6
|
excludeEffect?: (box: Box) => boolean;
|
|
7
7
|
includeTimeline?: boolean;
|
|
8
8
|
}) => ArrayBufferLike;
|
|
9
|
+
const encodeLayerInstrument: (instrument: Box) => ArrayBufferLike;
|
|
9
10
|
const encodeEffects: (effects: ReadonlyArray<Box>, kind: PresetHeader.ChainKind) => ArrayBufferLike;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=PresetEncoder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PresetEncoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAA2B,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAC,YAAY,EAA4D,MAAM,uBAAuB,CAAA;AAI7G,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAE3C,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,cAAc,YAAY,EAC1B,UAAS;QACL,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;QACtC,eAAe,CAAC,EAAE,OAAO,CAAA;KACvB,KAAG,eA+B/B,CAAA;IAEM,MAAM,aAAa,GACtB,SAAS,aAAa,CAAC,GAAG,CAAC,EAC3B,MAAM,YAAY,CAAC,SAAS,KAC7B,eAmFF,CAAA;CACJ"}
|
|
1
|
+
{"version":3,"file":"PresetEncoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,GAAG,EAA2B,MAAM,kBAAkB,CAAA;AAC9D,OAAO,EAAC,YAAY,EAA4D,MAAM,uBAAuB,CAAA;AAI7G,OAAO,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAE3C,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,cAAc,YAAY,EAC1B,UAAS;QACL,aAAa,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;QACtC,eAAe,CAAC,EAAE,OAAO,CAAA;KACvB,KAAG,eA+B/B,CAAA;IAGM,MAAM,qBAAqB,GAAI,YAAY,GAAG,KAAG,eAkCvD,CAAA;IAEM,MAAM,aAAa,GACtB,SAAS,aAAa,CAAC,GAAG,CAAC,EAC3B,MAAM,YAAY,CAAC,SAAS,KAC7B,eAmFF,CAAA;CACJ"}
|
|
@@ -36,6 +36,42 @@ export var PresetEncoder;
|
|
|
36
36
|
boxGraph.endTransaction();
|
|
37
37
|
return Arrays.concatArrayBuffers(header.toArrayBuffer(), boxGraph.toArrayBuffer());
|
|
38
38
|
};
|
|
39
|
+
// saved as an ordinary instrument preset, in a wrapper unit of its own
|
|
40
|
+
PresetEncoder.encodeLayerInstrument = (instrument) => {
|
|
41
|
+
const header = ByteArrayOutput.create();
|
|
42
|
+
header.writeInt(PresetHeader.MAGIC_HEADER_OPEN);
|
|
43
|
+
header.writeInt(PresetHeader.FORMAT_VERSION);
|
|
44
|
+
const preset = ProjectSkeleton.empty({ createOutputMaximizer: false, createDefaultUser: false });
|
|
45
|
+
const { boxGraph, mandatoryBoxes: { rootBox, primaryAudioBusBox } } = preset;
|
|
46
|
+
boxGraph.beginTransaction();
|
|
47
|
+
const captureBox = CaptureMidiBox.create(boxGraph, UUID.generate());
|
|
48
|
+
const wrapperAudioUnit = AudioUnitBox.create(boxGraph, UUID.generate(), box => {
|
|
49
|
+
box.collection.refer(rootBox.audioUnits);
|
|
50
|
+
box.output.refer(primaryAudioBusBox.input);
|
|
51
|
+
box.index.setValue(0);
|
|
52
|
+
box.type.setValue(AudioUnitType.Instrument);
|
|
53
|
+
box.capture.refer(captureBox);
|
|
54
|
+
});
|
|
55
|
+
const dependencies = TransferUtils.deviceDependencies(instrument);
|
|
56
|
+
const uuidMap = TransferUtils.mapUuids([instrument, ...dependencies]);
|
|
57
|
+
PointerField.decodeWith({
|
|
58
|
+
map: (pointer, address) => {
|
|
59
|
+
const internal = address.flatMap(addr => uuidMap.opt(addr.uuid).map(({ target }) => addr.moveTo(target)));
|
|
60
|
+
if (internal.nonEmpty()) {
|
|
61
|
+
return internal;
|
|
62
|
+
}
|
|
63
|
+
if (pointer.pointerType === Pointers.InstrumentHost) {
|
|
64
|
+
return Option.wrap(wrapperAudioUnit.input.address);
|
|
65
|
+
}
|
|
66
|
+
if (pointer.pointerType === Pointers.ModulatorCollection) {
|
|
67
|
+
return Option.wrap(rootBox.modulators.address);
|
|
68
|
+
}
|
|
69
|
+
return address.flatMap(addr => boxGraph.findBox(addr.uuid).nonEmpty() ? Option.wrap(addr) : Option.None);
|
|
70
|
+
}
|
|
71
|
+
}, () => TransferUtils.cloneBoxes([instrument, ...dependencies], uuidMap, boxGraph));
|
|
72
|
+
boxGraph.endTransaction();
|
|
73
|
+
return Arrays.concatArrayBuffers(header.toArrayBuffer(), boxGraph.toArrayBuffer());
|
|
74
|
+
};
|
|
39
75
|
PresetEncoder.encodeEffects = (effects, kind) => {
|
|
40
76
|
const header = ByteArrayOutput.create();
|
|
41
77
|
header.writeInt(PresetHeader.MAGIC_HEADER_OPEN);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { int, Option } from "@opendaw/lib-std";
|
|
2
|
+
import { ppqn } from "@opendaw/lib-dsp";
|
|
3
|
+
import { TrackBox } from "@opendaw/studio-boxes";
|
|
4
|
+
import { AnyRegionBox } from "../unions";
|
|
5
|
+
import { BoxAdapters } from "../BoxAdapters";
|
|
6
|
+
export declare namespace RegionOverlap {
|
|
7
|
+
const boundaryTolerance: (value: ppqn) => ppqn;
|
|
8
|
+
const endsAtSuccessor: (box: AnyRegionBox) => boolean;
|
|
9
|
+
const sortedRegions: (trackBox: TrackBox) => Array<AnyRegionBox>;
|
|
10
|
+
const find: (sorted: ReadonlyArray<AnyRegionBox>) => Option<int>;
|
|
11
|
+
const hasSpace: (boxAdapters: BoxAdapters, trackBox: TrackBox, position: ppqn, complete: ppqn) => boolean;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=RegionOverlap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegionOverlap.d.ts","sourceRoot":"","sources":["../../src/timeline/RegionOverlap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,MAAM,EAAC,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAC,IAAI,EAAW,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAiB,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9D,OAAO,EAAC,YAAY,EAAgB,MAAM,WAAW,CAAA;AACrD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAA;AAG1C,yBAAiB,aAAa,CAAC;IAGpB,MAAM,iBAAiB,GAAI,OAAO,IAAI,KAAG,IAAuD,CAAA;IAGhG,MAAM,eAAe,GAAI,KAAK,YAAY,KAAG,OAC6B,CAAA;IAE1E,MAAM,aAAa,GAAI,UAAU,QAAQ,KAAG,KAAK,CAAC,YAAY,CAEW,CAAA;IAEzE,MAAM,IAAI,GAAI,QAAQ,aAAa,CAAC,YAAY,CAAC,KAAG,MAAM,CAAC,GAAG,CAUpE,CAAA;IAEM,MAAM,QAAQ,GAAI,aAAa,WAAW,EAAE,UAAU,QAAQ,EAAE,UAAU,IAAI,EAAE,UAAU,IAAI,KAAG,OAIlG,CAAA;CACT"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Option } from "@opendaw/lib-std";
|
|
2
|
+
import { TimeBase } from "@opendaw/lib-dsp";
|
|
3
|
+
import { AudioRegionBox } from "@opendaw/studio-boxes";
|
|
4
|
+
import { UnionBoxTypes } from "../unions";
|
|
5
|
+
import { RegionAdapters } from "./RegionBoxAdapter";
|
|
6
|
+
export var RegionOverlap;
|
|
7
|
+
(function (RegionOverlap) {
|
|
8
|
+
const Float32RelativeEpsilon = 2 ** -23; // float32 has 23 mantissa bits
|
|
9
|
+
RegionOverlap.boundaryTolerance = (value) => Math.abs(value) * Float32RelativeEpsilon + 1e-3;
|
|
10
|
+
// The end of a seconds region moves with the tempo. It ends where the next region starts, never an error.
|
|
11
|
+
RegionOverlap.endsAtSuccessor = (box) => box instanceof AudioRegionBox && box.timeBase.getValue() !== TimeBase.Musical;
|
|
12
|
+
RegionOverlap.sortedRegions = (trackBox) => trackBox.regions.pointerHub.incoming()
|
|
13
|
+
.map(({ box }) => UnionBoxTypes.asRegionBox(box))
|
|
14
|
+
.sort((left, right) => left.position.getValue() - right.position.getValue());
|
|
15
|
+
RegionOverlap.find = (sorted) => {
|
|
16
|
+
for (let index = 1; index < sorted.length; index++) {
|
|
17
|
+
const prev = sorted[index - 1];
|
|
18
|
+
if (RegionOverlap.endsAtSuccessor(prev)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
const position = sorted[index].position.getValue();
|
|
22
|
+
if (prev.position.getValue() + prev.duration.getValue() > position + RegionOverlap.boundaryTolerance(position)) {
|
|
23
|
+
return Option.wrap(index);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return Option.None;
|
|
27
|
+
};
|
|
28
|
+
RegionOverlap.hasSpace = (boxAdapters, trackBox, position, complete) => trackBox.regions.pointerHub.incoming().every(({ box }) => {
|
|
29
|
+
const region = RegionAdapters.for(boxAdapters, box);
|
|
30
|
+
return region.resolveComplete(region.position) <= position || region.position >= complete;
|
|
31
|
+
});
|
|
32
|
+
})(RegionOverlap || (RegionOverlap = {}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ppqn } from "@opendaw/lib-dsp";
|
|
2
|
-
import { int, Option, SortedSet, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { int, Option, Predicate, SortedSet, UUID } from "@opendaw/lib-std";
|
|
3
3
|
import { AudioUnitBox, RootBox } from "@opendaw/studio-boxes";
|
|
4
4
|
import { Address, Box, BoxGraph, PointerField } from "@opendaw/lib-box";
|
|
5
5
|
import { ProjectSkeleton } from "../project/ProjectSkeleton";
|
|
@@ -13,6 +13,9 @@ export declare namespace TransferUtils {
|
|
|
13
13
|
const shouldExclude: (box: Box) => boolean;
|
|
14
14
|
const keepsIdentity: (box: Box) => boolean;
|
|
15
15
|
const withModulators: (boxes: ReadonlyArray<Box>) => ReadonlyArray<Box>;
|
|
16
|
+
const deviceDependencies: (root: Box, exclude?: Predicate<Box>) => ReadonlyArray<Box>;
|
|
17
|
+
const mapUuids: (boxes: ReadonlyArray<Box>) => SortedSet<UUID.Bytes, UUIDMapper>;
|
|
18
|
+
const cloneBoxes: (sources: ReadonlyArray<Box>, uuidMap: SortedSet<UUID.Bytes, UUIDMapper>, targetGraph: BoxGraph) => void;
|
|
16
19
|
const mapModulatorCollection: (pointer: PointerField, targetGraph: BoxGraph) => Option<Address>;
|
|
17
20
|
const generateMap: (audioUnitBoxes: ReadonlyArray<AudioUnitBox>, dependencies: ReadonlyArray<Box>, rootBoxUUID: UUID.Bytes, masterBusBoxUUID: UUID.Bytes) => SortedSet<UUID.Bytes, UUIDMapper>;
|
|
18
21
|
const copyBoxes: (uuidMap: SortedSet<UUID.Bytes, UUIDMapper>, targetBoxGraph: BoxGraph, audioUnitBoxes: ReadonlyArray<AudioUnitBox>, dependencies: ReadonlyArray<Box>) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TransferUtils.d.ts","sourceRoot":"","sources":["../../src/transfer/TransferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAMH,GAAG,EAGH,MAAM,
|
|
1
|
+
{"version":3,"file":"TransferUtils.d.ts","sourceRoot":"","sources":["../../src/transfer/TransferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACrC,OAAO,EAMH,GAAG,EAGH,MAAM,EACN,SAAS,EAET,SAAS,EACT,IAAI,EACP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,YAAY,EAAgD,OAAO,EAAW,MAAM,uBAAuB,CAAA;AAEnH,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAc,YAAY,EAAC,MAAM,kBAAkB,CAAA;AACjF,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAC,YAAY,EAAgB,MAAM,WAAW,CAAA;AAIrD,yBAAiB,aAAa,CAAC;IAC3B,KAAY,UAAU,GAAG;QAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC;QAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAA;KAAE,CAAA;IAI5D,MAAM,wBAAwB,GAAI,KAAK,GAAG,KAAG,OACqB,CAAA;IAClE,MAAM,aAAa,GAAI,KAAK,GAAG,KAAG,OAA6D,CAAA;IAC/F,MAAM,aAAa,GAAI,KAAK,GAAG,KAAG,OAA8D,CAAA;IAGhG,MAAM,cAAc,GAAI,OAAO,aAAa,CAAC,GAAG,CAAC,KAAG,aAAa,CAAC,GAAG,CAa3E,CAAA;IAEM,MAAM,kBAAkB,GAAI,MAAM,GAAG,EAAE,UAAS,SAAS,CAAC,GAAG,CAAe,KAAG,aAAa,CAAC,GAAG,CAK7D,CAAA;IAEnC,MAAM,QAAQ,GAAI,OAAO,aAAa,CAAC,GAAG,CAAC,KAAG,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAOpF,CAAA;IAEM,MAAM,UAAU,GAAI,SAAS,aAAa,CAAC,GAAG,CAAC,EAC3B,SAAS,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1C,aAAa,QAAQ,KAAG,IAK7C,CAAA;IAEC,MAAM,sBAAsB,GAAI,SAAS,YAAY,EAAE,aAAa,QAAQ,KAAG,MAAM,CAAC,OAAO,CAI/E,CAAA;IAEd,MAAM,WAAW,GAAI,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,cAAc,aAAa,CAAC,GAAG,CAAC,EAChC,aAAa,IAAI,CAAC,KAAK,EACvB,kBAAkB,IAAI,CAAC,KAAK,KAAG,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CA0B1F,CAAA;IAEM,MAAM,SAAS,GAAI,SAAS,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1C,gBAAgB,QAAQ,EACxB,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,cAAc,aAAa,CAAC,GAAG,CAAC,KAAG,IAqC5D,CAAA;IAEM,MAAM,iBAAiB,GAAI,SAAS,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,CAAC,EAC1C,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,SAAS,OAAO,EAChB,cAAc,GAAG,KAAG,IA2BrD,CAAA;IAEM,MAAM,cAAc,GAAI,aAAa,aAAa,CAAC,YAAY,CAAC,EACxC,+DAA2D,eAAe,EAC1E,iBAAgB,IAAU,KAAG,IA8C3D,CAAA;CACJ"}
|
|
@@ -31,6 +31,24 @@ export var TransferUtils;
|
|
|
31
31
|
});
|
|
32
32
|
return [...boxes, ...modulators];
|
|
33
33
|
};
|
|
34
|
+
TransferUtils.deviceDependencies = (root, exclude = () => false) => TransferUtils.withModulators(Array.from(root.graph.dependenciesOf([root], {
|
|
35
|
+
alwaysFollowMandatory: true,
|
|
36
|
+
stopAtResources: true,
|
|
37
|
+
excludeBox: box => exclude(box) || TransferUtils.shouldExclude(box) || TransferUtils.excludeTimelinePredicate(box) || box instanceof AudioUnitBox
|
|
38
|
+
}).boxes).filter(box => box !== root));
|
|
39
|
+
TransferUtils.mapUuids = (boxes) => {
|
|
40
|
+
const uuidMap = UUID.newSet(({ source }) => source);
|
|
41
|
+
uuidMap.addMany(boxes.map(box => ({
|
|
42
|
+
source: box.address.uuid,
|
|
43
|
+
target: TransferUtils.keepsIdentity(box) ? box.address.uuid : UUID.generate()
|
|
44
|
+
})));
|
|
45
|
+
return uuidMap;
|
|
46
|
+
};
|
|
47
|
+
TransferUtils.cloneBoxes = (sources, uuidMap, targetGraph) => sources.forEach(source => {
|
|
48
|
+
const input = new ByteArrayInput(source.toArrayBuffer());
|
|
49
|
+
const uuid = uuidMap.get(source.address.uuid, "uuid mapping").target;
|
|
50
|
+
targetGraph.createBox(source.name, uuid, box => box.read(input));
|
|
51
|
+
});
|
|
34
52
|
TransferUtils.mapModulatorCollection = (pointer, targetGraph) => pointer.pointerType === Pointers.ModulatorCollection
|
|
35
53
|
? Option.wrap(targetGraph.boxes().find(box => isInstanceOf(box, RootBox)))
|
|
36
54
|
.map(rootBox => rootBox.modulators.address)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendaw/studio-adapters",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"license": "AGPL-3.0-or-later",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -20,24 +20,24 @@
|
|
|
20
20
|
"generate-exports": "node generate-exports.mjs",
|
|
21
21
|
"build": "npm run generate-exports && tsc",
|
|
22
22
|
"lint": "eslint \"**/*.ts\"",
|
|
23
|
-
"test": "
|
|
23
|
+
"test": "vitest run",
|
|
24
24
|
"generate-all-boxes": "npx tsx scripts/generate-all-boxes.ts",
|
|
25
25
|
"pregenerate-all-boxes": "npm run build -w @opendaw/studio-forge-boxes && npm run build -w @opendaw/studio-boxes"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@opendaw/lib-box": "^0.0.
|
|
29
|
-
"@opendaw/lib-dsp": "^0.0.
|
|
30
|
-
"@opendaw/lib-fusion": "^0.0.
|
|
31
|
-
"@opendaw/lib-midi": "^0.0.
|
|
32
|
-
"@opendaw/lib-runtime": "^0.0.
|
|
33
|
-
"@opendaw/lib-std": "^0.0.
|
|
34
|
-
"@opendaw/studio-boxes": "^0.0.
|
|
35
|
-
"@opendaw/studio-enums": "^0.1.
|
|
28
|
+
"@opendaw/lib-box": "^0.0.95",
|
|
29
|
+
"@opendaw/lib-dsp": "^0.0.94",
|
|
30
|
+
"@opendaw/lib-fusion": "^0.0.104",
|
|
31
|
+
"@opendaw/lib-midi": "^0.0.75",
|
|
32
|
+
"@opendaw/lib-runtime": "^0.0.87",
|
|
33
|
+
"@opendaw/lib-std": "^0.0.86",
|
|
34
|
+
"@opendaw/studio-boxes": "^0.0.111",
|
|
35
|
+
"@opendaw/studio-enums": "^0.1.4",
|
|
36
36
|
"soundfont2": "^0.5.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@opendaw/eslint-config": "^0.0.28",
|
|
40
40
|
"@opendaw/typescript-config": "^0.0.32"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "88113f892cea2fa9495289a9c166b6fe0f93ce69"
|
|
43
43
|
}
|