@opendaw/studio-core 0.0.35 → 0.0.37

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,7 +1,7 @@
1
1
  import { Procedure, Terminable, TerminableOwner, Terminator } from "@opendaw/lib-std";
2
2
  import { BoxGraph, Editing } from "@opendaw/lib-box";
3
3
  import { AudioBusBox, AudioUnitBox, BoxIO, RootBox, TimelineBox, UserInterfaceBox } from "@opendaw/studio-boxes";
4
- import { BoxAdapters, BoxAdaptersContext, ClipSequencing, ParameterFieldAdapters, ProjectDecoder, RootBoxAdapter, SampleManager, TimelineBoxAdapter, UserEditingManager, VertexSelection } from "@opendaw/studio-adapters";
4
+ import { BoxAdapters, BoxAdaptersContext, ClipSequencing, ParameterFieldAdapters, ProcessorOptions, ProjectDecoder, RootBoxAdapter, SampleManager, TimelineBoxAdapter, UserEditingManager, VertexSelection } from "@opendaw/studio-adapters";
5
5
  import { LiveStreamBroadcaster, LiveStreamReceiver } from "@opendaw/lib-fusion";
6
6
  import { ProjectEnv } from "./ProjectEnv";
7
7
  import { Mixer } from "../Mixer";
@@ -37,7 +37,7 @@ export declare class Project implements BoxAdaptersContext, Terminable, Terminab
37
37
  readonly mixer: Mixer;
38
38
  readonly engine: EngineFacade;
39
39
  private constructor();
40
- startAudioWorklet(restart?: RestartWorklet): EngineWorklet;
40
+ startAudioWorklet(restart?: RestartWorklet, options?: ProcessorOptions): EngineWorklet;
41
41
  startRecording(countIn?: boolean): void;
42
42
  own<T extends Terminable>(terminable: T): T;
43
43
  ownAll<T extends Terminable>(...terminables: Array<T>): void;
@@ -54,6 +54,7 @@ export declare class Project implements BoxAdaptersContext, Terminable, Terminab
54
54
  get skeleton(): ProjectDecoder.Skeleton;
55
55
  toArrayBuffer(): ArrayBufferLike;
56
56
  copy(): Project;
57
+ invalid(): boolean;
57
58
  terminate(): void;
58
59
  }
59
60
  //# sourceMappingURL=Project.d.ts.map
@@ -1 +1 @@
1
- {"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A;IACvD,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAA;IAC/C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAA;IACrB,QAAQ,CAAC,MAAM,eAAqB;IAEpC,OAAO;IA+BP,iBAAiB,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,aAAa;IAoBtF,cAAc,CAAC,OAAO,GAAE,OAAc,GAAG,IAAI;IAM7C,GAAG,CAAC,CAAC,SAAS,UAAU,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC;IAC3C,MAAM,CAAC,CAAC,SAAS,UAAU,EAAE,GAAG,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,IAAI;IAC5D,KAAK,IAAI,UAAU;IAEnB,IAAI,GAAG,IAAI,UAAU,CAAmB;IACxC,IAAI,GAAG,IAAI,MAAM,CAAyC;IAC1D,IAAI,cAAc,IAAI,cAAc,CAAmE;IACvG,IAAI,kBAAkB,IAAI,kBAAkB,CAA2E;IACvH,IAAI,aAAa,IAAI,aAAa,CAAiC;IACnE,IAAI,cAAc,IAAI,cAAc,CAAkD;IACtF,IAAI,cAAc,IAAI,OAAO,CAAe;IAC5C,IAAI,YAAY,IAAI,OAAO,CAAc;IACzC,IAAI,qBAAqB,IAAI,qBAAqB,CAAkD;IAEpG,IAAI,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAWtC;IAED,aAAa,IAAI,eAAe;IAiBhC,IAAI,IAAI,OAAO;IAEf,OAAO,IAAI,OAAO;IAelB,SAAS,IAAI,IAAI;CAIpB"}
@@ -1,7 +1,7 @@
1
- import { ByteArrayOutput, Option, panic, safeExecute, Terminator, UUID } from "@opendaw/lib-std";
1
+ import { Arrays, ByteArrayOutput, Option, panic, safeExecute, Terminator, UUID } from "@opendaw/lib-std";
2
2
  import { BoxGraph, Editing } from "@opendaw/lib-box";
3
3
  import { AudioBusBox, AudioUnitBox, BoxIO, GrooveShuffleBox, RootBox, TimelineBox, UserInterfaceBox } from "@opendaw/studio-boxes";
4
- import { BoxAdapters, IconSymbol, ParameterFieldAdapters, ProjectDecoder, RootBoxAdapter, TimelineBoxAdapter, UserEditingManager, VertexSelection } from "@opendaw/studio-adapters";
4
+ import { BoxAdapters, IconSymbol, ParameterFieldAdapters, ProjectDecoder, RootBoxAdapter, TimelineBoxAdapter, UnionBoxTypes, UserEditingManager, VertexSelection } from "@opendaw/studio-adapters";
5
5
  import { LiveStreamReceiver } from "@opendaw/lib-fusion";
6
6
  import { AudioUnitType } from "@opendaw/studio-enums";
7
7
  import { Mixer } from "../Mixer";
@@ -101,10 +101,10 @@ export class Project {
101
101
  this.mixer = new Mixer(this.rootBoxAdapter.audioUnits);
102
102
  console.debug(`Project was created on ${this.rootBoxAdapter.created.toString()}`);
103
103
  }
104
- startAudioWorklet(restart) {
104
+ startAudioWorklet(restart, options) {
105
105
  console.debug(`start AudioWorklet`);
106
106
  const lifecycle = this.#terminator.spawn();
107
- const engine = lifecycle.own(this.#env.audioWorklets.createEngine(this));
107
+ const engine = lifecycle.own(this.#env.audioWorklets.createEngine({ project: this, options }));
108
108
  const handler = async (event) => {
109
109
  console.warn(event);
110
110
  // we will only accept the first error
@@ -168,6 +168,20 @@ export class Project {
168
168
  return output.toArrayBuffer();
169
169
  }
170
170
  copy() { return Project.load(this.#env, this.toArrayBuffer()); }
171
+ invalid() {
172
+ return this.boxGraph.boxes().some(box => box.accept({
173
+ visitTrackBox: (box) => {
174
+ for (const { current, next } of Arrays.iterateAdjacent(box.regions.pointerHub.incoming()
175
+ .map(({ box }) => UnionBoxTypes.asRegionBox(box))
176
+ .sort(({ position: a }, { position: b }) => a.getValue() - b.getValue()))) {
177
+ if (current.position.getValue() + current.duration.getValue() > next.position.getValue()) {
178
+ return true;
179
+ }
180
+ }
181
+ return false;
182
+ }
183
+ }) ?? false);
184
+ }
171
185
  terminate() {
172
186
  console.debug("Project terminated");
173
187
  this.#terminator.terminate();
@@ -0,0 +1,49 @@
1
+ import { Observer, RangeOptions, Subscription, Terminable, unitValue, ValueAxis } from "@opendaw/lib-std";
2
+ export declare class TimelineRange implements Terminable {
3
+ #private;
4
+ constructor(options?: RangeOptions);
5
+ subscribe(observer: Observer<TimelineRange>): Subscription;
6
+ get minUnits(): number;
7
+ set minUnits(_: number);
8
+ get maxUnits(): number;
9
+ set maxUnits(value: number);
10
+ get width(): number;
11
+ set width(value: number);
12
+ get minimum(): number;
13
+ set minimum(value: number);
14
+ get unitMin(): number;
15
+ set unitMin(value: number);
16
+ get unitMax(): number;
17
+ set unitMax(value: number);
18
+ get unitsPerPixel(): number;
19
+ get unitRange(): number;
20
+ get valueAxis(): ValueAxis;
21
+ normalize(value: number): unitValue;
22
+ denormalize(value: number): unitValue;
23
+ unitToX(unit: number): number;
24
+ xToUnit(x: number): number;
25
+ moveToUnit(value: number): void;
26
+ unitOverlaps(min: number, max: number): boolean;
27
+ showUnitInterval(min: number, max: number): void;
28
+ showAll(): void;
29
+ zoomRange(min: number, max: number, padding?: number): void;
30
+ moveUnitTo(value: number): void;
31
+ moveUnitBy(delta: number): void;
32
+ scaleUnitBy(scale: number, position: unitValue): void;
33
+ get unitPadding(): number;
34
+ get min(): unitValue;
35
+ set min(value: unitValue);
36
+ get max(): unitValue;
37
+ set max(value: unitValue);
38
+ get center(): unitValue;
39
+ set center(value: unitValue);
40
+ get length(): unitValue;
41
+ moveTo(value: unitValue): void;
42
+ moveBy(delta: unitValue): void;
43
+ scaleBy(scale: number, position: unitValue): void;
44
+ xToValue(x: number): unitValue;
45
+ valueToX(value: unitValue): number;
46
+ overlaps(start: number, complete: number): boolean;
47
+ terminate(): void;
48
+ }
49
+ //# sourceMappingURL=TimelineRange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimelineRange.d.ts","sourceRoot":"","sources":["../../src/ui/TimelineRange.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,QAAQ,EAGR,YA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AAG,IAAI;IAChD,OAAO,IAAI,IAAI;IACf,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,MAAW,GAAG,IAAI;IAa/D,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC/B,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAC/B,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI;IACrD,IAAI,WAAW,IAAI,MAAM,CAAkD;IAC3E,IAAI,GAAG,IAAI,SAAS,CAAyB;IAC7C,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,EAA2B;IACnD,IAAI,GAAG,IAAI,SAAS,CAAyB;IAC7C,IAAI,GAAG,CAAC,KAAK,EAAE,SAAS,EAA2B;IACnD,IAAI,MAAM,IAAI,SAAS,CAA4B;IACnD,IAAI,MAAM,CAAC,KAAK,EAAE,SAAS,EAA8B;IACzD,IAAI,MAAM,IAAI,SAAS,CAA4B;IACnD,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAC9B,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI;IAC9B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI;IACjD,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM;IAClC,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO;IAElD,SAAS,IAAI,IAAI;CACpB"}
@@ -0,0 +1,83 @@
1
+ import { Notifier, panic, Range, Terminator } from "@opendaw/lib-std";
2
+ export class TimelineRange {
3
+ #terminator;
4
+ #range;
5
+ #notifier;
6
+ #valueAxis;
7
+ #maxUnits = 1.0;
8
+ #minimum = 1.0;
9
+ constructor(options) {
10
+ this.#terminator = new Terminator();
11
+ this.#range = this.#terminator.own(new Range(options));
12
+ this.#notifier = this.#terminator.own(new Notifier());
13
+ this.#valueAxis = {
14
+ valueToAxis: (value) => this.unitToX(Math.max(0, value)),
15
+ axisToValue: (x) => Math.max(0, this.xToUnit(x))
16
+ };
17
+ this.#terminator.own(this.#range.subscribe(() => this.#notifier.notify(this)));
18
+ }
19
+ subscribe(observer) { return this.#notifier.subscribe(observer); }
20
+ get minUnits() { return 0; }
21
+ set minUnits(_) {
22
+ panic("minUnits not implemented");
23
+ }
24
+ get maxUnits() { return this.#maxUnits; }
25
+ set maxUnits(value) {
26
+ if (this.#maxUnits === value) {
27
+ return;
28
+ }
29
+ this.#maxUnits = value;
30
+ this.#range.minimum = this.normalize(this.#minimum);
31
+ }
32
+ get width() { return this.#range.width; }
33
+ set width(value) { this.#range.width = value; }
34
+ // minimum interval
35
+ get minimum() { return this.#minimum; }
36
+ set minimum(value) { this.#minimum = value; }
37
+ get unitMin() { return this.denormalize(this.#range.min); }
38
+ set unitMin(value) { this.#range.min = this.normalize(value); }
39
+ get unitMax() { return this.denormalize(this.#range.max); }
40
+ set unitMax(value) { this.#range.max = this.normalize(value); }
41
+ get unitsPerPixel() { return this.denormalize(this.#range.valuesPerPixel); }
42
+ get unitRange() { return this.unitMax - this.unitMin; }
43
+ get valueAxis() { return this.#valueAxis; }
44
+ normalize(value) { return value / this.maxUnits; }
45
+ denormalize(value) { return value * this.maxUnits; }
46
+ unitToX(unit) { return this.valueToX(this.normalize(unit)); }
47
+ xToUnit(x) { return this.denormalize(this.xToValue(x)); }
48
+ moveToUnit(value) { this.#range.moveTo(this.normalize(value)); }
49
+ unitOverlaps(min, max) { return this.#range.overlaps(this.normalize(min), this.normalize(max)); }
50
+ showUnitInterval(min, max) { this.#range.set(this.normalize(min), this.normalize(max)); }
51
+ showAll() { this.#range.set(0.0, 1.0); }
52
+ zoomRange(min, max, padding = 32) {
53
+ const innerWidth = this.#range.innerWidth;
54
+ const unitsPerPixel = (max - min) / (innerWidth - padding * 2.0);
55
+ const center = ((min + max) / 2.0) / this.#maxUnits;
56
+ const range = Math.max(this.#range.minimum, (unitsPerPixel * innerWidth) / this.#maxUnits * 0.5);
57
+ let a = center - range;
58
+ let b = center + range;
59
+ if (a < 0.0) {
60
+ b -= a;
61
+ a = 0.0;
62
+ }
63
+ this.#range.set(a, b);
64
+ }
65
+ moveUnitTo(value) { this.#range.moveTo(this.normalize(value)); }
66
+ moveUnitBy(delta) { this.#range.moveBy(this.normalize(delta)); }
67
+ scaleUnitBy(scale, position) { this.#range.scaleBy(scale, this.normalize(position)); }
68
+ get unitPadding() { return this.#range.padding * this.unitsPerPixel; }
69
+ get min() { return this.#range.min; }
70
+ set min(value) { this.#range.min = value; }
71
+ get max() { return this.#range.max; }
72
+ set max(value) { this.#range.max = value; }
73
+ get center() { return this.#range.center; }
74
+ set center(value) { this.#range.center = value; }
75
+ get length() { return this.#range.length; }
76
+ moveTo(value) { this.#range.moveTo(value); }
77
+ moveBy(delta) { this.#range.moveBy(delta); }
78
+ scaleBy(scale, position) { this.#range.scaleBy(scale, position); }
79
+ xToValue(x) { return this.#range.xToValue(x); }
80
+ valueToX(value) { return this.#range.valueToX(value); }
81
+ overlaps(start, complete) { return this.#range.overlaps(start, complete); }
82
+ terminate() { this.#terminator.terminate(); }
83
+ }