@opendaw/studio-adapters 0.0.84 → 0.0.86

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.
Files changed (33) hide show
  1. package/dist/MetaData.d.ts +10 -1
  2. package/dist/MetaData.d.ts.map +1 -1
  3. package/dist/MetaData.js +49 -1
  4. package/dist/engine/EnginePreferencesSchema.d.ts.map +1 -1
  5. package/dist/engine/EnginePreferencesSchema.js +1 -3
  6. package/dist/factories/AudioUnitFactory.d.ts +1 -1
  7. package/dist/factories/AudioUnitFactory.d.ts.map +1 -1
  8. package/dist/factories/AudioUnitFactory.js +2 -2
  9. package/dist/index.d.ts +3 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +3 -1
  12. package/dist/preset/PresetDecoder.d.ts.map +1 -1
  13. package/dist/preset/PresetDecoder.js +16 -3
  14. package/dist/preset/PresetEncoder.d.ts.map +1 -1
  15. package/dist/preset/PresetEncoder.js +16 -6
  16. package/dist/project/ProjectMandatoryBoxes.d.ts +2 -2
  17. package/dist/project/ProjectMandatoryBoxes.d.ts.map +1 -1
  18. package/dist/project/ProjectSkeleton.js +4 -4
  19. package/dist/transfer/TransferAudioUnits.d.ts +15 -0
  20. package/dist/transfer/TransferAudioUnits.d.ts.map +1 -0
  21. package/dist/transfer/TransferAudioUnits.js +26 -0
  22. package/dist/transfer/TransferRegions.d.ts +12 -0
  23. package/dist/transfer/TransferRegions.d.ts.map +1 -0
  24. package/dist/transfer/TransferRegions.js +81 -0
  25. package/dist/transfer/TransferUtils.d.ts +19 -0
  26. package/dist/transfer/TransferUtils.d.ts.map +1 -0
  27. package/dist/{project/ProjectUtils.js → transfer/TransferUtils.js} +67 -100
  28. package/dist/transfer/index.d.ts +4 -0
  29. package/dist/transfer/index.d.ts.map +1 -0
  30. package/dist/transfer/index.js +3 -0
  31. package/package.json +5 -5
  32. package/dist/project/ProjectUtils.d.ts +0 -13
  33. package/dist/project/ProjectUtils.d.ts.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { Box } from "@opendaw/lib-box";
2
2
  import { Pointers } from "@opendaw/studio-enums";
3
- import { JSONValue, Nullable } from "@opendaw/lib-std";
3
+ import { JSONValue, Nullable, Observer, Option, Terminable } from "@opendaw/lib-std";
4
4
  export declare namespace MetaData {
5
5
  /**
6
6
  * Stores the given JSONValue in the target box under the given origin.
@@ -24,5 +24,14 @@ export declare namespace MetaData {
24
24
  * @param origin The origin of the meta-data. Must be unique to the app.
25
25
  */
26
26
  const clear: (target: Box<Pointers.MetaData>, origin: string) => void;
27
+ /**
28
+ * Subscribes to meta-data changes on the target box for the given origin.
29
+ * Catches up with existing meta-data and subscribes to future additions/removals.
30
+ * The observer receives the parsed JSONValue or null when cleared.
31
+ * @param target The box to observe meta-data on.
32
+ * @param origin The origin of the meta-data. Must be unique to the app.
33
+ * @param observer Called with the current value whenever it changes, or null when removed.
34
+ */
35
+ const catchupAndSubscribe: (target: Box<Pointers.MetaData>, origin: string, observer: Observer<Option<JSONValue>>) => Terminable;
27
36
  }
28
37
  //# sourceMappingURL=MetaData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MetaData.d.ts","sourceRoot":"","sources":["../src/MetaData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAAiB,SAAS,EAAE,QAAQ,EAAwB,MAAM,kBAAkB,CAAA;AAG3F,yBAAiB,QAAQ,CAAC;IACtB;;;;;;OAMG;IACI,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,SAAS,EAAE,QAAQ,MAAM,KAAG,IAgBxF,CAAA;IAED;;;;;OAKG;IACI,MAAM,IAAI,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,MAAM,KAAG,QAAQ,CAAC,SAAS,CAYvF,CAAA;IAED;;;;;OAKG;IACI,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,MAAM,KAAG,IAOtE,CAAA;CACJ"}
1
+ {"version":3,"file":"MetaData.d.ts","sourceRoot":"","sources":["../src/MetaData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAe,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EAEH,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,MAAM,EAGN,UAAU,EAGb,MAAM,kBAAkB,CAAA;AAGzB,yBAAiB,QAAQ,CAAC;IACtB;;;;;;OAMG;IACI,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,SAAS,EAAE,QAAQ,MAAM,KAAG,IAgBxF,CAAA;IAED;;;;;OAKG;IACI,MAAM,IAAI,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,MAAM,KAAG,QAAQ,CAAC,SAAS,CAYvF,CAAA;IAED;;;;;OAKG;IACI,MAAM,KAAK,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,MAAM,KAAG,IAOtE,CAAA;IAED;;;;;;;OAOG;IACI,MAAM,mBAAmB,GAAI,QAAQ,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAC9B,QAAQ,MAAM,EACd,UAAU,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAG,UAgC3E,CAAA;CACJ"}
package/dist/MetaData.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Pointers } from "@opendaw/studio-enums";
2
- import { isNotUndefined, panic, tryCatch, UUID } from "@opendaw/lib-std";
2
+ import { isNotUndefined, Option, panic, tryCatch, UUID } from "@opendaw/lib-std";
3
3
  import { MetaDataBox } from "@opendaw/studio-boxes";
4
4
  export var MetaData;
5
5
  (function (MetaData) {
@@ -69,4 +69,52 @@ export var MetaData;
69
69
  .filter((box) => box instanceof MetaDataBox && box.origin.getValue() === origin)
70
70
  .forEach(box => box.delete());
71
71
  };
72
+ /**
73
+ * Subscribes to meta-data changes on the target box for the given origin.
74
+ * Catches up with existing meta-data and subscribes to future additions/removals.
75
+ * The observer receives the parsed JSONValue or null when cleared.
76
+ * @param target The box to observe meta-data on.
77
+ * @param origin The origin of the meta-data. Must be unique to the app.
78
+ * @param observer Called with the current value whenever it changes, or null when removed.
79
+ */
80
+ MetaData.catchupAndSubscribe = (target, origin, observer) => {
81
+ if (origin === "") {
82
+ return panic("MetaData.catchupAndSubscribe: origin must be unique to your app.");
83
+ }
84
+ const subscriptions = UUID.newSet(entry => entry.uuid);
85
+ const notifyValue = (metaDataBox) => {
86
+ const { status, value, error } = tryCatch(() => JSON.parse(metaDataBox.value.getValue()));
87
+ if (status === "success") {
88
+ observer(Option.wrap(value));
89
+ }
90
+ else {
91
+ console.warn(error);
92
+ observer(Option.None);
93
+ }
94
+ };
95
+ const pointerHubSubscription = target.pointerHub.catchupAndSubscribe({
96
+ onAdded: ({ box }) => {
97
+ if (!(box instanceof MetaDataBox) || box.origin.getValue() !== origin) {
98
+ return;
99
+ }
100
+ const subscription = box.value.catchupAndSubscribe(() => notifyValue(box));
101
+ subscriptions.add({ uuid: box.address.uuid, subscription });
102
+ },
103
+ onRemoved: ({ box }) => {
104
+ if (!(box instanceof MetaDataBox) || box.origin.getValue() !== origin) {
105
+ return;
106
+ }
107
+ const entry = subscriptions.removeByKey(box.address.uuid);
108
+ entry.subscription.terminate();
109
+ observer(Option.None);
110
+ }
111
+ }, Pointers.MetaData);
112
+ return {
113
+ terminate: () => {
114
+ pointerHubSubscription.terminate();
115
+ subscriptions.forEach(({ subscription }) => subscription.terminate());
116
+ subscriptions.clear();
117
+ }
118
+ };
119
+ };
72
120
  })(MetaData || (MetaData = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"EnginePreferencesSchema.d.ts","sourceRoot":"","sources":["../../src/engine/EnginePreferencesSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAA;AAUrB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAgC/B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,yBAAiB,cAAc,CAAC;IACrB,MAAM,sBAAsB,uBAA0B,CAAA;IACtD,MAAM,oBAAoB,mCAAwB,CAAA;IAClD,MAAM,sBAAsB,2CAA0B,CAAA;IACtD,MAAM,qBAAqB,mCAAyB,CAAA;CAC9D"}
1
+ {"version":3,"file":"EnginePreferencesSchema.d.ts","sourceRoot":"","sources":["../../src/engine/EnginePreferencesSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAA;AAOrB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAgC/B,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAA;AAEjE,yBAAiB,cAAc,CAAC;IACrB,MAAM,sBAAsB,uBAA0B,CAAA;IACtD,MAAM,oBAAoB,mCAAwB,CAAA;IAClD,MAAM,sBAAsB,2CAA0B,CAAA;IACtD,MAAM,qBAAqB,mCAAyB,CAAA;CAC9D"}
@@ -3,8 +3,6 @@ const _BeatSubDivisionOptions = [1, 2, 4, 8];
3
3
  const _RecordingCountInBars = [1, 2, 3, 4, 5, 6, 7, 8];
4
4
  const _OlderTakeActionOptions = ["disable-track", "mute-region"];
5
5
  const _OlderTakeScopeOptions = ["all", "previous-only"];
6
- const isDevOrLocalhost = typeof location !== "undefined" &&
7
- (location.hostname === "localhost" || location.hostname === "dev.opendaw.studio");
8
6
  export const EngineSettingsSchema = z.object({
9
7
  metronome: z.object({
10
8
  enabled: z.boolean(),
@@ -33,7 +31,7 @@ export const EngineSettingsSchema = z.object({
33
31
  olderTakeScope: z.union(_OlderTakeScopeOptions.map(value => z.literal(value)))
34
32
  }).default({
35
33
  countInBars: 1,
36
- allowTakes: isDevOrLocalhost,
34
+ allowTakes: true,
37
35
  olderTakeAction: "mute-region",
38
36
  olderTakeScope: "previous-only"
39
37
  })
@@ -6,7 +6,7 @@ import { CaptureBox } from "../CaptureBox";
6
6
  import { ProjectSkeleton } from "../project/ProjectSkeleton";
7
7
  import { TrackType } from "../timeline/TrackType";
8
8
  export declare namespace AudioUnitFactory {
9
- const create: ({ boxGraph, mandatoryBoxes: { rootBox, primaryAudioBus } }: ProjectSkeleton, type: AudioUnitType, capture: Option<CaptureBox>, index?: int) => AudioUnitBox;
9
+ const create: ({ boxGraph, mandatoryBoxes: { rootBox, primaryAudioBusBox } }: ProjectSkeleton, type: AudioUnitType, capture: Option<CaptureBox>, index?: int) => AudioUnitBox;
10
10
  const orderAndGetIndex: (rootBox: RootBox, type: AudioUnitType) => int;
11
11
  const trackTypeToCapture: (boxGraph: BoxGraph, trackType: TrackType) => Option<CaptureBox>;
12
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AudioUnitFactory.d.ts","sourceRoot":"","sources":["../../src/factories/AudioUnitFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAC,GAAG,EAAE,MAAM,EAAO,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,QAAQ,EAAa,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAC,YAAY,EAAmC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAE5F,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,yBAAiB,gBAAgB,CAAC;IACvB,MAAM,MAAM,GAAI,4DAAwD,eAAe,EACvE,MAAM,aAAa,EACnB,SAAS,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,KAAG,YAUjE,CAAA;IAEM,MAAM,gBAAgB,GAAI,SAAS,OAAO,EAAE,MAAM,aAAa,KAAG,GAYxE,CAAA;IAEM,MAAM,kBAAkB,GAAI,UAAU,QAAQ,EAAE,WAAW,SAAS,KAAG,MAAM,CAAC,UAAU,CAS9F,CAAA;CACJ"}
1
+ {"version":3,"file":"AudioUnitFactory.d.ts","sourceRoot":"","sources":["../../src/factories/AudioUnitFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAC,GAAG,EAAE,MAAM,EAAO,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAC,QAAQ,EAAa,MAAM,kBAAkB,CAAA;AACrD,OAAO,EAAC,YAAY,EAAmC,OAAO,EAAC,MAAM,uBAAuB,CAAA;AAE5F,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAA;AACxC,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAC,SAAS,EAAC,MAAM,uBAAuB,CAAA;AAE/C,yBAAiB,gBAAgB,CAAC;IACvB,MAAM,MAAM,GAAI,+DAA2D,eAAe,EAC1E,MAAM,aAAa,EACnB,SAAS,MAAM,CAAC,UAAU,CAAC,EAAE,QAAQ,GAAG,KAAG,YAUjE,CAAA;IAEM,MAAM,gBAAgB,GAAI,SAAS,OAAO,EAAE,MAAM,aAAa,KAAG,GAYxE,CAAA;IAEM,MAAM,kBAAkB,GAAI,UAAU,QAAQ,EAAE,WAAW,SAAS,KAAG,MAAM,CAAC,UAAU,CAS9F,CAAA;CACJ"}
@@ -5,12 +5,12 @@ import { AudioUnitOrdering } from "./AudioUnitOrdering";
5
5
  import { TrackType } from "../timeline/TrackType";
6
6
  export var AudioUnitFactory;
7
7
  (function (AudioUnitFactory) {
8
- AudioUnitFactory.create = ({ boxGraph, mandatoryBoxes: { rootBox, primaryAudioBus } }, type, capture, index) => {
8
+ AudioUnitFactory.create = ({ boxGraph, mandatoryBoxes: { rootBox, primaryAudioBusBox } }, type, capture, index) => {
9
9
  const insertIndex = index ?? AudioUnitFactory.orderAndGetIndex(rootBox, type);
10
10
  console.debug(`createAudioUnit type: ${type}, insertIndex: ${insertIndex}`);
11
11
  return AudioUnitBox.create(boxGraph, UUID.generate(), box => {
12
12
  box.collection.refer(rootBox.audioUnits);
13
- box.output.refer(primaryAudioBus.input);
13
+ box.output.refer(primaryAudioBusBox.input);
14
14
  box.index.setValue(insertIndex);
15
15
  box.type.setValue(type);
16
16
  capture.ifSome(capture => box.capture.refer(capture));
package/dist/index.d.ts CHANGED
@@ -110,7 +110,6 @@ export * from "./preset/PresetHeader";
110
110
  export * from "./project/ProjectMandatoryBoxes";
111
111
  export * from "./project/ProjectQueries";
112
112
  export * from "./project/ProjectSkeleton";
113
- export * from "./project/ProjectUtils";
114
113
  export * from "./protocols";
115
114
  export * from "./sample/Sample";
116
115
  export * from "./sample/SampleLoader";
@@ -155,6 +154,9 @@ export * from "./timeline/region/FadingAdapter";
155
154
  export * from "./timeline/region/MutableRegion";
156
155
  export * from "./timeline/region/NoteRegionBoxAdapter";
157
156
  export * from "./timeline/region/ValueRegionBoxAdapter";
157
+ export * from "./transfer/TransferAudioUnits";
158
+ export * from "./transfer/TransferRegions";
159
+ export * from "./transfer/TransferUtils";
158
160
  export * from "./unions";
159
161
  export type { Preferences, PreferencesProtocol } from "@opendaw/lib-fusion";
160
162
  export { PreferencesClient, PreferencesFacade, PreferencesHost } from "@opendaw/lib-fusion";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAA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,CAAA;AAC1C,cAAc,0BAA0B,CAAA;AACxC,cAAc,UAAU,CAAA;AACxB,YAAY,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAC,iBAAiB,EAAE,iBAAiB,EAAE,eAAe,EAAC,MAAM,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -112,7 +112,6 @@ export * from "./preset/PresetHeader";
112
112
  export * from "./project/ProjectMandatoryBoxes";
113
113
  export * from "./project/ProjectQueries";
114
114
  export * from "./project/ProjectSkeleton";
115
- export * from "./project/ProjectUtils";
116
115
  export * from "./protocols";
117
116
  export * from "./sample/Sample";
118
117
  export * from "./sample/SampleLoader";
@@ -157,5 +156,8 @@ export * from "./timeline/region/FadingAdapter";
157
156
  export * from "./timeline/region/MutableRegion";
158
157
  export * from "./timeline/region/NoteRegionBoxAdapter";
159
158
  export * from "./timeline/region/ValueRegionBoxAdapter";
159
+ export * from "./transfer/TransferAudioUnits";
160
+ export * from "./transfer/TransferRegions";
161
+ export * from "./transfer/TransferUtils";
160
162
  export * from "./unions";
161
163
  export { PreferencesClient, PreferencesFacade, PreferencesHost } from "@opendaw/lib-fusion";
@@ -1 +1 @@
1
- {"version":3,"file":"PresetDecoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,OAAO,EASV,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAEH,YAAY,EAOf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAK1D,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,OAAO,eAAe,EAAE,QAAQ,eAAe,SAqDrE,CAAA;IAEM,MAAM,gBAAgB,GAAI,aAAa,WAAW,EAAE,oBAAoB,YAAY,EAAE,UAAU;QACnG,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC7B,KAAG,OAAO,CAAC,IAAI,EAAE,MAAM,CAyGvB,CAAA;CACJ"}
1
+ {"version":3,"file":"PresetDecoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,OAAO,EASV,MAAM,kBAAkB,CAAA;AAGzB,OAAO,EAEH,YAAY,EAOf,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAK1D,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,OAAO,eAAe,EAAE,QAAQ,eAAe,SAoErE,CAAA;IAEM,MAAM,gBAAgB,GAAI,aAAa,WAAW,EAAE,oBAAoB,YAAY,EAAE,UAAU;QACnG,eAAe,CAAC,EAAE,OAAO,CAAA;QACzB,gBAAgB,CAAC,EAAE,OAAO,CAAA;KAC7B,KAAG,OAAO,CAAC,IAAI,EAAE,MAAM,CAyGvB,CAAA;CACJ"}
@@ -3,9 +3,9 @@ import { BoxGraph, PointerField } from "@opendaw/lib-box";
3
3
  import { AudioUnitType } from "@opendaw/studio-enums";
4
4
  import { AudioFileBox, AudioUnitBox, BoxIO, CaptureAudioBox, CaptureMidiBox, SoundfontFileBox, TrackBox } from "@opendaw/studio-boxes";
5
5
  import { ProjectSkeleton } from "../project/ProjectSkeleton";
6
- import { ProjectUtils } from "../project/ProjectUtils";
7
- import { TrackType } from "../timeline/TrackType";
6
+ import { TransferUtils } from "../transfer";
8
7
  import { PresetHeader } from "./PresetHeader";
8
+ import { TrackType } from "../timeline/TrackType";
9
9
  export var PresetDecoder;
10
10
  (function (PresetDecoder) {
11
11
  PresetDecoder.decode = (bytes, target) => {
@@ -38,7 +38,20 @@ export var PresetDecoder;
38
38
  const sourceAudioUnitBoxes = sourceBoxGraph.boxes()
39
39
  .filter(box => isInstanceOf(box, AudioUnitBox))
40
40
  .filter(box => box.type.getValue() !== AudioUnitType.Output);
41
- ProjectUtils.extractAudioUnits(sourceAudioUnitBoxes, target, { excludeTimeline: true })
41
+ const excludeBox = (box) => TransferUtils.shouldExclude(box) || TransferUtils.excludeTimelinePredicate(box);
42
+ const dependencies = Array.from(sourceBoxGraph.dependenciesOf(sourceAudioUnitBoxes, {
43
+ alwaysFollowMandatory: true,
44
+ stopAtResources: true,
45
+ excludeBox
46
+ }).boxes);
47
+ const { mandatoryBoxes: { rootBox, primaryAudioBusBox } } = target;
48
+ const uuidMap = TransferUtils.generateMap(sourceAudioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBusBox.address.uuid);
49
+ TransferUtils.copyBoxes(uuidMap, target.boxGraph, sourceAudioUnitBoxes, dependencies);
50
+ TransferUtils.reorderAudioUnits(uuidMap, sourceAudioUnitBoxes, rootBox);
51
+ sourceAudioUnitBoxes
52
+ .map(source => asInstanceOf(rootBox.graph
53
+ .findBox(uuidMap.get(source.address.uuid).target)
54
+ .unwrap("Target AudioUnit has not been copied"), AudioUnitBox))
42
55
  .filter(box => box.type.getValue() !== AudioUnitType.Output)
43
56
  .forEach((audioUnitBox) => {
44
57
  const inputBox = audioUnitBox.input.pointerHub.incoming().at(0)?.box;
@@ -1 +1 @@
1
- {"version":3,"file":"PresetEncoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetEncoder.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAKlD,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,cAAc,YAAY,KAAG,eAWnD,CAAA;CACJ"}
1
+ {"version":3,"file":"PresetEncoder.d.ts","sourceRoot":"","sources":["../../src/preset/PresetEncoder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAKlD,yBAAiB,aAAa,CAAC;IACpB,MAAM,MAAM,GAAI,cAAc,YAAY,KAAG,eAuBnD,CAAA;CACJ"}
@@ -1,6 +1,6 @@
1
1
  import { Arrays, ByteArrayOutput } from "@opendaw/lib-std";
2
2
  import { ProjectSkeleton } from "../project/ProjectSkeleton";
3
- import { ProjectUtils } from "../project/ProjectUtils";
3
+ import { TransferUtils } from "../transfer";
4
4
  import { PresetHeader } from "./PresetHeader";
5
5
  export var PresetEncoder;
6
6
  (function (PresetEncoder) {
@@ -9,11 +9,21 @@ export var PresetEncoder;
9
9
  header.writeInt(PresetHeader.MAGIC_HEADER_OPEN);
10
10
  header.writeInt(PresetHeader.FORMAT_VERSION);
11
11
  const preset = ProjectSkeleton.empty({ createOutputCompressor: false, createDefaultUser: false });
12
- preset.boxGraph.beginTransaction();
13
- ProjectUtils.extractAudioUnits([audioUnitBox], preset, { excludeTimeline: true });
14
- preset.boxGraph.endTransaction();
12
+ const { boxGraph, mandatoryBoxes: { rootBox, primaryAudioBusBox } } = preset;
13
+ const audioUnitBoxes = [audioUnitBox];
14
+ const excludeBox = (box) => TransferUtils.shouldExclude(box) || TransferUtils.excludeTimelinePredicate(box);
15
+ boxGraph.beginTransaction();
16
+ const dependencies = Array.from(audioUnitBox.graph.dependenciesOf(audioUnitBoxes, {
17
+ alwaysFollowMandatory: true,
18
+ stopAtResources: true,
19
+ excludeBox
20
+ }).boxes);
21
+ const uuidMap = TransferUtils.generateMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBusBox.address.uuid);
22
+ TransferUtils.copyBoxes(uuidMap, boxGraph, audioUnitBoxes, dependencies);
23
+ TransferUtils.reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
24
+ boxGraph.endTransaction();
15
25
  console.debug("SAVING...");
16
- preset.boxGraph.debugBoxes();
17
- return Arrays.concatArrayBuffers(header.toArrayBuffer(), preset.boxGraph.toArrayBuffer());
26
+ boxGraph.debugBoxes();
27
+ return Arrays.concatArrayBuffers(header.toArrayBuffer(), boxGraph.toArrayBuffer());
18
28
  };
19
29
  })(PresetEncoder || (PresetEncoder = {}));
@@ -2,8 +2,8 @@ import { AudioBusBox, AudioUnitBox, RootBox, TimelineBox, UserInterfaceBox } fro
2
2
  export type ProjectMandatoryBoxes = {
3
3
  rootBox: RootBox;
4
4
  timelineBox: TimelineBox;
5
- primaryAudioBus: AudioBusBox;
6
- primaryAudioOutputUnit: AudioUnitBox;
5
+ primaryAudioBusBox: AudioBusBox;
6
+ primaryAudioUnitBox: AudioUnitBox;
7
7
  userInterfaceBoxes: ReadonlyArray<UserInterfaceBox>;
8
8
  };
9
9
  //# sourceMappingURL=ProjectMandatoryBoxes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectMandatoryBoxes.d.ts","sourceRoot":"","sources":["../../src/project/ProjectMandatoryBoxes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAEvG,MAAM,MAAM,qBAAqB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,eAAe,EAAE,WAAW,CAAA;IAC5B,sBAAsB,EAAE,YAAY,CAAA;IACpC,kBAAkB,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CACtD,CAAA"}
1
+ {"version":3,"file":"ProjectMandatoryBoxes.d.ts","sourceRoot":"","sources":["../../src/project/ProjectMandatoryBoxes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAC,MAAM,uBAAuB,CAAA;AAEvG,MAAM,MAAM,qBAAqB,GAAG;IAChC,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,WAAW,CAAA;IACxB,kBAAkB,EAAE,WAAW,CAAA;IAC/B,mBAAmB,EAAE,YAAY,CAAA;IACjC,kBAAkB,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAA;CACtD,CAAA"}
@@ -54,8 +54,8 @@ export var ProjectSkeleton;
54
54
  boxGraph,
55
55
  mandatoryBoxes: {
56
56
  rootBox,
57
- primaryAudioBus,
58
- primaryAudioOutputUnit,
57
+ primaryAudioBusBox: primaryAudioBus,
58
+ primaryAudioUnitBox: primaryAudioOutputUnit,
59
59
  timelineBox,
60
60
  userInterfaceBoxes
61
61
  }
@@ -90,8 +90,8 @@ export var ProjectSkeleton;
90
90
  const userInterfaceBoxes = rootBox.users.pointerHub.incoming().map(({ box }) => asInstanceOf(box, UserInterfaceBox));
91
91
  return {
92
92
  rootBox,
93
- primaryAudioBus,
94
- primaryAudioOutputUnit,
93
+ primaryAudioBusBox: primaryAudioBus,
94
+ primaryAudioUnitBox: primaryAudioOutputUnit,
95
95
  timelineBox,
96
96
  userInterfaceBoxes
97
97
  };
@@ -0,0 +1,15 @@
1
+ import { AudioUnitBox } from "@opendaw/studio-boxes";
2
+ import { ProjectSkeleton } from "../project/ProjectSkeleton";
3
+ export declare namespace TransferAudioUnits {
4
+ /**
5
+ * Copies audio units and their dependencies to a target project.
6
+ * Preserved resources already present in the target graph are shared, not duplicated.
7
+ * @returns the newly created audio unit boxes in the target graph
8
+ */
9
+ const transfer: (audioUnitBoxes: ReadonlyArray<AudioUnitBox>, { boxGraph: targetBoxGraph, mandatoryBoxes: { primaryAudioBusBox, rootBox } }: ProjectSkeleton, options?: {
10
+ includeAux?: boolean;
11
+ includeBus?: boolean;
12
+ excludeTimeline?: boolean;
13
+ }) => ReadonlyArray<AudioUnitBox>;
14
+ }
15
+ //# sourceMappingURL=TransferAudioUnits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransferAudioUnits.d.ts","sourceRoot":"","sources":["../../src/transfer/TransferAudioUnits.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAA;AAClD,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAA;AAG1D,yBAAiB,kBAAkB,CAAC;IAChC;;;;OAIG;IACI,MAAM,QAAQ,GAAI,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,+EAA2E,eAAe,EAC1F,UAAS;QACL,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,eAAe,CAAC,EAAE,OAAO,CAAC;KACxB,KAAG,aAAa,CAAC,YAAY,CAgB3D,CAAA;CACJ"}
@@ -0,0 +1,26 @@
1
+ import { asInstanceOf } from "@opendaw/lib-std";
2
+ import { AudioUnitBox } from "@opendaw/studio-boxes";
3
+ import { TransferUtils } from "./TransferUtils";
4
+ export var TransferAudioUnits;
5
+ (function (TransferAudioUnits) {
6
+ /**
7
+ * Copies audio units and their dependencies to a target project.
8
+ * Preserved resources already present in the target graph are shared, not duplicated.
9
+ * @returns the newly created audio unit boxes in the target graph
10
+ */
11
+ TransferAudioUnits.transfer = (audioUnitBoxes, { boxGraph: targetBoxGraph, mandatoryBoxes: { primaryAudioBusBox, rootBox } }, options = {}) => {
12
+ const excludeBox = (box) => TransferUtils.shouldExclude(box)
13
+ || (options?.excludeTimeline === true && TransferUtils.excludeTimelinePredicate(box));
14
+ const dependencies = Array.from(audioUnitBoxes[0].graph.dependenciesOf(audioUnitBoxes, {
15
+ alwaysFollowMandatory: true,
16
+ stopAtResources: true,
17
+ excludeBox
18
+ }).boxes);
19
+ const uuidMap = TransferUtils.generateMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBusBox.address.uuid);
20
+ TransferUtils.copyBoxes(uuidMap, targetBoxGraph, audioUnitBoxes, dependencies);
21
+ TransferUtils.reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
22
+ return audioUnitBoxes.map(source => asInstanceOf(rootBox.graph
23
+ .findBox(uuidMap.get(source.address.uuid).target)
24
+ .unwrap("Target AudioUnit has not been copied"), AudioUnitBox));
25
+ };
26
+ })(TransferAudioUnits || (TransferAudioUnits = {}));
@@ -0,0 +1,12 @@
1
+ import { ppqn } from "@opendaw/lib-dsp";
2
+ import { TrackBox } from "@opendaw/studio-boxes";
3
+ import { AnyRegionBox } from "../unions";
4
+ export declare namespace TransferRegions {
5
+ /**
6
+ * Copies a region and its dependencies to a target track, works across BoxGraphs.
7
+ * Preserved resources already present in the target graph are shared, not duplicated.
8
+ * @returns the newly created region box in the target graph
9
+ */
10
+ const transfer: (region: AnyRegionBox, targetTrack: TrackBox, insertPosition: ppqn, deleteSource?: boolean) => AnyRegionBox;
11
+ }
12
+ //# sourceMappingURL=TransferRegions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransferRegions.d.ts","sourceRoot":"","sources":["../../src/transfer/TransferRegions.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAErC,OAAO,EAAQ,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AACrD,OAAO,EAAC,YAAY,EAAgB,MAAM,WAAW,CAAA;AAErD,yBAAiB,eAAe,CAAC;IAC7B;;;;OAIG;IACI,MAAM,QAAQ,GAAI,QAAQ,YAAY,EACpB,aAAa,QAAQ,EACrB,gBAAgB,IAAI,EACpB,eAAc,OAAc,KAAG,YA6DvD,CAAA;CACJ"}
@@ -0,0 +1,81 @@
1
+ import { asDefined, ByteArrayInput, Option, UUID } from "@opendaw/lib-std";
2
+ import { PointerField } from "@opendaw/lib-box";
3
+ import { Pointers } from "@opendaw/studio-enums";
4
+ import { UnionBoxTypes } from "../unions";
5
+ export var TransferRegions;
6
+ (function (TransferRegions) {
7
+ /**
8
+ * Copies a region and its dependencies to a target track, works across BoxGraphs.
9
+ * Preserved resources already present in the target graph are shared, not duplicated.
10
+ * @returns the newly created region box in the target graph
11
+ */
12
+ TransferRegions.transfer = (region, targetTrack, insertPosition, deleteSource = true) => {
13
+ const targetGraph = targetTrack.graph;
14
+ const uniqueBoxes = UUID.newSet(box => box.address.uuid);
15
+ uniqueBoxes.add(region);
16
+ for (const dependency of region.graph.dependenciesOf(region, {
17
+ alwaysFollowMandatory: true,
18
+ stopAtResources: true,
19
+ excludeBox: (dep) => dep.ephemeral
20
+ }).boxes) {
21
+ uniqueBoxes.add(dependency);
22
+ }
23
+ const skippedPreservedUuids = UUID.newSet(uuid => uuid);
24
+ uniqueBoxes.forEach(box => {
25
+ if (box.resource === "preserved" && targetGraph.findBox(box.address.uuid).nonEmpty()) {
26
+ skippedPreservedUuids.add(box.address.uuid);
27
+ }
28
+ });
29
+ const shouldSkipBox = (box) => {
30
+ if (box.resource === "preserved" && skippedPreservedUuids.hasKey(box.address.uuid)) {
31
+ return true;
32
+ }
33
+ for (const [, targetAddress] of box.outgoingEdges()) {
34
+ if (skippedPreservedUuids.hasKey(targetAddress.uuid) && !targetAddress.isBox()) {
35
+ return true;
36
+ }
37
+ }
38
+ return false;
39
+ };
40
+ const sourceBoxes = uniqueBoxes.values().filter(box => !shouldSkipBox(box));
41
+ const uuidMap = UUID.newSet(entry => entry.source);
42
+ sourceBoxes.forEach(box => {
43
+ uuidMap.add({
44
+ source: box.address.uuid,
45
+ target: box.resource === "preserved" ? box.address.uuid : UUID.generate()
46
+ });
47
+ });
48
+ skippedPreservedUuids.forEach(uuid => uuidMap.add({ source: uuid, target: uuid }));
49
+ let result = null;
50
+ PointerField.decodeWith({
51
+ map: (pointer, address) => {
52
+ const remapped = address.flatMap(addr => uuidMap.opt(addr.uuid).map(entry => addr.moveTo(entry.target)));
53
+ if (remapped.nonEmpty()) {
54
+ return remapped;
55
+ }
56
+ if (pointer.pointerType === Pointers.RegionCollection) {
57
+ return Option.wrap(targetTrack.regions.address);
58
+ }
59
+ if (pointer.pointerType === Pointers.ClipCollection) {
60
+ return Option.wrap(targetTrack.clips.address);
61
+ }
62
+ return Option.None;
63
+ }
64
+ }, () => sourceBoxes.forEach(sourceBox => {
65
+ const input = new ByteArrayInput(sourceBox.toArrayBuffer());
66
+ const targetUuid = uuidMap.get(sourceBox.address.uuid).target;
67
+ targetGraph.createBox(sourceBox.name, targetUuid, box => {
68
+ box.read(input);
69
+ if (UnionBoxTypes.isRegionBox(box)) {
70
+ const regionBox = UnionBoxTypes.asRegionBox(box);
71
+ regionBox.position.setValue(insertPosition);
72
+ result = regionBox;
73
+ }
74
+ });
75
+ }));
76
+ if (deleteSource) {
77
+ region.delete();
78
+ }
79
+ return asDefined(result, "Failed to create region copy");
80
+ };
81
+ })(TransferRegions || (TransferRegions = {}));
@@ -0,0 +1,19 @@
1
+ import { ppqn } from "@opendaw/lib-dsp";
2
+ import { SortedSet, UUID } from "@opendaw/lib-std";
3
+ import { AudioUnitBox, RootBox } from "@opendaw/studio-boxes";
4
+ import { Box, BoxGraph } from "@opendaw/lib-box";
5
+ import { ProjectSkeleton } from "../project/ProjectSkeleton";
6
+ import { AnyRegionBox } from "../unions";
7
+ export declare namespace TransferUtils {
8
+ type UUIDMapper = {
9
+ source: UUID.Bytes;
10
+ target: UUID.Bytes;
11
+ };
12
+ const excludeTimelinePredicate: (box: Box) => boolean;
13
+ const shouldExclude: (box: Box) => boolean;
14
+ const generateMap: (audioUnitBoxes: ReadonlyArray<AudioUnitBox>, dependencies: ReadonlyArray<Box>, rootBoxUUID: UUID.Bytes, masterBusBoxUUID: UUID.Bytes) => SortedSet<UUID.Bytes, UUIDMapper>;
15
+ const copyBoxes: (uuidMap: SortedSet<UUID.Bytes, UUIDMapper>, targetBoxGraph: BoxGraph, audioUnitBoxes: ReadonlyArray<AudioUnitBox>, dependencies: ReadonlyArray<Box>) => void;
16
+ const reorderAudioUnits: (uuidMap: SortedSet<UUID.Bytes, UUIDMapper>, audioUnitBoxes: ReadonlyArray<AudioUnitBox>, rootBox: RootBox) => void;
17
+ const extractRegions: (regionBoxes: ReadonlyArray<AnyRegionBox>, { boxGraph, mandatoryBoxes: { primaryAudioBusBox, rootBox } }: ProjectSkeleton, insertPosition?: ppqn) => void;
18
+ }
19
+ //# sourceMappingURL=TransferUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransferUtils.d.ts","sourceRoot":"","sources":["../../src/transfer/TransferUtils.ts"],"names":[],"mappings":"AAAA,OAAO,E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,eAAe,EAC1E,iBAAgB,IAAU,KAAG,IA8C3D,CAAA;CACJ"}
@@ -3,85 +3,13 @@ import { AudioUnitBox, AuxSendBox, TrackBox } from "@opendaw/studio-boxes";
3
3
  import { IndexedBox, PointerField } from "@opendaw/lib-box";
4
4
  import { UnionBoxTypes } from "../unions";
5
5
  import { AudioUnitOrdering } from "../factories/AudioUnitOrdering";
6
- export var ProjectUtils;
7
- (function (ProjectUtils) {
6
+ export var TransferUtils;
7
+ (function (TransferUtils) {
8
8
  const isSameGraph = ({ graph: a }, { graph: b }) => a === b;
9
9
  const compareIndex = (a, b) => a.index.getValue() - b.index.getValue();
10
- const excludeTimelinePredicate = (box) => box.accept({
11
- visitTrackBox: (_box) => true
12
- }) === true;
13
- const shouldExclude = (box) => box.ephemeral || box.name === AuxSendBox.ClassName;
14
- ProjectUtils.extractAudioUnits = (audioUnitBoxes, { boxGraph, mandatoryBoxes: { primaryAudioBus, rootBox } }, options = {}) => {
15
- assert(Arrays.satisfy(audioUnitBoxes, isSameGraph), "AudioUnits must share the same BoxGraph");
16
- assert(!options.includeAux && !options.includeBus, "Options are not yet implemented");
17
- const excludeBox = (box) => shouldExclude(box) || (options?.excludeTimeline === true && excludeTimelinePredicate(box));
18
- const seen = UUID.newSet(uuid => uuid);
19
- const dependencies = audioUnitBoxes
20
- .flatMap(box => Array.from(box.graph.dependenciesOf(box, {
21
- alwaysFollowMandatory: true,
22
- stopAtResources: true,
23
- excludeBox
24
- }).boxes))
25
- .filter(box => {
26
- if (seen.hasKey(box.address.uuid)) {
27
- return false;
28
- }
29
- seen.add(box.address.uuid);
30
- return true;
31
- });
32
- const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBus.address.uuid);
33
- copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
34
- reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
35
- console.debug("inTransaction", boxGraph.inTransaction());
36
- return audioUnitBoxes.map(source => asInstanceOf(rootBox.graph
37
- .findBox(uuidMap.get(source.address.uuid).target)
38
- .unwrap("Target Track has not been copied"), AudioUnitBox));
39
- };
40
- ProjectUtils.extractRegions = (regionBoxes, { boxGraph, mandatoryBoxes: { primaryAudioBus, rootBox } }, insertPosition = 0.0) => {
41
- assert(Arrays.satisfy(regionBoxes, isSameGraph), "Region smust be from the same BoxGraph");
42
- const regionBoxSet = new Set(regionBoxes);
43
- const trackBoxSet = new Set();
44
- const audioUnitBoxSet = new SetMultimap();
45
- regionBoxes.forEach(regionBox => {
46
- const trackBox = asInstanceOf(regionBox.regions.targetVertex.unwrap().box, TrackBox);
47
- trackBoxSet.add(trackBox);
48
- const audioUnitBox = asInstanceOf(trackBox.tracks.targetVertex.unwrap().box, AudioUnitBox);
49
- audioUnitBoxSet.add(audioUnitBox, trackBox);
50
- });
51
- console.debug(`Found ${audioUnitBoxSet.keyCount()} audioUnits`);
52
- console.debug(`Found ${trackBoxSet.size} tracks`);
53
- const audioUnitBoxes = [...audioUnitBoxSet.keys()];
54
- const excludeBox = (box) => shouldExclude(box)
55
- || (isInstanceOf(box, TrackBox) && !trackBoxSet.has(box))
56
- || (UnionBoxTypes.isRegionBox(box) && !regionBoxSet.has(box));
57
- const dependencies = audioUnitBoxes
58
- .flatMap(box => Array.from(box.graph.dependenciesOf(box, {
59
- excludeBox,
60
- alwaysFollowMandatory: true,
61
- stopAtResources: true
62
- }).boxes));
63
- const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBus.address.uuid);
64
- copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
65
- reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
66
- audioUnitBoxSet.forEach((_, trackBoxes) => [...trackBoxes]
67
- .sort(compareIndex)
68
- .forEach((source, index) => {
69
- const box = boxGraph
70
- .findBox(uuidMap.get(source.address.uuid).target)
71
- .unwrap("Target Track has not been copied");
72
- asInstanceOf(box, TrackBox).index.setValue(index);
73
- }));
74
- const minPosition = regionBoxes.reduce((min, region) => Math.min(min, region.position.getValue()), Number.MAX_VALUE);
75
- const delta = insertPosition - minPosition;
76
- regionBoxes.forEach((source) => {
77
- const box = boxGraph
78
- .findBox(uuidMap.get(source.address.uuid).target)
79
- .unwrap("Target Track has not been copied");
80
- const { position } = UnionBoxTypes.asRegionBox(box);
81
- position.setValue(position.getValue() + delta);
82
- });
83
- };
84
- const generateTransferMap = (audioUnitBoxes, dependencies, rootBoxUUID, masterBusBoxUUID) => {
10
+ TransferUtils.excludeTimelinePredicate = (box) => box.accept({ visitTrackBox: () => true }) === true;
11
+ TransferUtils.shouldExclude = (box) => box.ephemeral || box.name === AuxSendBox.ClassName;
12
+ TransferUtils.generateMap = (audioUnitBoxes, dependencies, rootBoxUUID, masterBusBoxUUID) => {
85
13
  const uuidMap = UUID.newSet(({ source }) => source);
86
14
  uuidMap.addMany([
87
15
  ...audioUnitBoxes
@@ -108,17 +36,17 @@ export var ProjectUtils;
108
36
  ]);
109
37
  return uuidMap;
110
38
  };
111
- const copy = (uuidMap, boxGraph, audioUnitBoxes, dependencies) => {
112
- const existingExternalResourceUUIDs = UUID.newSet(uuid => uuid);
39
+ TransferUtils.copyBoxes = (uuidMap, targetBoxGraph, audioUnitBoxes, dependencies) => {
40
+ const existingPreservedUuids = UUID.newSet(uuid => uuid);
113
41
  dependencies.forEach((source) => {
114
- if (source.resource === "preserved" && boxGraph.findBox(source.address.uuid).nonEmpty()) {
115
- existingExternalResourceUUIDs.add(source.address.uuid);
42
+ if (source.resource === "preserved" && targetBoxGraph.findBox(source.address.uuid).nonEmpty()) {
43
+ existingPreservedUuids.add(source.address.uuid);
116
44
  }
117
45
  });
118
- const isOwnedByExistingExternalResource = (box) => {
46
+ const isOwnedByExistingPreserved = (box) => {
119
47
  for (const [pointer, targetAddress] of box.outgoingEdges()) {
120
48
  if (pointer.mandatory && !targetAddress.isBox()) {
121
- if (existingExternalResourceUUIDs.hasKey(targetAddress.uuid)) {
49
+ if (existingPreservedUuids.hasKey(targetAddress.uuid)) {
122
50
  return true;
123
51
  }
124
52
  }
@@ -126,42 +54,81 @@ export var ProjectUtils;
126
54
  return false;
127
55
  };
128
56
  PointerField.decodeWith({
129
- map: (_pointer, newAddress) => newAddress.map(address => uuidMap.opt(address.uuid).match({
130
- none: () => address,
131
- some: ({ target }) => address.moveTo(target)
57
+ map: (_pointer, address) => address.map(addr => uuidMap.opt(addr.uuid).match({
58
+ none: () => addr,
59
+ some: ({ target }) => addr.moveTo(target)
132
60
  }))
133
61
  }, () => {
134
- audioUnitBoxes
135
- .forEach((source) => {
62
+ audioUnitBoxes.forEach((source) => {
136
63
  const input = new ByteArrayInput(source.toArrayBuffer());
137
- const key = source.name;
138
64
  const uuid = uuidMap.get(source.address.uuid).target;
139
- boxGraph.createBox(key, uuid, box => box.read(input));
65
+ targetBoxGraph.createBox(source.name, uuid, box => box.read(input));
140
66
  });
141
- dependencies
142
- .forEach((source) => {
143
- if (existingExternalResourceUUIDs.hasKey(source.address.uuid)) {
67
+ dependencies.forEach((source) => {
68
+ if (existingPreservedUuids.hasKey(source.address.uuid)) {
144
69
  return;
145
70
  }
146
- if (isOwnedByExistingExternalResource(source)) {
71
+ if (isOwnedByExistingPreserved(source)) {
147
72
  return;
148
73
  }
149
74
  const input = new ByteArrayInput(source.toArrayBuffer());
150
- const key = source.name;
151
75
  const uuid = uuidMap.get(source.address.uuid).target;
152
- boxGraph.createBox(key, uuid, box => box.read(input));
76
+ targetBoxGraph.createBox(source.name, uuid, box => box.read(input));
153
77
  });
154
78
  });
155
79
  };
156
- const reorderAudioUnits = (uuidMap, audioUnitBoxes, rootBox) => audioUnitBoxes
80
+ TransferUtils.reorderAudioUnits = (uuidMap, audioUnitBoxes, rootBox) => audioUnitBoxes
157
81
  .toSorted(compareIndex)
158
- .map(source => (asInstanceOf(rootBox.graph
82
+ .map(source => asInstanceOf(rootBox.graph
159
83
  .findBox(uuidMap.get(source.address.uuid).target)
160
- .unwrap("Target Track has not been copied"), AudioUnitBox)))
84
+ .unwrap("Target AudioUnit has not been copied"), AudioUnitBox))
161
85
  .forEach((target) => IndexedBox.collectIndexedBoxes(rootBox.audioUnits, AudioUnitBox).toSorted((a, b) => {
162
86
  const orderA = AudioUnitOrdering[a.type.getValue()];
163
87
  const orderB = AudioUnitOrdering[b.type.getValue()];
164
88
  const orderDifference = orderA - orderB;
165
89
  return orderDifference === 0 ? b === target ? -1 : 1 : orderDifference;
166
90
  }).forEach((box, index) => box.index.setValue(index)));
167
- })(ProjectUtils || (ProjectUtils = {}));
91
+ TransferUtils.extractRegions = (regionBoxes, { boxGraph, mandatoryBoxes: { primaryAudioBusBox, rootBox } }, insertPosition = 0.0) => {
92
+ assert(Arrays.satisfy(regionBoxes, isSameGraph), "Region smust be from the same BoxGraph");
93
+ const regionBoxSet = new Set(regionBoxes);
94
+ const trackBoxSet = new Set();
95
+ const audioUnitBoxSet = new SetMultimap();
96
+ regionBoxes.forEach(regionBox => {
97
+ const trackBox = asInstanceOf(regionBox.regions.targetVertex.unwrap().box, TrackBox);
98
+ trackBoxSet.add(trackBox);
99
+ const audioUnitBox = asInstanceOf(trackBox.tracks.targetVertex.unwrap().box, AudioUnitBox);
100
+ audioUnitBoxSet.add(audioUnitBox, trackBox);
101
+ });
102
+ console.debug(`Found ${audioUnitBoxSet.keyCount()} audioUnits`);
103
+ console.debug(`Found ${trackBoxSet.size} tracks`);
104
+ const audioUnitBoxes = [...audioUnitBoxSet.keys()];
105
+ const excludeBox = (box) => TransferUtils.shouldExclude(box)
106
+ || (isInstanceOf(box, TrackBox) && !trackBoxSet.has(box))
107
+ || (UnionBoxTypes.isRegionBox(box) && !regionBoxSet.has(box));
108
+ const dependencies = Array.from(audioUnitBoxes[0].graph.dependenciesOf(audioUnitBoxes, {
109
+ alwaysFollowMandatory: true,
110
+ stopAtResources: true,
111
+ excludeBox
112
+ }).boxes);
113
+ const uuidMap = TransferUtils.generateMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, primaryAudioBusBox.address.uuid);
114
+ TransferUtils.copyBoxes(uuidMap, boxGraph, audioUnitBoxes, dependencies);
115
+ TransferUtils.reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
116
+ audioUnitBoxSet.forEach((_, trackBoxes) => [...trackBoxes]
117
+ .sort(compareIndex)
118
+ .forEach((source, index) => {
119
+ const box = boxGraph
120
+ .findBox(uuidMap.get(source.address.uuid).target)
121
+ .unwrap("Target Track has not been copied");
122
+ asInstanceOf(box, TrackBox).index.setValue(index);
123
+ }));
124
+ const minPosition = regionBoxes.reduce((min, region) => Math.min(min, region.position.getValue()), Number.MAX_VALUE);
125
+ const delta = insertPosition - minPosition;
126
+ regionBoxes.forEach((source) => {
127
+ const box = boxGraph
128
+ .findBox(uuidMap.get(source.address.uuid).target)
129
+ .unwrap("Target Track has not been copied");
130
+ const { position } = UnionBoxTypes.asRegionBox(box);
131
+ position.setValue(position.getValue() + delta);
132
+ });
133
+ };
134
+ })(TransferUtils || (TransferUtils = {}));
@@ -0,0 +1,4 @@
1
+ export * from "./TransferAudioUnits";
2
+ export * from "./TransferRegions";
3
+ export * from "./TransferUtils";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transfer/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,iBAAiB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from "./TransferAudioUnits";
2
+ export * from "./TransferRegions";
3
+ export * from "./TransferUtils";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendaw/studio-adapters",
3
- "version": "0.0.84",
3
+ "version": "0.0.86",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -23,12 +23,12 @@
23
23
  "test": "echo \"No tests to run\""
24
24
  },
25
25
  "dependencies": {
26
- "@opendaw/lib-box": "^0.0.73",
26
+ "@opendaw/lib-box": "^0.0.74",
27
27
  "@opendaw/lib-dsp": "^0.0.72",
28
- "@opendaw/lib-fusion": "^0.0.78",
28
+ "@opendaw/lib-fusion": "^0.0.79",
29
29
  "@opendaw/lib-runtime": "^0.0.70",
30
30
  "@opendaw/lib-std": "^0.0.69",
31
- "@opendaw/studio-boxes": "^0.0.75",
31
+ "@opendaw/studio-boxes": "^0.0.76",
32
32
  "@opendaw/studio-enums": "^0.0.64",
33
33
  "soundfont2": "^0.5.0"
34
34
  },
@@ -36,5 +36,5 @@
36
36
  "@opendaw/eslint-config": "^0.0.27",
37
37
  "@opendaw/typescript-config": "^0.0.29"
38
38
  },
39
- "gitHead": "60447f48d38d7cd08ef6a74bb011700dffff68f7"
39
+ "gitHead": "bad85dc13003b771a7470ed29eeff4dbf2244410"
40
40
  }
@@ -1,13 +0,0 @@
1
- import { ppqn } from "@opendaw/lib-dsp";
2
- import { AudioUnitBox } from "@opendaw/studio-boxes";
3
- import { ProjectSkeleton } from "./ProjectSkeleton";
4
- import { AnyRegionBox } from "../unions";
5
- export declare namespace ProjectUtils {
6
- const extractAudioUnits: (audioUnitBoxes: ReadonlyArray<AudioUnitBox>, { boxGraph, mandatoryBoxes: { primaryAudioBus, rootBox } }: ProjectSkeleton, options?: {
7
- includeAux?: boolean;
8
- includeBus?: boolean;
9
- excludeTimeline?: boolean;
10
- }) => ReadonlyArray<AudioUnitBox>;
11
- const extractRegions: (regionBoxes: ReadonlyArray<AnyRegionBox>, { boxGraph, mandatoryBoxes: { primaryAudioBus, rootBox } }: ProjectSkeleton, insertPosition?: ppqn) => void;
12
- }
13
- //# sourceMappingURL=ProjectUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProjectUtils.d.ts","sourceRoot":"","sources":["../../src/project/ProjectUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAarC,OAAO,EAAC,YAAY,EAAmD,MAAM,uBAAuB,CAAA;AAEpG,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,YAAY,EAAgB,MAAM,WAAW,CAAA;AAGrD,yBAAiB,YAAY,CAAC;IAUnB,MAAM,iBAAiB,GAAI,gBAAgB,aAAa,CAAC,YAAY,CAAC,EAC3C,4DAAwD,eAAe,EACvE,UAAS;QACL,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,UAAU,CAAC,EAAE,OAAO,CAAC;QACrB,eAAe,CAAC,EAAE,OAAO,CAAC;KACxB,KAClC,aAAa,CAAC,YAAY,CAyB/B,CAAA;IAEM,MAAM,cAAc,GAAI,aAAa,aAAa,CAAC,YAAY,CAAC,EACxC,4DAAwD,eAAe,EACvE,iBAAgB,IAAU,KAAG,IA+C3D,CAAA;CA6FJ"}