@opendaw/studio-core 0.0.13 → 0.0.14

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.
@@ -0,0 +1,3 @@
1
+ import { ArpeggioDeviceBox, DelayDeviceBox, ModularDeviceBox, PitchDeviceBox, RevampDeviceBox, ReverbDeviceBox, StereoToolDeviceBox, ZeitgeistDeviceBox } from "@opendaw/studio-boxes";
2
+ export type EffectBox = ArpeggioDeviceBox | PitchDeviceBox | ZeitgeistDeviceBox | DelayDeviceBox | ReverbDeviceBox | RevampDeviceBox | StereoToolDeviceBox | ModularDeviceBox;
3
+ //# sourceMappingURL=EffectBox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectBox.d.ts","sourceRoot":"","sources":["../src/EffectBox.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EACrB,MAAM,uBAAuB,CAAA;AAE9B,MAAM,MAAM,SAAS,GACf,iBAAiB,GAAG,cAAc,GAAG,kBAAkB,GACvD,cAAc,GAAG,eAAe,GAAG,eAAe,GAAG,mBAAmB,GAAG,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { EffectFactory } from "./EffectFactory";
2
- export declare namespace Effects {
2
+ export declare namespace EffectFactories {
3
3
  const Arpeggio: EffectFactory;
4
4
  const Pitch: EffectFactory;
5
5
  const Zeitgeist: EffectFactory;
@@ -1 +1 @@
1
- {"version":3,"file":"EffectFactories.d.ts","sourceRoot":"","sources":["../src/EffectFactories.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,yBAAiB,OAAO,CAAC;IACd,MAAM,QAAQ,EAAE,aAWtB,CAAA;IAEM,MAAM,KAAK,EAAE,aAWnB,CAAA;IAEM,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AAC,QAAQ,CAAC,aAAa,CAAC,CAA6B,CAAA;IACnF,MAAM,WAAW;;;;;;;;;KAAgC,CAAA;IACxD,KAAY,cAAc,GAAG,MAAM,OAAO,SAAS,CAAA;IACnD,KAAY,eAAe,GAAG,MAAM,OAAO,UAAU,CAAA;CACxD"}
@@ -1,9 +1,9 @@
1
1
  import { INVERSE_SQRT_2, UUID } from "@opendaw/lib-std";
2
2
  import { ArpeggioDeviceBox, DelayDeviceBox, GrooveShuffleBox, ModularAudioInputBox, ModularAudioOutputBox, ModularBox, ModularDeviceBox, ModuleConnectionBox, PitchDeviceBox, RevampDeviceBox, ReverbDeviceBox, StereoToolDeviceBox, ZeitgeistDeviceBox } from "@opendaw/studio-boxes";
3
3
  import { IconSymbol } from "@opendaw/studio-adapters";
4
- export var Effects;
5
- (function (Effects) {
6
- Effects.Arpeggio = {
4
+ export var EffectFactories;
5
+ (function (EffectFactories) {
6
+ EffectFactories.Arpeggio = {
7
7
  defaultName: "Arpeggio",
8
8
  defaultIcon: IconSymbol.Stack,
9
9
  description: "Generates rhythmic note sequences from chords",
@@ -15,7 +15,7 @@ export var Effects;
15
15
  box.host.refer(unit);
16
16
  })
17
17
  };
18
- Effects.Pitch = {
18
+ EffectFactories.Pitch = {
19
19
  defaultName: "Pitch",
20
20
  defaultIcon: IconSymbol.Note,
21
21
  description: "Shifts the pitch of incoming notes",
@@ -27,7 +27,7 @@ export var Effects;
27
27
  box.host.refer(unit);
28
28
  })
29
29
  };
30
- Effects.Zeitgeist = {
30
+ EffectFactories.Zeitgeist = {
31
31
  defaultName: "Zeitgeist",
32
32
  defaultIcon: IconSymbol.Zeitgeist,
33
33
  description: "Distorts space and time",
@@ -49,7 +49,7 @@ export var Effects;
49
49
  });
50
50
  }
51
51
  };
52
- Effects.StereoTool = {
52
+ EffectFactories.StereoTool = {
53
53
  defaultName: "Stereo Tool",
54
54
  defaultIcon: IconSymbol.Stereo,
55
55
  description: "Computes a stereo transformation matrix with volume, panning, phase inversion and stereo width.",
@@ -61,7 +61,7 @@ export var Effects;
61
61
  box.host.refer(unit);
62
62
  })
63
63
  };
64
- Effects.Delay = {
64
+ EffectFactories.Delay = {
65
65
  defaultName: "Delay",
66
66
  defaultIcon: IconSymbol.Time,
67
67
  description: "Echoes the input signal with time-based repeats",
@@ -73,7 +73,7 @@ export var Effects;
73
73
  box.host.refer(unit);
74
74
  })
75
75
  };
76
- Effects.Reverb = {
76
+ EffectFactories.Reverb = {
77
77
  defaultName: "Reverb",
78
78
  defaultIcon: IconSymbol.Cube,
79
79
  description: "Simulates space and depth with reflections",
@@ -86,7 +86,7 @@ export var Effects;
86
86
  box.host.refer(unit);
87
87
  })
88
88
  };
89
- Effects.Revamp = {
89
+ EffectFactories.Revamp = {
90
90
  defaultName: "Revamp",
91
91
  defaultIcon: IconSymbol.EQ,
92
92
  description: "Shapes the frequency balance of the sound",
@@ -118,7 +118,7 @@ export var Effects;
118
118
  box.host.refer(unit);
119
119
  })
120
120
  };
121
- Effects.Modular = {
121
+ EffectFactories.Modular = {
122
122
  defaultName: "🔇 Create New Modular Audio Effect (inaudible yet)",
123
123
  defaultIcon: IconSymbol.Box,
124
124
  description: "",
@@ -155,9 +155,9 @@ export var Effects;
155
155
  });
156
156
  }
157
157
  };
158
- Effects.MidiNamed = { Arpeggio: Effects.Arpeggio, Pitch: Effects.Pitch, Zeitgeist: Effects.Zeitgeist };
159
- Effects.AudioNamed = { StereoTool: Effects.StereoTool, Delay: Effects.Delay, Reverb: Effects.Reverb, Revamp: Effects.Revamp, Modular: Effects.Modular };
160
- Effects.MidiList = Object.values(Effects.MidiNamed);
161
- Effects.AudioList = Object.values(Effects.AudioNamed);
162
- Effects.MergedNamed = { ...Effects.MidiNamed, ...Effects.AudioNamed };
163
- })(Effects || (Effects = {}));
158
+ EffectFactories.MidiNamed = { Arpeggio: EffectFactories.Arpeggio, Pitch: EffectFactories.Pitch, Zeitgeist: EffectFactories.Zeitgeist };
159
+ EffectFactories.AudioNamed = { StereoTool: EffectFactories.StereoTool, Delay: EffectFactories.Delay, Reverb: EffectFactories.Reverb, Revamp: EffectFactories.Revamp, Modular: EffectFactories.Modular };
160
+ EffectFactories.MidiList = Object.values(EffectFactories.MidiNamed);
161
+ EffectFactories.AudioList = Object.values(EffectFactories.AudioNamed);
162
+ EffectFactories.MergedNamed = { ...EffectFactories.MidiNamed, ...EffectFactories.AudioNamed };
163
+ })(EffectFactories || (EffectFactories = {}));
@@ -1,13 +1,14 @@
1
1
  import { EffectPointerType, IconSymbol } from "@opendaw/studio-adapters";
2
- import { Box, Field } from "@opendaw/lib-box";
2
+ import { Field } from "@opendaw/lib-box";
3
3
  import { int } from "@opendaw/lib-std";
4
4
  import { Project } from "./Project";
5
+ import { EffectBox } from "./EffectBox";
5
6
  export interface EffectFactory {
6
7
  get defaultName(): string;
7
8
  get defaultIcon(): IconSymbol;
8
9
  get description(): string;
9
10
  get separatorBefore(): boolean;
10
11
  get type(): "audio" | "midi";
11
- create(project: Project, unit: Field<EffectPointerType>, index: int): Box;
12
+ create(project: Project, unit: Field<EffectPointerType>, index: int): EffectBox;
12
13
  }
13
14
  //# sourceMappingURL=EffectFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"EffectFactory.d.ts","sourceRoot":"","sources":["../src/EffectFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAC,GAAG,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAEjC,MAAM,WAAW,aAAa;IAC1B,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,WAAW,IAAI,UAAU,CAAA;IAC7B,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,eAAe,IAAI,OAAO,CAAA;IAC9B,IAAI,IAAI,IAAI,OAAO,GAAG,MAAM,CAAA;IAE5B,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,GAAG,CAAA;CAC5E"}
1
+ {"version":3,"file":"EffectFactory.d.ts","sourceRoot":"","sources":["../src/EffectFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAE,UAAU,EAAC,MAAM,0BAA0B,CAAA;AACtE,OAAO,EAAC,KAAK,EAAC,MAAM,kBAAkB,CAAA;AACtC,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AACpC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAA;AAErC,MAAM,WAAW,aAAa;IAC1B,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,WAAW,IAAI,UAAU,CAAA;IAC7B,IAAI,WAAW,IAAI,MAAM,CAAA;IACzB,IAAI,eAAe,IAAI,OAAO,CAAA;IAC9B,IAAI,IAAI,IAAI,OAAO,GAAG,MAAM,CAAA;IAE5B,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,iBAAiB,CAAC,EAAE,KAAK,EAAE,GAAG,GAAG,SAAS,CAAA;CAClF"}
@@ -1 +1 @@
1
- {"version":3,"file":"InstrumentFactories.d.ts","sourceRoot":"","sources":["../src/InstrumentFactories.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AAErD,yBAAiB,mBAAmB,CAAC;IAC1B,MAAM,IAAI,EAAE,iBAelB,CAAA;IAEM,MAAM,IAAI,EAAE,iBAkBlB,CAAA;IAEM,MAAM,SAAS,EAAE,iBAiCvB,CAAA;IAEM,MAAM,YAAY,EAAE,iBAiB1B,CAAA;IAEM,MAAM,KAAK;;;;;KAAwC,CAAA;IAC1D,KAAY,IAAI,GAAG,MAAM,OAAO,KAAK,CAAA;CAMxC"}
1
+ {"version":3,"file":"InstrumentFactories.d.ts","sourceRoot":"","sources":["../src/InstrumentFactories.ts"],"names":[],"mappings":"AAaA,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AAGrD,yBAAiB,mBAAmB,CAAC;IAC1B,MAAM,IAAI,EAAE,iBAelB,CAAA;IAEM,MAAM,IAAI,EAAE,iBAkBlB,CAAA;IAEM,MAAM,SAAS,EAAE,iBAiCvB,CAAA;IAEM,MAAM,YAAY,EAAE,iBAiB1B,CAAA;IAEM,MAAM,KAAK;;;;;KAAwC,CAAA;IAC1D,KAAY,IAAI,GAAG,MAAM,OAAO,KAAK,CAAA;CAMxC"}
@@ -9,14 +9,14 @@ export var InstrumentFactories;
9
9
  defaultIcon: IconSymbol.Tape,
10
10
  description: "Plays audio regions & clips",
11
11
  trackType: TrackType.Audio,
12
- create: (boxGraph, deviceHost, name, icon) => TapeDeviceBox.create(boxGraph, UUID.generate(), box => {
12
+ create: (boxGraph, host, name, icon) => TapeDeviceBox.create(boxGraph, UUID.generate(), box => {
13
13
  box.label.setValue(name);
14
14
  box.icon.setValue(IconSymbol.toName(icon));
15
15
  box.flutter.setValue(0.2);
16
16
  box.wow.setValue(0.05);
17
17
  box.noise.setValue(0.02);
18
18
  box.saturation.setValue(0.5);
19
- box.host.refer(deviceHost.inputField);
19
+ box.host.refer(host);
20
20
  })
21
21
  };
22
22
  InstrumentFactories.Nano = {
@@ -24,7 +24,7 @@ export var InstrumentFactories;
24
24
  defaultIcon: IconSymbol.NanoWave,
25
25
  description: "Simple sampler",
26
26
  trackType: TrackType.Notes,
27
- create: (boxGraph, deviceHost, name, icon) => {
27
+ create: (boxGraph, host, name, icon) => {
28
28
  const fileUUID = UUID.parse("c1678daa-4a47-4cba-b88f-4f4e384663c3");
29
29
  const audioFileBox = boxGraph.findBox(fileUUID)
30
30
  .unwrapOrElse(() => AudioFileBox.create(boxGraph, fileUUID, box => {
@@ -34,7 +34,7 @@ export var InstrumentFactories;
34
34
  box.label.setValue(name);
35
35
  box.icon.setValue(IconSymbol.toName(icon));
36
36
  box.file.refer(audioFileBox);
37
- box.host.refer(deviceHost.inputField);
37
+ box.host.refer(host);
38
38
  });
39
39
  }
40
40
  };
@@ -43,11 +43,11 @@ export var InstrumentFactories;
43
43
  defaultIcon: IconSymbol.Playfield,
44
44
  description: "Drum computer",
45
45
  trackType: TrackType.Notes,
46
- create: (boxGraph, deviceHost, name, icon) => {
46
+ create: (boxGraph, host, name, icon) => {
47
47
  const deviceBox = PlayfieldDeviceBox.create(boxGraph, UUID.generate(), box => {
48
48
  box.label.setValue(name);
49
49
  box.icon.setValue(IconSymbol.toName(icon));
50
- box.host.refer(deviceHost.inputField);
50
+ box.host.refer(host);
51
51
  });
52
52
  const files = [
53
53
  useFile(boxGraph, UUID.parse("8bb2c6e8-9a6d-4d32-b7ec-1263594ef367"), "909 Bassdrum"),
@@ -77,7 +77,7 @@ export var InstrumentFactories;
77
77
  defaultIcon: IconSymbol.Piano,
78
78
  description: "Classic subtractive synthesizer",
79
79
  trackType: TrackType.Notes,
80
- create: (boxGraph, deviceHost, name, icon) => VaporisateurDeviceBox.create(boxGraph, UUID.generate(), box => {
80
+ create: (boxGraph, host, name, icon) => VaporisateurDeviceBox.create(boxGraph, UUID.generate(), box => {
81
81
  box.label.setValue(name);
82
82
  box.icon.setValue(IconSymbol.toName(icon));
83
83
  box.tune.setInitValue(0.0);
@@ -86,7 +86,7 @@ export var InstrumentFactories;
86
86
  box.attack.setInitValue(0.005);
87
87
  box.release.setInitValue(0.1);
88
88
  box.waveform.setInitValue(Waveform.sine);
89
- box.host.refer(deviceHost.inputField);
89
+ box.host.refer(host);
90
90
  })
91
91
  };
92
92
  InstrumentFactories.Named = { Vaporisateur: InstrumentFactories.Vaporisateur, Playfield: InstrumentFactories.Playfield, Nano: InstrumentFactories.Nano, Tape: InstrumentFactories.Tape };
@@ -1,11 +1,12 @@
1
- import { DeviceHost, IconSymbol, TrackType } from "@opendaw/studio-adapters";
2
- import { BoxGraph } from "@opendaw/lib-box";
1
+ import { IconSymbol, TrackType } from "@opendaw/studio-adapters";
2
+ import { BoxGraph, Field } from "@opendaw/lib-box";
3
3
  import { InstrumentBox } from "./InstrumentBox";
4
+ import { Pointers } from "@opendaw/studio-enums";
4
5
  export interface InstrumentFactory {
5
6
  defaultName: string;
6
7
  defaultIcon: IconSymbol;
7
8
  description: string;
8
9
  trackType: TrackType;
9
- create: (boxGraph: BoxGraph, deviceHost: DeviceHost, name: string, icon: IconSymbol) => InstrumentBox;
10
+ create: (boxGraph: BoxGraph, host: Field<Pointers.InstrumentHost | Pointers.AudioOutput>, name: string, icon: IconSymbol) => InstrumentBox;
10
11
  }
11
12
  //# sourceMappingURL=InstrumentFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"InstrumentFactory.d.ts","sourceRoot":"","sources":["../src/InstrumentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,UAAU,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAC,QAAQ,EAAC,MAAM,kBAAkB,CAAA;AAEzC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,KAAK,aAAa,CAAA;CACxG"}
1
+ {"version":3,"file":"InstrumentFactory.d.ts","sourceRoot":"","sources":["../src/InstrumentFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAC,QAAQ,EAAE,KAAK,EAAC,MAAM,kBAAkB,CAAA;AAEhD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE9C,MAAM,WAAW,iBAAiB;IAC9B,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,UAAU,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,KAAK,CAAC,QAAQ,CAAC,cAAc,GAAG,QAAQ,CAAC,WAAW,CAAC,EAC3D,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,UAAU,KAAK,aAAa,CAAA;CAC9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"InstrumentProduct.d.ts","sourceRoot":"","sources":["../src/InstrumentProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAE5D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,QAAQ,CAAA;CACrB,CAAA"}
1
+ {"version":3,"file":"InstrumentProduct.d.ts","sourceRoot":"","sources":["../src/InstrumentProduct.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAE,QAAQ,EAAC,MAAM,uBAAuB,CAAA;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,aAAa,EAAE,aAAa,CAAA;IAC5B,QAAQ,EAAE,QAAQ,CAAA;CACrB,CAAA"}
@@ -1,14 +1,15 @@
1
- import { float, int, Option } from "@opendaw/lib-std";
2
- import { PointerField } from "@opendaw/lib-box";
1
+ import { float, int, Observer, Option, Subscription } from "@opendaw/lib-std";
2
+ import { ppqn } from "@opendaw/lib-dsp";
3
+ import { Field, PointerField } from "@opendaw/lib-box";
3
4
  import { AudioUnitType, Pointers } from "@opendaw/studio-enums";
4
- import { AudioBusBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
5
- import { AnyClipBox, AudioUnitBoxAdapter, DeviceHost, IconSymbol } from "@opendaw/studio-adapters";
5
+ import { AudioBusBox, AudioUnitBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
6
+ import { AnyClipBox, AudioUnitBoxAdapter, EffectPointerType, IconSymbol, IndexedAdapterCollectionListener } from "@opendaw/studio-adapters";
6
7
  import { Project } from "./Project";
7
8
  import { InstrumentFactory } from "./InstrumentFactory";
8
9
  import { InstrumentProduct } from "./InstrumentProduct";
9
10
  import { InstrumentOptions } from "./InstrumentOptions";
10
11
  import { EffectFactory } from "./EffectFactory";
11
- import { ppqn } from "@opendaw/lib-dsp";
12
+ import { EffectBox } from "./EffectBox";
12
13
  export type ClipRegionOptions = {
13
14
  name?: string;
14
15
  hue?: number;
@@ -38,23 +39,21 @@ export type NoteRegionParams = {
38
39
  };
39
40
  export declare class ProjectApi {
40
41
  #private;
41
- static readonly AudioUnitOrdering: {
42
- readonly instrument: 0;
43
- readonly aux: 1;
44
- readonly bus: 2;
45
- readonly output: 3;
46
- };
42
+ static readonly AudioUnitOrdering: Record<string, int>;
47
43
  constructor(project: Project);
44
+ setBpm(value: number): void;
45
+ catchupAndSubscribeBpm(observer: Observer<number>): Subscription;
46
+ catchupAndSubscribeAudioUnits(listener: IndexedAdapterCollectionListener<AudioUnitBoxAdapter>): Subscription;
48
47
  createInstrument({ create, defaultIcon, defaultName, trackType }: InstrumentFactory, { name, icon, index }?: InstrumentOptions): InstrumentProduct;
49
- createEffect(host: DeviceHost, factory: EffectFactory, newIndex: int): import("@opendaw/lib-box").Box<import("@opendaw/lib-box").PointerTypes, any>;
50
48
  createAudioBus(name: string, icon: IconSymbol, type: AudioUnitType, color: string): AudioBusBox;
51
- createNoteTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
52
- createAudioTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
53
- createAutomationTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
49
+ insertEffect(field: Field<EffectPointerType>, factory: EffectFactory, insertIndex?: int): EffectBox;
50
+ createNoteTrack(audioUnitBox: AudioUnitBox, insertIndex?: int): TrackBox;
51
+ createAudioTrack(audioUnitBox: AudioUnitBox, insertIndex?: int): TrackBox;
52
+ createAutomationTrack(audioUnitBox: AudioUnitBox, target: Field<Pointers.Automation>, insertIndex?: int): TrackBox;
54
53
  createClip(trackBox: TrackBox, clipIndex: int, { name, hue }?: ClipRegionOptions): Option<AnyClipBox>;
55
54
  createNoteRegion({ trackBox, position, duration, loopOffset, loopDuration, eventOffset, eventCollection, mute, name, hue }: NoteRegionParams): NoteRegionBox;
56
55
  createTrackRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
57
56
  createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBox;
58
- deleteAudioUnit(adapter: AudioUnitBoxAdapter): void;
57
+ deleteAudioUnit(audioUnitBox: AudioUnitBox): void;
59
58
  }
60
59
  //# sourceMappingURL=ProjectApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProjectApi.d.ts","sourceRoot":"","sources":["../src/ProjectApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,GAAG,EAAE,MAAM,EAAuB,MAAM,kBAAkB,CAAA;AACjF,OAAO,EAAQ,YAAY,EAAC,MAAM,kBAAkB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IAe1G,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;CAgDpD"}
@@ -1,9 +1,11 @@
1
- import { assert, Option, panic, Strings, UUID } from "@opendaw/lib-std";
1
+ import { asDefined, asInstanceOf, assert, clamp, Option, Strings, UUID } from "@opendaw/lib-std";
2
+ import { PPQN } from "@opendaw/lib-dsp";
3
+ import { IndexedBox, StringField } from "@opendaw/lib-box";
2
4
  import { AudioUnitType } from "@opendaw/studio-enums";
3
5
  import { AudioBusBox, AudioUnitBox, NoteClipBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueClipBox, ValueEventCollectionBox, ValueRegionBox } from "@opendaw/studio-boxes";
4
- import { AudioUnitBoxAdapter, IconSymbol, TrackType } from "@opendaw/studio-adapters";
6
+ import { IconSymbol, TrackType } from "@opendaw/studio-adapters";
5
7
  import { ColorCodes } from "./ColorCodes";
6
- import { PPQN } from "@opendaw/lib-dsp";
8
+ // noinspection JSUnusedGlobalSymbols
7
9
  export class ProjectApi {
8
10
  static AudioUnitOrdering = {
9
11
  [AudioUnitType.Instrument]: 0,
@@ -13,51 +15,42 @@ export class ProjectApi {
13
15
  };
14
16
  #project;
15
17
  constructor(project) { this.#project = project; }
18
+ setBpm(value) {
19
+ if (isNaN(value)) {
20
+ return;
21
+ }
22
+ this.#project.timelineBoxAdapter.box.bpm.setValue(clamp(value, 30, 1000));
23
+ }
24
+ catchupAndSubscribeBpm(observer) {
25
+ return this.#project.timelineBoxAdapter.box.bpm.catchupAndSubscribe(owner => observer(owner.getValue()));
26
+ }
27
+ catchupAndSubscribeAudioUnits(listener) {
28
+ return this.#project.rootBoxAdapter.audioUnits.catchupAndSubscribe(listener);
29
+ }
16
30
  createInstrument({ create, defaultIcon, defaultName, trackType }, { name, icon, index } = {}) {
17
- const { boxGraph, boxAdapters, rootBoxAdapter, userEditingManager } = this.#project;
18
- const existingNames = rootBoxAdapter.audioUnits.adapters()
19
- .map(adapter => adapter.input.getValue().match({
20
- none: () => "Untitled",
21
- some: adapter => adapter.labelField.getValue()
22
- }));
31
+ const { boxGraph, rootBox, userEditingManager } = this.#project;
32
+ assert(rootBox.isAttached(), "rootBox not attached");
33
+ const existingNames = rootBox.audioUnits.pointerHub.incoming().map(({ box }) => {
34
+ const inputBox = asDefined(asInstanceOf(box, AudioUnitBox).input.pointerHub.incoming().at(0)).box;
35
+ return "label" in inputBox && inputBox.label instanceof StringField ? inputBox.label.getValue() : "N/A";
36
+ });
23
37
  const audioUnitBox = this.#createAudioUnit(AudioUnitType.Instrument, index);
24
- const audioUnitBoxAdapter = boxAdapters.adapterFor(audioUnitBox, AudioUnitBoxAdapter);
25
38
  const uniqueName = Strings.getUniqueName(existingNames, name ?? defaultName);
26
39
  const iconSymbol = icon ?? defaultIcon;
27
- const instrumentBox = create(boxGraph, audioUnitBoxAdapter, uniqueName, iconSymbol);
40
+ const instrumentBox = create(boxGraph, audioUnitBox.input, uniqueName, iconSymbol);
28
41
  const trackBox = TrackBox.create(boxGraph, UUID.generate(), box => {
29
42
  box.index.setValue(0);
30
43
  box.type.setValue(trackType);
31
- box.tracks.refer(audioUnitBoxAdapter.tracksField);
32
- box.target.refer(audioUnitBoxAdapter.audioUnitBoxAdapter().box);
44
+ box.tracks.refer(audioUnitBox.tracks);
45
+ box.target.refer(audioUnitBox);
33
46
  });
34
47
  userEditingManager.audioUnit.edit(audioUnitBox.editing);
35
48
  return { audioUnitBox, instrumentBox, trackBox };
36
49
  }
37
- createEffect(host, factory, newIndex) {
38
- let chain;
39
- let field;
40
- if (factory.type === "audio") {
41
- chain = host.audioEffects.adapters();
42
- field = host.audioEffects.field();
43
- }
44
- else if (factory.type === "midi") {
45
- chain = host.midiEffects.adapters();
46
- field = host.midiEffects.field();
47
- }
48
- else {
49
- return panic(`Unknown factory type: ${factory.type}`);
50
- }
51
- const box = factory.create(this.#project, field, newIndex);
52
- for (let index = newIndex; index < chain.length; index++) {
53
- chain[index].indexField.setValue(index + 1);
54
- }
55
- return box;
56
- }
57
50
  createAudioBus(name, icon, type, color) {
58
51
  console.debug(`createAudioBus '${name}', type: ${type}, color: ${color}`);
59
52
  const { rootBox, boxGraph } = this.#project;
60
- assert(rootBox.audioBusses.isAttached(), "rootBox not attached");
53
+ assert(rootBox.isAttached(), "rootBox not attached");
61
54
  const uuid = UUID.generate();
62
55
  const audioBusBox = AudioBusBox.create(boxGraph, uuid, box => {
63
56
  box.collection.refer(rootBox.audioBusses);
@@ -75,14 +68,17 @@ export class ProjectApi {
75
68
  audioBusBox.output.refer(audioUnitBox.input);
76
69
  return audioBusBox;
77
70
  }
78
- createNoteTrack(adapter, index = 0) {
79
- return this.#createTrack(adapter, TrackType.Notes, index);
71
+ insertEffect(field, factory, insertIndex = Number.MAX_SAFE_INTEGER) {
72
+ return factory.create(this.#project, field, IndexedBox.insertOrder(field, insertIndex));
73
+ }
74
+ createNoteTrack(audioUnitBox, insertIndex = Number.MAX_SAFE_INTEGER) {
75
+ return this.#createTrack({ field: audioUnitBox.tracks, trackType: TrackType.Notes, insertIndex });
80
76
  }
81
- createAudioTrack(adapter, index = 0) {
82
- return this.#createTrack(adapter, TrackType.Audio, index);
77
+ createAudioTrack(audioUnitBox, insertIndex = Number.MAX_SAFE_INTEGER) {
78
+ return this.#createTrack({ field: audioUnitBox.tracks, trackType: TrackType.Audio, insertIndex });
83
79
  }
84
- createAutomationTrack(adapter, index = 0) {
85
- return this.#createTrack(adapter, TrackType.Value, index);
80
+ createAutomationTrack(audioUnitBox, target, insertIndex = Number.MAX_SAFE_INTEGER) {
81
+ return this.#createTrack({ field: audioUnitBox.tracks, target, trackType: TrackType.Value, insertIndex });
86
82
  }
87
83
  createClip(trackBox, clipIndex, { name, hue } = {}) {
88
84
  const { boxGraph } = this.#project;
@@ -116,6 +112,9 @@ export class ProjectApi {
116
112
  return Option.None;
117
113
  }
118
114
  createNoteRegion({ trackBox, position, duration, loopOffset, loopDuration, eventOffset, eventCollection, mute, name, hue }) {
115
+ if (trackBox.type.getValue() !== TrackType.Notes) {
116
+ console.warn("You should not create a note-region in mismatched track");
117
+ }
119
118
  const { boxGraph } = this.#project;
120
119
  const events = eventCollection ?? NoteEventCollectionBox.create(boxGraph, UUID.generate());
121
120
  return NoteRegionBox.create(boxGraph, UUID.generate(), box => {
@@ -178,27 +177,14 @@ export class ProjectApi {
178
177
  .asBox(NoteEventCollectionBox).events);
179
178
  });
180
179
  }
181
- deleteAudioUnit(adapter) {
182
- const { rootBoxAdapter } = this.#project;
183
- const adapters = rootBoxAdapter.audioUnits.adapters();
184
- const boxIndex = adapter.indexField.getValue();
185
- const deleteIndex = adapters.indexOf(adapter);
186
- console.debug(`deleteAudioUnit adapter: ${adapter.toString()}, deleteIndex: ${deleteIndex}, indexField: ${boxIndex}`);
187
- if (deleteIndex === -1) {
188
- return panic(`Cannot delete ${adapter}. Does not exist.`);
189
- }
190
- if (deleteIndex !== boxIndex) {
191
- console.debug("indices", adapters.map(x => x.box.index.getValue()).join(", "));
192
- return panic(`Cannot delete ${adapter}. Wrong index.`);
193
- }
194
- for (let index = deleteIndex + 1; index < adapters.length; index++) {
195
- adapters[index].indexField.setValue(index - 1);
196
- }
197
- adapter.box.delete();
180
+ deleteAudioUnit(audioUnitBox) {
181
+ const { rootBox } = this.#project;
182
+ IndexedBox.removeOrder(rootBox.audioUnits, audioUnitBox.index.getValue());
183
+ audioUnitBox.delete();
198
184
  }
199
185
  #createAudioUnit(type, index) {
200
- const { boxGraph, rootBox, rootBoxAdapter, masterBusBox } = this.#project;
201
- const insertIndex = index ?? this.#pushAudioUnitsIndices(rootBoxAdapter, type, 1);
186
+ const { boxGraph, rootBox, masterBusBox } = this.#project;
187
+ const insertIndex = index ?? this.#sortAudioUnitOrdering(type);
202
188
  console.debug(`createAudioUnit type: ${type}, insertIndex: ${insertIndex}`);
203
189
  return AudioUnitBox.create(boxGraph, UUID.generate(), box => {
204
190
  box.collection.refer(rootBox.audioUnits);
@@ -207,26 +193,29 @@ export class ProjectApi {
207
193
  box.type.setValue(type);
208
194
  });
209
195
  }
210
- #createTrack(adapter, trackType, index = 0) {
196
+ #createTrack({ field, target, trackType, insertIndex }) {
197
+ const index = IndexedBox.insertOrder(field, insertIndex);
211
198
  return TrackBox.create(this.#project.boxGraph, UUID.generate(), box => {
212
199
  box.index.setValue(index);
213
200
  box.type.setValue(trackType);
214
- box.tracks.refer(adapter.tracksField);
215
- box.target.refer(adapter.audioUnitBoxAdapter().box);
201
+ box.tracks.refer(field);
202
+ box.target.refer(target ?? field.box);
216
203
  });
217
204
  }
218
- #pushAudioUnitsIndices(rootBoxAdapter, type, count = 1) {
219
- const adapters = rootBoxAdapter.audioUnits.adapters();
220
- const order = ProjectApi.AudioUnitOrdering[type];
205
+ #sortAudioUnitOrdering(type) {
206
+ const { AudioUnitOrdering } = ProjectApi;
207
+ const { rootBox } = this.#project;
208
+ const boxes = IndexedBox.collectIndexedBoxes(rootBox.audioUnits, AudioUnitBox);
209
+ const order = AudioUnitOrdering[type];
221
210
  let index = 0 | 0;
222
- for (; index < adapters.length; index++) {
223
- if (ProjectApi.AudioUnitOrdering[adapters[index].type] > order) {
211
+ for (; index < boxes.length; index++) {
212
+ if (AudioUnitOrdering[boxes[index].type.getValue()] > order) {
224
213
  break;
225
214
  }
226
215
  }
227
216
  const insertIndex = index;
228
- while (index < adapters.length) {
229
- adapters[index].indexField.setValue(count + index++);
217
+ while (index < boxes.length) {
218
+ boxes[index].index.setValue(++index);
230
219
  }
231
220
  return insertIndex;
232
221
  }
package/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./samples/MainThreadSampleManager";
8
8
  export * from "./samples/SampleProvider";
9
9
  export * from "./ColorCodes";
10
10
  export * from "./Colors";
11
+ export * from "./EffectBox";
11
12
  export * from "./EffectFactory";
12
13
  export * from "./EffectFactories";
13
14
  export * from "./Engine";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACj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B,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,qBAAqB,CAAA;AACnC,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,cAAc,CAAA;AAC5B,cAAc,cAAc,CAAA;AAC5B,cAAc,OAAO,CAAA;AACrB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -8,6 +8,7 @@ export * from "./samples/MainThreadSampleManager";
8
8
  export * from "./samples/SampleProvider";
9
9
  export * from "./ColorCodes";
10
10
  export * from "./Colors";
11
+ export * from "./EffectBox";
11
12
  export * from "./EffectFactory";
12
13
  export * from "./EffectFactories";
13
14
  export * from "./Engine";