@opendaw/studio-core 0.0.49 → 0.0.51

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.
@@ -1,5 +1,5 @@
1
- import { AcceptedSource } from "./FFmpegWorker";
2
1
  import { Progress } from "@opendaw/lib-std";
2
+ import type { AcceptedSource } from "./FFmpegWorker";
3
3
  export interface FFmpegConverter<OPTIONS> {
4
4
  convert(source: AcceptedSource, progress: Progress.Handler, options?: OPTIONS): Promise<ArrayBuffer>;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"FFmpegConverter.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/FFmpegConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAEzC,MAAM,WAAW,eAAe,CAAC,OAAO;IACpC,OAAO,CAAC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAC1B,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CACnD"}
1
+ {"version":3,"file":"FFmpegConverter.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/FFmpegConverter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,gBAAgB,CAAA;AAElD,MAAM,WAAW,eAAe,CAAC,OAAO;IACpC,OAAO,CAAC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAC1B,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CACnD"}
@@ -1,6 +1,6 @@
1
- import { FFmpegConverter } from "./FFmpegConverter";
2
1
  import { int, Progress } from "@opendaw/lib-std";
3
- import { AcceptedSource, FFmpegWorker } from "./FFmpegWorker";
2
+ import type { FFmpegConverter } from "./FFmpegConverter";
3
+ import type { AcceptedSource, FFmpegWorker } from "./FFmpegWorker";
4
4
  export type FlacOptions = {
5
5
  compression: int;
6
6
  };
@@ -1 +1 @@
1
- {"version":3,"file":"flac.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/flac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAG3D,MAAM,MAAM,WAAW,GAAG;IAAE,WAAW,EAAE,GAAG,CAAA;CAAE,CAAA;AAE9C,qBAAa,aAAc,YAAW,eAAe,CAAC,WAAW,CAAC;;gBAGlD,MAAM,EAAE,YAAY;IAC1B,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CA0BjH"}
1
+ {"version":3,"file":"flac.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/flac.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAE,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAGhE,MAAM,MAAM,WAAW,GAAG;IAAE,WAAW,EAAE,GAAG,CAAA;CAAE,CAAA;AAE9C,qBAAa,aAAc,YAAW,eAAe,CAAC,WAAW,CAAC;;gBAGlD,MAAM,EAAE,YAAY;IAC1B,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;CA0BjH"}
@@ -1,6 +1,6 @@
1
1
  import { Progress } from "@opendaw/lib-std";
2
- import { AcceptedSource, FFmpegWorker } from "./FFmpegWorker";
3
- import { FFmpegConverter } from "./FFmpegConverter";
2
+ import type { AcceptedSource, FFmpegWorker } from "./FFmpegWorker";
3
+ import type { FFmpegConverter } from "./FFmpegConverter";
4
4
  export type Mp3Options = {
5
5
  bitrate?: string;
6
6
  quality?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"mp3.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/mp3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAC3D,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AAEjD,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/D,qBAAa,YAAa,YAAW,eAAe,CAAC,UAAU,CAAC;;gBAGhD,MAAM,EAAE,YAAY;IAE1B,OAAO,CAAC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAC1B,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA8BhE"}
1
+ {"version":3,"file":"mp3.d.ts","sourceRoot":"","sources":["../../src/ffmpeg/mp3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AACzC,OAAO,KAAK,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,gBAAgB,CAAA;AAChE,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAA;AAEtD,MAAM,MAAM,UAAU,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAE/D,qBAAa,YAAa,YAAW,eAAe,CAAC,UAAU,CAAC;;gBAGhD,MAAM,EAAE,YAAY;IAE1B,OAAO,CAAC,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,QAAQ,CAAC,OAAO,EAC1B,OAAO,GAAE,UAAe,GAAG,OAAO,CAAC,WAAW,CAAC;CA8BhE"}
@@ -1 +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;AAYjC,OAAO,EAEH,YAAY,EAMf,MAAM,uBAAuB,CAAA;AAG9B,yBAAiB,YAAY,CAAC;IAKnB,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,IAuChG,CAAA;IAEM,MAAM,cAAc,GAAI,aAAa,aAAa,CAAC,YAAY,CAAC,EACxC,eAAe,OAAO,EACtB,iBAAgB,IAAU,KAAG,IAyE3D,CAAA;CAmCJ"}
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;CAsFJ"}
@@ -1,51 +1,29 @@
1
1
  import { UnionBoxTypes } from "@opendaw/studio-adapters";
2
2
  import { Arrays, asInstanceOf, assert, ByteArrayInput, isInstanceOf, SetMultimap, UUID } from "@opendaw/lib-std";
3
3
  import { AudioFileBox, AudioUnitBox, AuxSendBox, SelectionBox, SoundfontFileBox, TrackBox } from "@opendaw/studio-boxes";
4
- import { PointerField } from "@opendaw/lib-box";
4
+ import { IndexedBox, PointerField } from "@opendaw/lib-box";
5
+ import { AudioUnitOrdering } from "../AudioUnitOrdering";
5
6
  export var ProjectUtils;
6
7
  (function (ProjectUtils) {
7
8
  const isSameGraph = ({ graph: a }, { graph: b }) => a === b;
9
+ const compareIndex = (a, b) => a.index.getValue() - b.index.getValue();
8
10
  ProjectUtils.extractAudioUnits = (audioUnitBoxes, targetProject, options = {}) => {
9
11
  assert(Arrays.satisfy(audioUnitBoxes, isSameGraph), "AudioUnits must share the same BoxGraph");
10
12
  // TODO Implement include options.
11
13
  assert(!options.includeAux && !options.includeBus, "Options are not yet implemented");
12
- const { boxGraph, masterBusBox, masterAudioUnit, rootBox } = targetProject;
14
+ const { boxGraph, masterBusBox, rootBox } = targetProject;
13
15
  const dependencies = audioUnitBoxes
14
16
  .flatMap(box => Array.from(box.graph.dependenciesOf(box, { alwaysFollowMandatory: true }).boxes))
15
17
  .filter(box => box.name !== SelectionBox.ClassName && box.name !== AuxSendBox.ClassName);
16
- const uuidMap = generateUUIDMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
18
+ const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
17
19
  boxGraph.beginTransaction();
18
- PointerField.decodeWith({
19
- map: (_pointer, newAddress) => newAddress.map(address => uuidMap.opt(address.uuid).match({
20
- none: () => address,
21
- some: ({ target }) => address.moveTo(target)
22
- }))
23
- }, () => {
24
- audioUnitBoxes
25
- .toSorted((a, b) => a.index.getValue() - b.index.getValue())
26
- .forEach((source, index) => {
27
- const input = new ByteArrayInput(source.toArrayBuffer());
28
- const key = source.name;
29
- const uuid = uuidMap.get(source.address.uuid).target;
30
- const copy = boxGraph.createBox(key, uuid, box => box.read(input));
31
- copy.index.setValue(index);
32
- });
33
- masterAudioUnit.index.setValue(audioUnitBoxes.length);
34
- dependencies
35
- .forEach((source) => {
36
- const input = new ByteArrayInput(source.toArrayBuffer());
37
- const key = source.name;
38
- const uuid = uuidMap.get(source.address.uuid).target;
39
- boxGraph.createBox(key, uuid, box => box.read(input));
40
- });
41
- });
20
+ copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
21
+ reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
42
22
  boxGraph.endTransaction();
43
23
  boxGraph.verifyPointers();
44
- console.timeEnd("extractIntoNew");
45
24
  };
46
25
  ProjectUtils.extractRegions = (regionBoxes, targetProject, insertPosition = 0.0) => {
47
26
  assert(Arrays.satisfy(regionBoxes, isSameGraph), "Region smust be from the same BoxGraph");
48
- const compareIndex = (a, b) => a.index.getValue() - b.index.getValue();
49
27
  const regionBoxSet = new Set(regionBoxes);
50
28
  const trackBoxSet = new Set();
51
29
  const audioUnitBoxSet = new SetMultimap();
@@ -55,7 +33,6 @@ export var ProjectUtils;
55
33
  trackBoxSet.add(trackBox);
56
34
  const audioUnitBox = asInstanceOf(trackBox.tracks.targetVertex.unwrap().box, AudioUnitBox);
57
35
  audioUnitBoxSet.add(audioUnitBox, trackBox);
58
- console.debug(regionBox, trackBox);
59
36
  });
60
37
  console.debug(`Found ${audioUnitBoxSet.keyCount()} audioUnits`);
61
38
  console.debug(`Found ${trackBoxSet.size} tracks`);
@@ -66,32 +43,11 @@ export var ProjectUtils;
66
43
  const dependencies = audioUnitBoxes
67
44
  .flatMap(box => Array.from(box.graph.dependenciesOf(box, { excludeBox, alwaysFollowMandatory: true }).boxes))
68
45
  .filter(box => box.name !== SelectionBox.ClassName && box.name !== AuxSendBox.ClassName);
69
- const uuidMap = generateUUIDMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
46
+ const uuidMap = generateTransferMap(audioUnitBoxes, dependencies, rootBox.audioUnits.address.uuid, masterBusBox.address.uuid);
70
47
  boxGraph.beginTransaction();
71
- PointerField.decodeWith({
72
- map: (_pointer, newAddress) => newAddress.map(address => uuidMap.opt(address.uuid).match({
73
- none: () => address,
74
- some: ({ target }) => address.moveTo(target)
75
- }))
76
- }, () => {
77
- audioUnitBoxes
78
- .toSorted(compareIndex)
79
- .forEach((source, index) => {
80
- const input = new ByteArrayInput(source.toArrayBuffer());
81
- const key = source.name;
82
- const uuid = uuidMap.get(source.address.uuid).target;
83
- const copy = boxGraph.createBox(key, uuid, box => box.read(input));
84
- copy.index.setValue(index);
85
- });
86
- masterAudioUnit.index.setValue(audioUnitBoxes.length);
87
- dependencies
88
- .forEach((source) => {
89
- const input = new ByteArrayInput(source.toArrayBuffer());
90
- const key = source.name;
91
- const uuid = uuidMap.get(source.address.uuid).target;
92
- boxGraph.createBox(key, uuid, box => box.read(input));
93
- });
94
- });
48
+ copy(uuidMap, boxGraph, audioUnitBoxes, dependencies);
49
+ reorderAudioUnits(uuidMap, audioUnitBoxes, rootBox);
50
+ // reorder track indices
95
51
  audioUnitBoxSet.forEach((_, trackBoxes) => [...trackBoxes]
96
52
  .sort(compareIndex)
97
53
  .forEach((source, index) => {
@@ -100,6 +56,7 @@ export var ProjectUtils;
100
56
  .unwrap("Target Track has not been copied");
101
57
  asInstanceOf(box, TrackBox).index.setValue(index);
102
58
  }));
59
+ // move new regions to the target position
103
60
  const minPosition = regionBoxes.reduce((min, region) => Math.min(min, region.position.getValue()), Number.MAX_VALUE);
104
61
  const delta = insertPosition - minPosition;
105
62
  regionBoxes.forEach((source) => {
@@ -112,7 +69,7 @@ export var ProjectUtils;
112
69
  boxGraph.endTransaction();
113
70
  boxGraph.verifyPointers();
114
71
  };
115
- const generateUUIDMap = (audioUnitBoxes, dependencies, rootBoxUUID, masterBusBoxUUID) => {
72
+ const generateTransferMap = (audioUnitBoxes, dependencies, rootBoxUUID, masterBusBoxUUID) => {
116
73
  const uuidMap = UUID.newSet(({ source }) => source);
117
74
  uuidMap.addMany([
118
75
  ...audioUnitBoxes
@@ -141,4 +98,49 @@ export var ProjectUtils;
141
98
  ]);
142
99
  return uuidMap;
143
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
+ // That is a bit slow, but we are probably not dealing with too many audioUnits at this point.
129
+ const boxes = IndexedBox.collectIndexedBoxes(rootBox.audioUnits, AudioUnitBox);
130
+ const order = AudioUnitOrdering[box.type.getValue()];
131
+ let index = 0 | 0;
132
+ for (; index < boxes.length; index++) {
133
+ if (AudioUnitOrdering[boxes[index].type.getValue()] > order) {
134
+ break;
135
+ }
136
+ }
137
+ const insertIndex = index;
138
+ while (index < boxes.length) {
139
+ boxes[index].index.setValue(++index);
140
+ }
141
+ asInstanceOf(rootBox.graph
142
+ .findBox(uuidMap.get(box.address.uuid).target)
143
+ .unwrap("Target Track has not been copied"), AudioUnitBox).index.setValue(insertIndex);
144
+ });
145
+ };
144
146
  })(ProjectUtils || (ProjectUtils = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendaw/studio-core",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "license": "LGPL-3.0-or-later",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -26,16 +26,16 @@
26
26
  "test": "vitest run --config vitest.config.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@opendaw/lib-box": "^0.0.40",
30
- "@opendaw/lib-dawproject": "^0.0.26",
31
- "@opendaw/lib-dom": "^0.0.40",
32
- "@opendaw/lib-dsp": "^0.0.40",
33
- "@opendaw/lib-fusion": "^0.0.40",
34
- "@opendaw/lib-runtime": "^0.0.40",
35
- "@opendaw/lib-std": "^0.0.40",
36
- "@opendaw/studio-adapters": "^0.0.41",
37
- "@opendaw/studio-boxes": "^0.0.40",
38
- "@opendaw/studio-enums": "^0.0.31",
29
+ "@opendaw/lib-box": "^0.0.42",
30
+ "@opendaw/lib-dawproject": "^0.0.28",
31
+ "@opendaw/lib-dom": "^0.0.42",
32
+ "@opendaw/lib-dsp": "^0.0.42",
33
+ "@opendaw/lib-fusion": "^0.0.42",
34
+ "@opendaw/lib-runtime": "^0.0.42",
35
+ "@opendaw/lib-std": "^0.0.42",
36
+ "@opendaw/studio-adapters": "^0.0.43",
37
+ "@opendaw/studio-boxes": "^0.0.42",
38
+ "@opendaw/studio-enums": "^0.0.33",
39
39
  "dropbox": "^10.34.0",
40
40
  "y-websocket": "^1.4.5",
41
41
  "yjs": "^13.6.27",
@@ -49,10 +49,10 @@
49
49
  "@ffmpeg/ffmpeg": "^0.12.15",
50
50
  "@ffmpeg/util": "^0.12.2",
51
51
  "@opendaw/eslint-config": "^0.0.20",
52
- "@opendaw/studio-core-processors": "^0.0.41",
53
- "@opendaw/studio-core-workers": "^0.0.36",
54
- "@opendaw/studio-forge-boxes": "^0.0.40",
52
+ "@opendaw/studio-core-processors": "^0.0.43",
53
+ "@opendaw/studio-core-workers": "^0.0.38",
54
+ "@opendaw/studio-forge-boxes": "^0.0.42",
55
55
  "@opendaw/typescript-config": "^0.0.20"
56
56
  },
57
- "gitHead": "ee29837d620b53244f842b642abd2b1674b2745f"
57
+ "gitHead": "022a43f5265e17aca64985b7d3424e9849e75c08"
58
58
  }