@opendaw/studio-core 0.0.12 → 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,19 +1,23 @@
1
- import { float, int, Option } from "@opendaw/lib-std";
2
- import { AudioUnitType } from "@opendaw/studio-enums";
3
- import { AudioBusBox, NoteClipBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
4
- import { AnyClipBox, AudioUnitBoxAdapter, DeviceHost, IconSymbol, NoteEventBoxAdapter } from "@opendaw/studio-adapters";
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";
4
+ import { AudioUnitType, Pointers } from "@opendaw/studio-enums";
5
+ import { AudioBusBox, AudioUnitBox, NoteEventBox, NoteEventCollectionBox, NoteRegionBox, TrackBox, ValueRegionBox } from "@opendaw/studio-boxes";
6
+ import { AnyClipBox, AudioUnitBoxAdapter, EffectPointerType, IconSymbol, IndexedAdapterCollectionListener } from "@opendaw/studio-adapters";
5
7
  import { Project } from "./Project";
6
8
  import { InstrumentFactory } from "./InstrumentFactory";
7
9
  import { InstrumentProduct } from "./InstrumentProduct";
8
10
  import { InstrumentOptions } from "./InstrumentOptions";
9
11
  import { EffectFactory } from "./EffectFactory";
10
- import { ppqn } from "@opendaw/lib-dsp";
12
+ import { EffectBox } from "./EffectBox";
11
13
  export type ClipRegionOptions = {
12
14
  name?: string;
13
15
  hue?: number;
14
16
  };
15
17
  export type NoteEventParams = {
16
- owner: NoteRegionBox | NoteClipBox;
18
+ owner: {
19
+ events: PointerField<Pointers.NoteEventCollection>;
20
+ };
17
21
  position: ppqn;
18
22
  duration: ppqn;
19
23
  pitch: int;
@@ -21,24 +25,35 @@ export type NoteEventParams = {
21
25
  velocity?: float;
22
26
  chance?: int;
23
27
  };
28
+ export type NoteRegionParams = {
29
+ trackBox: TrackBox;
30
+ position: ppqn;
31
+ duration: ppqn;
32
+ loopOffset?: ppqn;
33
+ loopDuration?: ppqn;
34
+ eventOffset?: ppqn;
35
+ eventCollection?: NoteEventCollectionBox;
36
+ mute?: boolean;
37
+ name?: string;
38
+ hue?: number;
39
+ };
24
40
  export declare class ProjectApi {
25
41
  #private;
26
- static readonly AudioUnitOrdering: {
27
- readonly instrument: 0;
28
- readonly aux: 1;
29
- readonly bus: 2;
30
- readonly output: 3;
31
- };
42
+ static readonly AudioUnitOrdering: Record<string, int>;
32
43
  constructor(project: Project);
44
+ setBpm(value: number): void;
45
+ catchupAndSubscribeBpm(observer: Observer<number>): Subscription;
46
+ catchupAndSubscribeAudioUnits(listener: IndexedAdapterCollectionListener<AudioUnitBoxAdapter>): Subscription;
33
47
  createInstrument({ create, defaultIcon, defaultName, trackType }: InstrumentFactory, { name, icon, index }?: InstrumentOptions): InstrumentProduct;
34
- createEffect(host: DeviceHost, factory: EffectFactory, newIndex: int): import("@opendaw/lib-box").Box<import("@opendaw/lib-box").PointerTypes, any>;
35
48
  createAudioBus(name: string, icon: IconSymbol, type: AudioUnitType, color: string): AudioBusBox;
36
- createNoteTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
37
- createAudioTrack(adapter: AudioUnitBoxAdapter, index?: int): TrackBox;
38
- 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;
39
53
  createClip(trackBox: TrackBox, clipIndex: int, { name, hue }?: ClipRegionOptions): Option<AnyClipBox>;
40
- createRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
41
- createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBoxAdapter;
42
- deleteAudioUnit(adapter: AudioUnitBoxAdapter): void;
54
+ createNoteRegion({ trackBox, position, duration, loopOffset, loopDuration, eventOffset, eventCollection, mute, name, hue }: NoteRegionParams): NoteRegionBox;
55
+ createTrackRegion(trackBox: TrackBox, position: ppqn, duration: ppqn, { name, hue }?: ClipRegionOptions): Option<NoteRegionBox> | Option<ValueRegionBox>;
56
+ createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }: NoteEventParams): NoteEventBox;
57
+ deleteAudioUnit(audioUnitBox: AudioUnitBox): void;
43
58
  }
44
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;AAEjF,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAA;AACnD,OAAO,EACH,WAAW,EAEX,WAAW,EAGX,aAAa,EACb,QAAQ,EAGR,cAAc,EACjB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,UAAU,EACV,mBAAmB,EACnB,UAAU,EAGV,UAAU,EACV,mBAAmB,EAGtB,MAAM,0BAA0B,CAAA;AACjC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAE7C,OAAO,EAAC,IAAI,EAAO,MAAM,kBAAkB,CAAA;AAE3C,MAAM,MAAM,iBAAiB,GAAG;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,KAAK,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{ 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, NoteEventBoxAdapter, 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));
80
73
  }
81
- createAudioTrack(adapter, index = 0) {
82
- return this.#createTrack(adapter, TrackType.Audio, index);
74
+ createNoteTrack(audioUnitBox, insertIndex = Number.MAX_SAFE_INTEGER) {
75
+ return this.#createTrack({ field: audioUnitBox.tracks, trackType: TrackType.Notes, insertIndex });
83
76
  }
84
- createAutomationTrack(adapter, index = 0) {
85
- return this.#createTrack(adapter, TrackType.Value, index);
77
+ createAudioTrack(audioUnitBox, insertIndex = Number.MAX_SAFE_INTEGER) {
78
+ return this.#createTrack({ field: audioUnitBox.tracks, trackType: TrackType.Audio, insertIndex });
79
+ }
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;
@@ -104,7 +100,7 @@ export class ProjectApi {
104
100
  const events = ValueEventCollectionBox.create(boxGraph, UUID.generate());
105
101
  return Option.wrap(ValueClipBox.create(boxGraph, UUID.generate(), box => {
106
102
  box.index.setValue(clipIndex);
107
- box.label.setValue(name ?? "CV");
103
+ box.label.setValue(name ?? "Automation");
108
104
  box.hue.setValue(hue ?? ColorCodes.forTrackType(type));
109
105
  box.mute.setValue(false);
110
106
  box.duration.setValue(PPQN.Bar);
@@ -115,7 +111,26 @@ export class ProjectApi {
115
111
  }
116
112
  return Option.None;
117
113
  }
118
- createRegion(trackBox, position, duration, { name, hue } = {}) {
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
+ }
118
+ const { boxGraph } = this.#project;
119
+ const events = eventCollection ?? NoteEventCollectionBox.create(boxGraph, UUID.generate());
120
+ return NoteRegionBox.create(boxGraph, UUID.generate(), box => {
121
+ box.position.setValue(position);
122
+ box.label.setValue(name ?? "Notes");
123
+ box.hue.setValue(hue ?? ColorCodes.forTrackType(trackBox.type.getValue()));
124
+ box.mute.setValue(mute ?? false);
125
+ box.duration.setValue(duration);
126
+ box.loopDuration.setValue(loopOffset ?? 0);
127
+ box.loopDuration.setValue(loopDuration ?? duration);
128
+ box.eventOffset.setValue(eventOffset ?? 0);
129
+ box.events.refer(events.owners);
130
+ box.regions.refer(trackBox.regions);
131
+ });
132
+ }
133
+ createTrackRegion(trackBox, position, duration, { name, hue } = {}) {
119
134
  const { boxGraph } = this.#project;
120
135
  const type = trackBox.type.getValue();
121
136
  switch (type) {
@@ -149,8 +164,8 @@ export class ProjectApi {
149
164
  return Option.None;
150
165
  }
151
166
  createNoteEvent({ owner, position, duration, velocity, pitch, chance, cent }) {
152
- const { boxAdapters, boxGraph } = this.#project;
153
- return boxAdapters.adapterFor(NoteEventBox.create(boxGraph, UUID.generate(), box => {
167
+ const { boxGraph } = this.#project;
168
+ return NoteEventBox.create(boxGraph, UUID.generate(), box => {
154
169
  box.position.setValue(position);
155
170
  box.duration.setValue(duration);
156
171
  box.velocity.setValue(velocity ?? 1.0);
@@ -160,29 +175,16 @@ export class ProjectApi {
160
175
  box.events.refer(owner.events.targetVertex
161
176
  .unwrap("Owner has no event-collection").box
162
177
  .asBox(NoteEventCollectionBox).events);
163
- }), NoteEventBoxAdapter);
164
- }
165
- deleteAudioUnit(adapter) {
166
- const { rootBoxAdapter } = this.#project;
167
- const adapters = rootBoxAdapter.audioUnits.adapters();
168
- const boxIndex = adapter.indexField.getValue();
169
- const deleteIndex = adapters.indexOf(adapter);
170
- console.debug(`deleteAudioUnit adapter: ${adapter.toString()}, deleteIndex: ${deleteIndex}, indexField: ${boxIndex}`);
171
- if (deleteIndex === -1) {
172
- return panic(`Cannot delete ${adapter}. Does not exist.`);
173
- }
174
- if (deleteIndex !== boxIndex) {
175
- console.debug("indices", adapters.map(x => x.box.index.getValue()).join(", "));
176
- return panic(`Cannot delete ${adapter}. Wrong index.`);
177
- }
178
- for (let index = deleteIndex + 1; index < adapters.length; index++) {
179
- adapters[index].indexField.setValue(index - 1);
180
- }
181
- adapter.box.delete();
178
+ });
179
+ }
180
+ deleteAudioUnit(audioUnitBox) {
181
+ const { rootBox } = this.#project;
182
+ IndexedBox.removeOrder(rootBox.audioUnits, audioUnitBox.index.getValue());
183
+ audioUnitBox.delete();
182
184
  }
183
185
  #createAudioUnit(type, index) {
184
- const { boxGraph, rootBox, rootBoxAdapter, masterBusBox } = this.#project;
185
- const insertIndex = index ?? this.#pushAudioUnitsIndices(rootBoxAdapter, type, 1);
186
+ const { boxGraph, rootBox, masterBusBox } = this.#project;
187
+ const insertIndex = index ?? this.#sortAudioUnitOrdering(type);
186
188
  console.debug(`createAudioUnit type: ${type}, insertIndex: ${insertIndex}`);
187
189
  return AudioUnitBox.create(boxGraph, UUID.generate(), box => {
188
190
  box.collection.refer(rootBox.audioUnits);
@@ -191,26 +193,29 @@ export class ProjectApi {
191
193
  box.type.setValue(type);
192
194
  });
193
195
  }
194
- #createTrack(adapter, trackType, index = 0) {
196
+ #createTrack({ field, target, trackType, insertIndex }) {
197
+ const index = IndexedBox.insertOrder(field, insertIndex);
195
198
  return TrackBox.create(this.#project.boxGraph, UUID.generate(), box => {
196
199
  box.index.setValue(index);
197
200
  box.type.setValue(trackType);
198
- box.tracks.refer(adapter.tracksField);
199
- box.target.refer(adapter.audioUnitBoxAdapter().box);
201
+ box.tracks.refer(field);
202
+ box.target.refer(target ?? field.box);
200
203
  });
201
204
  }
202
- #pushAudioUnitsIndices(rootBoxAdapter, type, count = 1) {
203
- const adapters = rootBoxAdapter.audioUnits.adapters();
204
- 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];
205
210
  let index = 0 | 0;
206
- for (; index < adapters.length; index++) {
207
- if (ProjectApi.AudioUnitOrdering[adapters[index].type] > order) {
211
+ for (; index < boxes.length; index++) {
212
+ if (AudioUnitOrdering[boxes[index].type.getValue()] > order) {
208
213
  break;
209
214
  }
210
215
  }
211
216
  const insertIndex = index;
212
- while (index < adapters.length) {
213
- adapters[index].indexField.setValue(count + index++);
217
+ while (index < boxes.length) {
218
+ boxes[index].index.setValue(++index);
214
219
  }
215
220
  return insertIndex;
216
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;AACjC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAAA;AAExC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,kCAAkC,CAAA;AAChD,cAAc,mCAAmC,CAAA;AACjD,cAAc,0BAA0B,CAAA;AAExC,cAAc,cAAc,CAAA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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";