@opendaw/studio-core 0.0.38 → 0.0.39

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 +1 @@
1
- {"version":3,"file":"AudioOfflineRenderer.d.ts","sourceRoot":"","sources":["../src/AudioOfflineRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,GAAG,EAAE,MAAM,EAAmC,MAAM,kBAAkB,CAAA;AAI9G,OAAO,EAAC,wBAAwB,EAAC,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AAIjD,yBAAiB,oBAAoB,CAAC;IAC3B,MAAM,KAAK,GAAU,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,wBAAwB,MAAM,CAAC,wBAAwB,CAAC,EACxD,aAAY,GAAY,KAAG,OAAO,CAAC,IAAI,CA+BlE,CAAA;CAiDJ"}
1
+ {"version":3,"file":"AudioOfflineRenderer.d.ts","sourceRoot":"","sources":["../src/AudioOfflineRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,GAAG,EAAE,MAAM,EAAmC,MAAM,kBAAkB,CAAA;AAI9G,OAAO,EAAC,wBAAwB,EAAC,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAA;AACzC,OAAO,EAAC,WAAW,EAAC,MAAM,uBAAuB,CAAA;AAIjD,yBAAiB,oBAAoB,CAAC;IAC3B,MAAM,KAAK,GAAU,QAAQ,OAAO,EACf,MAAM,WAAW,EACjB,wBAAwB,MAAM,CAAC,wBAAwB,CAAC,EACxD,aAAY,GAAY,KAAG,OAAO,CAAC,IAAI,CAgClE,CAAA;CAiDJ"}
@@ -8,8 +8,11 @@ import { AudioWorklets } from "./AudioWorklets";
8
8
  export var AudioOfflineRenderer;
9
9
  (function (AudioOfflineRenderer) {
10
10
  AudioOfflineRenderer.start = async (source, meta, optExportConfiguration, sampleRate = 48_000) => {
11
- const project = source.copy();
12
11
  const numStems = ExportStemsConfiguration.countStems(optExportConfiguration);
12
+ if (numStems === 0) {
13
+ return panic("Nothing to export");
14
+ }
15
+ const project = source.copy();
13
16
  const progress = new DefaultObservableValue(0.0);
14
17
  const dialog = RuntimeNotifier.progress({ headline: "Rendering...", progress });
15
18
  project.boxGraph.beginTransaction();
@@ -1 +1 @@
1
- {"version":3,"file":"CaptureMidi.d.ts","sourceRoot":"","sources":["../../src/capture/CaptureMidi.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,UAAU,EACb,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAEnD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAI/C,qBAAa,WAAY,SAAQ,OAAO,CAAC,cAAc,CAAC;;gBAOxC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc;IA8B/F,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAEhC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY;IAE5D,IAAI,KAAK,IAAI,MAAM,CAgBlB;IAED,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,CAIhC;IAEK,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBvC,cAAc,IAAI,UAAU;CAgD/B"}
1
+ {"version":3,"file":"CaptureMidi.d.ts","sourceRoot":"","sources":["../../src/capture/CaptureMidi.ts"],"names":[],"mappings":"AAAA,OAAO,EAQH,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,UAAU,EACb,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EAAC,YAAY,EAAE,cAAc,EAAC,MAAM,uBAAuB,CAAA;AAClE,OAAO,EAAC,UAAU,EAAC,MAAM,0BAA0B,CAAA;AAEnD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AACjC,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAA;AAI/C,qBAAa,WAAY,SAAQ,OAAO,CAAC,cAAc,CAAC;;gBAOxC,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc;IA+B/F,MAAM,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IAEhC,cAAc,CAAC,QAAQ,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,YAAY;IAE5D,IAAI,KAAK,IAAI,MAAM,CAgBlB;IAED,IAAI,WAAW,IAAI,MAAM,CAAC,MAAM,CAAC,CAIhC;IAEK,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuBvC,cAAc,IAAI,UAAU;CAgD/B"}
@@ -33,7 +33,7 @@ export class CaptureMidi extends Capture {
33
33
  else {
34
34
  this.#stopStream();
35
35
  }
36
- }), this.#notifier.subscribe((signal) => manager.project.engine.noteSignal(signal)));
36
+ }), this.#notifier.subscribe((signal) => manager.project.engine.noteSignal(signal)), Terminable.create(() => this.#stopStream()));
37
37
  }
38
38
  notify(signal) { this.#notifier.notify(signal); }
39
39
  subscribeNotes(observer) { return this.#notifier.subscribe(observer); }
@@ -1,5 +1,7 @@
1
- import { byte, Terminable, unitValue } from "@opendaw/lib-std";
2
- export declare class SoftwareMIDIInput implements MIDIInput, Terminable {
1
+ import { byte, int, Nullable, ObservableValue, unitValue } from "@opendaw/lib-std";
2
+ type OnMidiMessage = Nullable<(this: MIDIInput, ev: MIDIMessageEvent) => any>;
3
+ type OnStateChange = Nullable<(this: MIDIPort, ev: MIDIConnectionEvent) => any>;
4
+ export declare class SoftwareMIDIInput implements MIDIInput {
3
5
  #private;
4
6
  readonly manufacturer: string | null;
5
7
  readonly connection: MIDIPortConnectionState;
@@ -8,13 +10,18 @@ export declare class SoftwareMIDIInput implements MIDIInput, Terminable {
8
10
  readonly state: MIDIPortDeviceState;
9
11
  readonly type: MIDIPortType;
10
12
  readonly version: string | null;
11
- onmidimessage: ((this: MIDIInput, ev: MIDIMessageEvent) => any) | null;
12
- onstatechange: ((this: MIDIPort, ev: MIDIConnectionEvent) => any) | null;
13
- channel: byte;
13
+ onstatechange: OnStateChange;
14
14
  constructor();
15
- sendNoteOnEvent(note: byte, velocity?: unitValue): void;
16
- sendNoteOffEvent(note: byte): void;
17
- sendMIDIMessageData(data: Uint8Array): void;
15
+ get onmidimessage(): OnMidiMessage;
16
+ set onmidimessage(value: OnMidiMessage);
17
+ get countListeners(): ObservableValue<int>;
18
+ sendNoteOn(note: byte, velocity?: unitValue): void;
19
+ sendNoteOff(note: byte): void;
20
+ releaseAllNotes(): void;
21
+ hasActiveNote(note: byte): boolean;
22
+ hasActiveNotes(): boolean;
23
+ get channel(): byte;
24
+ set channel(value: byte);
18
25
  open(): Promise<MIDIPort>;
19
26
  close(): Promise<MIDIPort>;
20
27
  addEventListener<K extends keyof MIDIInputEventMap>(type: K, listener: (this: MIDIInput, ev: MIDIInputEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
@@ -22,6 +29,6 @@ export declare class SoftwareMIDIInput implements MIDIInput, Terminable {
22
29
  dispatchEvent(event: MIDIMessageEvent): boolean;
23
30
  removeEventListener<K extends keyof MIDIInputEventMap>(type: K, listener: (this: MIDIInput, ev: MIDIInputEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
24
31
  removeEventListener<K extends keyof MIDIPortEventMap>(type: K, listener: (this: MIDIPort, ev: MIDIPortEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
25
- terminate(): void;
26
32
  }
33
+ export {};
27
34
  //# sourceMappingURL=SoftwareMIDIInput.d.ts.map
@@ -1 +1 @@
1
- {"version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,gBAAgB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI;IAK1K,aAAa,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO;IAI/C,mBAAmB,CAAC,CAAC,SAAS,MAAM,iBAAiB,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI;IAC7K,mBAAmB,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI;CAc7K"}
@@ -1,4 +1,4 @@
1
- import { clamp, safeExecute } from "@opendaw/lib-std";
1
+ import { assert, clamp, DefaultObservableValue, isNull, safeExecute } from "@opendaw/lib-std";
2
2
  import { MidiData } from "@opendaw/lib-midi";
3
3
  export class SoftwareMIDIInput {
4
4
  manufacturer = "openDAW";
@@ -9,34 +9,72 @@ export class SoftwareMIDIInput {
9
9
  type = "input";
10
10
  version = "1.0.0";
11
11
  #dispatcher;
12
- onmidimessage = null;
13
- onstatechange = null; // has no effect. always on.
14
- channel = 0; // 0...16
15
- constructor() { this.#dispatcher = new EventTarget(); }
16
- sendNoteOnEvent(note, velocity = 1.0) {
17
- const velocityByte = Math.round(clamp(velocity, 0, 1) * 127);
18
- this.sendMIDIMessageData(MidiData.noteOn(this.channel, note, velocityByte));
19
- }
20
- sendNoteOffEvent(note) {
21
- this.sendMIDIMessageData(MidiData.noteOff(this.channel, note));
22
- }
23
- sendMIDIMessageData(data) {
24
- const eventInit = { data };
25
- this.dispatchEvent(new MessageEvent("midimessage", eventInit));
12
+ #countListeners;
13
+ #activeNotes;
14
+ onstatechange = null; // has no effect. this device is always connected.
15
+ #onmidimessage = null;
16
+ #channel = 0; // 0...15
17
+ constructor() {
18
+ this.#dispatcher = new EventTarget();
19
+ this.#countListeners = new DefaultObservableValue(0);
20
+ this.#activeNotes = new Uint8Array(128);
21
+ }
22
+ get onmidimessage() { return this.#onmidimessage; }
23
+ set onmidimessage(value) {
24
+ this.#onmidimessage = value;
25
+ if (isNull(value)) {
26
+ this.#changeListenerCount(-1);
27
+ }
28
+ else {
29
+ this.#changeListenerCount(1);
30
+ }
31
+ }
32
+ get countListeners() { return this.#countListeners; }
33
+ sendNoteOn(note, velocity = 1.0) {
34
+ assert(note >= 0 && note <= 127, `Note must be between 0 and 127, but was ${note}`);
35
+ this.#activeNotes[note]++;
36
+ const velocityByte = Math.round(clamp(velocity, 0.0, 1.0) * 127.0);
37
+ this.#sendMIDIMessageData(MidiData.noteOn(this.#channel, note, velocityByte));
38
+ }
39
+ sendNoteOff(note) {
40
+ assert(note >= 0 && note <= 127, `Note must be between 0 and 127, but was ${note}`);
41
+ this.#activeNotes[note]--;
42
+ this.#sendMIDIMessageData(MidiData.noteOff(this.#channel, note));
43
+ assert(this.#activeNotes[note] >= 0, "Negative count of active notes");
44
+ }
45
+ releaseAllNotes() {
46
+ this.#activeNotes.forEach((_, note) => this.#sendMIDIMessageData(MidiData.noteOff(this.#channel, note)));
47
+ this.#activeNotes.fill(0);
48
+ }
49
+ hasActiveNote(note) { return this.#activeNotes[note] > 0; }
50
+ hasActiveNotes() { return this.#activeNotes.some(count => count > 0); }
51
+ get channel() { return this.#channel; }
52
+ set channel(value) {
53
+ if (this.#channel === value) {
54
+ return;
55
+ }
56
+ this.releaseAllNotes();
57
+ this.#channel = value;
26
58
  }
27
59
  open() { return Promise.resolve(this); }
28
60
  close() { return Promise.resolve(this); }
29
61
  addEventListener(type, listener, options) {
30
62
  this.#dispatcher.addEventListener(type, listener, options);
63
+ this.#changeListenerCount(1);
31
64
  }
32
65
  dispatchEvent(event) {
33
- safeExecute(this.onmidimessage, event);
66
+ safeExecute(this.#onmidimessage, event);
34
67
  return this.#dispatcher.dispatchEvent(event);
35
68
  }
36
69
  removeEventListener(type, listener, options) {
37
70
  this.#dispatcher.removeEventListener(type, listener, options);
71
+ this.#changeListenerCount(-1);
72
+ }
73
+ #sendMIDIMessageData(data) {
74
+ const eventInit = { data };
75
+ this.dispatchEvent(new MessageEvent("midimessage", eventInit));
38
76
  }
39
- terminate() {
40
- this.#dispatcher.dispatchEvent(new Event("close"));
77
+ #changeListenerCount(delta) {
78
+ this.#countListeners.setValue(this.#countListeners.getValue() + delta);
41
79
  }
42
80
  }