@opendaw/studio-core 0.0.25 → 0.0.27

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.
Files changed (118) hide show
  1. package/dist/AudioDevices.js +4 -4
  2. package/dist/AudioOfflineRenderer.d.ts.map +1 -1
  3. package/dist/AudioOfflineRenderer.js +9 -5
  4. package/dist/Engine.d.ts +4 -4
  5. package/dist/Engine.d.ts.map +1 -1
  6. package/dist/EngineFacade.d.ts +4 -4
  7. package/dist/EngineFacade.d.ts.map +1 -1
  8. package/dist/EngineWorklet.d.ts +4 -4
  9. package/dist/EngineWorklet.d.ts.map +1 -1
  10. package/dist/RecordingWorklet.d.ts +1 -1
  11. package/dist/RecordingWorklet.d.ts.map +1 -1
  12. package/dist/RecordingWorklet.js +1 -1
  13. package/dist/WavFile.d.ts +10 -0
  14. package/dist/WavFile.d.ts.map +1 -0
  15. package/dist/WavFile.js +94 -0
  16. package/dist/WorkerAgents.d.ts +1 -1
  17. package/dist/WorkerAgents.d.ts.map +1 -1
  18. package/dist/WorkerAgents.js +15 -3
  19. package/dist/capture/Capture.d.ts +1 -1
  20. package/dist/capture/Capture.d.ts.map +1 -1
  21. package/dist/capture/CaptureAudio.d.ts.map +1 -1
  22. package/dist/capture/CaptureAudio.js +4 -4
  23. package/dist/capture/CaptureDevices.d.ts +1 -1
  24. package/dist/capture/CaptureDevices.d.ts.map +1 -1
  25. package/dist/capture/CaptureMidi.d.ts.map +1 -1
  26. package/dist/capture/CaptureMidi.js +6 -5
  27. package/dist/capture/Recording.d.ts.map +1 -1
  28. package/dist/capture/Recording.js +3 -3
  29. package/dist/clouds/CloudAuthManager.d.ts +10 -0
  30. package/dist/clouds/CloudAuthManager.d.ts.map +1 -0
  31. package/dist/clouds/CloudAuthManager.js +195 -0
  32. package/dist/clouds/CloudBackup.d.ts +8 -0
  33. package/dist/clouds/CloudBackup.d.ts.map +1 -0
  34. package/dist/clouds/CloudBackup.js +55 -0
  35. package/dist/clouds/CloudBackupProjects.d.ts +10 -0
  36. package/dist/clouds/CloudBackupProjects.d.ts.map +1 -0
  37. package/dist/clouds/CloudBackupProjects.js +167 -0
  38. package/dist/clouds/CloudBackupSamples.d.ts +13 -0
  39. package/dist/clouds/CloudBackupSamples.d.ts.map +1 -0
  40. package/dist/clouds/CloudBackupSamples.js +129 -0
  41. package/dist/clouds/CloudHandler.d.ts +9 -0
  42. package/dist/clouds/CloudHandler.d.ts.map +1 -0
  43. package/dist/clouds/CloudHandler.js +1 -0
  44. package/dist/clouds/CloudService.d.ts +2 -0
  45. package/dist/clouds/CloudService.d.ts.map +1 -0
  46. package/dist/clouds/CloudService.js +1 -0
  47. package/dist/clouds/DropboxHandler.d.ts +12 -0
  48. package/dist/clouds/DropboxHandler.d.ts.map +1 -0
  49. package/dist/clouds/DropboxHandler.js +83 -0
  50. package/dist/clouds/GoogleDriveHandler.d.ts +12 -0
  51. package/dist/clouds/GoogleDriveHandler.d.ts.map +1 -0
  52. package/dist/clouds/GoogleDriveHandler.js +256 -0
  53. package/dist/dawproject/DawProject.d.ts +2 -2
  54. package/dist/dawproject/DawProject.d.ts.map +1 -1
  55. package/dist/dawproject/DawProjectExporter.js +2 -2
  56. package/dist/dawproject/DawProjectImport.d.ts +1 -1
  57. package/dist/dawproject/DawProjectImport.d.ts.map +1 -1
  58. package/dist/dawproject/DeviceIO.d.ts +1 -1
  59. package/dist/dawproject/DeviceIO.d.ts.map +1 -1
  60. package/dist/dawproject/DeviceIO.js +2 -1
  61. package/dist/index.d.ts +18 -12
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +18 -12
  64. package/dist/midi/MIDILearning.d.ts +26 -0
  65. package/dist/midi/MIDILearning.d.ts.map +1 -0
  66. package/dist/midi/MIDILearning.js +88 -0
  67. package/dist/midi/MIDIMessageSubscriber.d.ts +5 -0
  68. package/dist/midi/MIDIMessageSubscriber.d.ts.map +1 -0
  69. package/dist/midi/MIDIMessageSubscriber.js +40 -0
  70. package/dist/midi/MidiDevices.d.ts.map +1 -0
  71. package/dist/{MidiDevices.js → midi/MidiDevices.js} +6 -5
  72. package/dist/processors.js +3 -3
  73. package/dist/processors.js.map +4 -4
  74. package/dist/project/Project.d.ts +2 -0
  75. package/dist/project/Project.d.ts.map +1 -1
  76. package/dist/project/Project.js +7 -1
  77. package/dist/project/ProjectApi.d.ts +9 -1
  78. package/dist/project/ProjectApi.d.ts.map +1 -1
  79. package/dist/project/ProjectApi.js +67 -3
  80. package/dist/project/ProjectBundle.d.ts +1 -1
  81. package/dist/project/ProjectBundle.d.ts.map +1 -1
  82. package/dist/project/ProjectBundle.js +10 -12
  83. package/dist/project/ProjectPaths.d.ts +4 -4
  84. package/dist/project/ProjectPaths.d.ts.map +1 -1
  85. package/dist/project/ProjectProfile.d.ts +2 -2
  86. package/dist/project/ProjectProfile.d.ts.map +1 -1
  87. package/dist/project/ProjectProfile.js +3 -3
  88. package/dist/project/ProjectSignals.d.ts +6 -0
  89. package/dist/project/ProjectSignals.d.ts.map +1 -0
  90. package/dist/project/ProjectSignals.js +4 -0
  91. package/dist/project/ProjectStorage.d.ts +23 -0
  92. package/dist/project/ProjectStorage.d.ts.map +1 -0
  93. package/dist/project/ProjectStorage.js +59 -0
  94. package/dist/samples/MainThreadSampleLoader.d.ts +2 -2
  95. package/dist/samples/MainThreadSampleLoader.d.ts.map +1 -1
  96. package/dist/samples/MainThreadSampleLoader.js +2 -3
  97. package/dist/samples/MainThreadSampleManager.d.ts +4 -4
  98. package/dist/samples/MainThreadSampleManager.d.ts.map +1 -1
  99. package/dist/samples/OpenSampleAPI.d.ts +4 -2
  100. package/dist/samples/OpenSampleAPI.d.ts.map +1 -1
  101. package/dist/samples/OpenSampleAPI.js +19 -2
  102. package/dist/samples/SampleAPI.d.ts +2 -2
  103. package/dist/samples/SampleAPI.d.ts.map +1 -1
  104. package/dist/samples/SampleImporter.d.ts +1 -1
  105. package/dist/samples/SampleImporter.d.ts.map +1 -1
  106. package/dist/samples/SampleProvider.d.ts +1 -1
  107. package/dist/samples/SampleProvider.d.ts.map +1 -1
  108. package/dist/samples/SampleStorage.d.ts +7 -5
  109. package/dist/samples/SampleStorage.d.ts.map +1 -1
  110. package/dist/samples/SampleStorage.js +31 -17
  111. package/dist/workers.js +2 -2
  112. package/dist/workers.js.map +4 -4
  113. package/package.json +14 -14
  114. package/dist/MidiDevices.d.ts.map +0 -1
  115. package/dist/Wav.d.ts +0 -6
  116. package/dist/Wav.d.ts.map +0 -1
  117. package/dist/Wav.js +0 -46
  118. /package/dist/{MidiDevices.d.ts → midi/MidiDevices.d.ts} +0 -0
@@ -0,0 +1,88 @@
1
+ import { Errors, isDefined, RuntimeNotifier, Terminator } from "@opendaw/lib-std";
2
+ import { Address } from "@opendaw/lib-box";
3
+ import { MidiData } from "@opendaw/lib-midi";
4
+ import { MidiDevices } from "./MidiDevices";
5
+ export class MIDILearning {
6
+ #terminator = new Terminator();
7
+ #project;
8
+ #connections;
9
+ constructor(project) {
10
+ this.#project = project;
11
+ this.#connections = Address.newSet(connection => connection.address);
12
+ }
13
+ hasMidiConnection(address) { return this.#connections.hasKey(address); }
14
+ forgetMidiConnection(address) { this.#connections.removeByKey(address).terminate(); }
15
+ async learnMIDIControls(field) {
16
+ if (!MidiDevices.canRequestMidiAccess()) {
17
+ return;
18
+ }
19
+ await MidiDevices.requestPermission();
20
+ const learnLifecycle = this.#terminator.spawn();
21
+ const abortController = new AbortController();
22
+ learnLifecycle.own(MidiDevices.subscribeMessageEvents((event) => {
23
+ const data = event.data;
24
+ if (data === null) {
25
+ return;
26
+ }
27
+ if (MidiData.isController(data)) {
28
+ learnLifecycle.terminate();
29
+ abortController.abort(Errors.AbortError);
30
+ return this.#startListeningControl(field, MidiData.readChannel(data), MidiData.readParam1(data), event);
31
+ }
32
+ }));
33
+ return RuntimeNotifier.info({
34
+ headline: "Learn Midi Keys...",
35
+ message: "Hit a key on your midi-device to learn a connection.",
36
+ okText: "Cancel",
37
+ abortSignal: abortController.signal
38
+ }).then(() => learnLifecycle.terminate(), Errors.CatchAbort);
39
+ }
40
+ toJSON() {
41
+ return this.#connections.values().map(connection => connection.toJSON());
42
+ }
43
+ terminate() {
44
+ this.#killAllConnections();
45
+ this.#terminator.terminate();
46
+ }
47
+ #startListeningControl(field, channel, controlId, event) {
48
+ console.debug(`startListeningControl channel: ${channel}, controlId: ${controlId}`);
49
+ const { observer, terminate } = this.#createMidiControlObserver(this.#project, this.#project.parameterFieldAdapters.get(field.address), controlId);
50
+ if (isDefined(event)) {
51
+ observer(event);
52
+ }
53
+ const subscription = MidiDevices.subscribeMessageEvents(observer, channel);
54
+ this.#connections.add({
55
+ address: field.address,
56
+ toJSON: () => ({
57
+ type: "control",
58
+ address: field.address.toJSON(),
59
+ channel,
60
+ controlId
61
+ }),
62
+ label: () => this.#project.parameterFieldAdapters.get(field.address).name,
63
+ terminate: () => {
64
+ terminate();
65
+ subscription.terminate();
66
+ }
67
+ });
68
+ }
69
+ #killAllConnections() {
70
+ this.#connections.forEach(({ terminate }) => terminate());
71
+ this.#connections.clear();
72
+ }
73
+ #createMidiControlObserver(project, adapter, controlId) {
74
+ const registration = adapter.registerMidiControl();
75
+ return {
76
+ observer: (event) => {
77
+ const data = event.data;
78
+ if (data === null) {
79
+ return;
80
+ }
81
+ if (MidiData.isController(data) && MidiData.readParam1(data) === controlId) {
82
+ project.editing.modify(() => adapter.setValue(adapter.valueMapping.y(MidiData.asValue(data))), false);
83
+ }
84
+ },
85
+ terminate: () => registration.terminate()
86
+ };
87
+ }
88
+ }
@@ -0,0 +1,5 @@
1
+ import { byte, Observer, Subscription } from "@opendaw/lib-std";
2
+ export declare class MIDIMessageSubscriber {
3
+ static subscribeMessageEvents(access: MIDIAccess, observer: Observer<MIDIMessageEvent>, channel?: byte): Subscription;
4
+ }
5
+ //# sourceMappingURL=MIDIMessageSubscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MIDIMessageSubscriber.d.ts","sourceRoot":"","sources":["../../src/midi/MIDIMessageSubscriber.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAqC,QAAQ,EAAE,YAAY,EAAC,MAAM,kBAAkB,CAAA;AAIhG,qBAAa,qBAAqB;IAC9B,MAAM,CAAC,sBAAsB,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG,YAAY;CA+BxH"}
@@ -0,0 +1,40 @@
1
+ import { isDefined, isInstanceOf } from "@opendaw/lib-std";
2
+ import { Events } from "@opendaw/lib-dom";
3
+ import { MidiData } from "@opendaw/lib-midi";
4
+ export class MIDIMessageSubscriber {
5
+ static subscribeMessageEvents(access, observer, channel) {
6
+ const listen = (input) => isDefined(channel)
7
+ ? Events.subscribe(input, "midimessage", (event) => {
8
+ if (event.data === null || MidiData.readChannel(event.data) !== channel) {
9
+ return;
10
+ }
11
+ observer(event);
12
+ }) : Events.subscribe(input, "midimessage", observer);
13
+ const connections = Array.from(access.inputs.values())
14
+ .map(input => ([input, listen(input)]));
15
+ const stateSubscription = Events.subscribe(access, "statechange", (event) => {
16
+ const port = event.port;
17
+ if (!isInstanceOf(port, MIDIInput)) {
18
+ return;
19
+ }
20
+ for (const [input, subscription] of connections) {
21
+ if (input === port) {
22
+ // Well, this is strange, but if you start listening to a midi-input initially,
23
+ // it will change its state to 'connected', so we clean up the first old subscriptions.
24
+ subscription.terminate();
25
+ break;
26
+ }
27
+ }
28
+ if (port.state === "connected") {
29
+ connections.push([port, listen(port)]);
30
+ }
31
+ });
32
+ return {
33
+ terminate: () => {
34
+ stateSubscription.terminate();
35
+ connections.forEach(([_, subscription]) => subscription.terminate());
36
+ connections.length = 0;
37
+ }
38
+ };
39
+ }
40
+ }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MidiDevices.d.ts","sourceRoot":"","sources":["../../src/midi/MidiDevices.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,IAAI,EAIJ,sBAAsB,EAEtB,gBAAgB,EAEhB,QAAQ,EACR,MAAM,EACN,YAAY,EAEf,MAAM,kBAAkB,CAAA;AAKzB,qBAAa,WAAW;;IACpB,MAAM,CAAC,oBAAoB,IAAI,OAAO;WAIzB,iBAAiB;IAiB9B,MAAM,CAAC,GAAG,IAAI,gBAAgB,CAAC,UAAU,CAAC;IAE1C,MAAM,CAAC,sBAAsB,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG,YAAY;IAWjG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAIjD,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAInD,MAAM,CAAC,KAAK,IAAI,IAAI;IAkBpB,MAAM,CAAC,SAAS,IAAI,sBAAsB,CAAC,OAAO,CAAC;CAqCtD"}
@@ -7,18 +7,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
- import { Lazy, MutableObservableOption, MutableObservableValue, Notifier, Terminator, warn } from "@opendaw/lib-std";
10
+ import { Errors, Lazy, MutableObservableOption, MutableObservableValue, Notifier, Terminator } from "@opendaw/lib-std";
11
11
  import { MidiData } from "@opendaw/lib-midi";
12
12
  import { Promises } from "@opendaw/lib-runtime";
13
- import { MIDIMessageSubscriber } from "@opendaw/app-studio/src/midi/devices/MIDIMessageSubscriber";
13
+ import { MIDIMessageSubscriber } from "./MIDIMessageSubscriber";
14
14
  export class MidiDevices {
15
15
  static canRequestMidiAccess() { return "requestMIDIAccess" in navigator; }
16
+ static #memoizedRequest = Promises.memoizeAsync(() => navigator.requestMIDIAccess({ sysex: false }));
16
17
  static async requestPermission() {
17
18
  if (this.canRequestMidiAccess()) {
18
- const { status, value: midiAccess, error } = await Promises.tryCatch(navigator.requestMIDIAccess({ sysex: false }));
19
+ const { status, value: midiAccess, error } = await Promises.tryCatch(this.#memoizedRequest());
19
20
  if (status === "rejected") {
20
21
  console.warn(error);
21
- return warn("Could not request MIDI");
22
+ return Errors.warn("Could not request MIDI");
22
23
  }
23
24
  const numberOfInputs = midiAccess.inputs.size;
24
25
  const numberOfOutputs = midiAccess.outputs.size;
@@ -26,7 +27,7 @@ export class MidiDevices {
26
27
  this.#midiAccess.wrap(midiAccess);
27
28
  }
28
29
  else {
29
- return warn("This browser does not support MIDI");
30
+ return Errors.warn("This browser does not support MIDI");
30
31
  }
31
32
  }
32
33
  static get() { return this.#midiAccess; }