@opendaw/studio-core 0.0.43 → 0.0.44
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.
- package/dist/AssetService.d.ts +12 -2
- package/dist/AssetService.d.ts.map +1 -1
- package/dist/AssetService.js +46 -1
- package/dist/EngineWorklet.d.ts +1 -1
- package/dist/EngineWorklet.d.ts.map +1 -1
- package/dist/capture/CaptureDevices.js +1 -1
- package/dist/cloud/CloudAuthManager.d.ts +6 -2
- package/dist/cloud/CloudAuthManager.d.ts.map +1 -1
- package/dist/cloud/CloudAuthManager.js +12 -12
- package/dist/cloud/CloudBackup.js +1 -1
- package/dist/cloud/{CloudBackupSoundfont.d.ts → CloudBackupSoundfonts.d.ts} +1 -1
- package/dist/cloud/CloudBackupSoundfonts.d.ts.map +1 -0
- package/dist/cloud/{CloudBackupSoundfont.js → CloudBackupSoundfonts.js} +1 -1
- package/dist/processors.js +27 -5
- package/dist/processors.js.map +4 -4
- package/dist/project/Project.d.ts +2 -2
- package/dist/project/Project.d.ts.map +1 -1
- package/dist/project/Project.js +2 -3
- package/dist/samples/OpenSampleAPI.d.ts.map +1 -1
- package/dist/samples/OpenSampleAPI.js +5 -3
- package/dist/samples/SampleService.d.ts +5 -2
- package/dist/samples/SampleService.d.ts.map +1 -1
- package/dist/samples/SampleService.js +12 -4
- package/dist/samples/SampleStorage.d.ts +1 -1
- package/dist/samples/SampleStorage.d.ts.map +1 -1
- package/dist/samples/SampleStorage.js +1 -1
- package/dist/soundfont/DefaultSoundfontLoader.d.ts +2 -1
- package/dist/soundfont/DefaultSoundfontLoader.d.ts.map +1 -1
- package/dist/soundfont/DefaultSoundfontLoader.js +14 -4
- package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts +2 -1
- package/dist/soundfont/DefaultSoundfontLoaderManager.d.ts.map +1 -1
- package/dist/soundfont/DefaultSoundfontLoaderManager.js +1 -0
- package/dist/soundfont/OpenSoundfontAPI.d.ts.map +1 -1
- package/dist/soundfont/OpenSoundfontAPI.js +6 -4
- package/dist/soundfont/SoundfontService.d.ts +5 -2
- package/dist/soundfont/SoundfontService.d.ts.map +1 -1
- package/dist/soundfont/SoundfontService.js +18 -8
- package/dist/workers-main.js +2 -2
- package/dist/workers-main.js.map +3 -3
- package/dist/ysync/YService.d.ts.map +1 -1
- package/dist/ysync/YService.js +4 -2
- package/dist/ysync/YSync.d.ts.map +1 -1
- package/dist/ysync/YSync.js +79 -51
- package/package.json +17 -16
- package/dist/cloud/CloudBackupSoundfont.d.ts.map +0 -1
- package/dist/env.d.ts +0 -6
- package/dist/env.d.ts.map +0 -1
- package/dist/env.js +0 -9
|
@@ -6,10 +6,10 @@ import { LiveStreamBroadcaster, LiveStreamReceiver } from "@opendaw/lib-fusion";
|
|
|
6
6
|
import { ProjectEnv } from "./ProjectEnv";
|
|
7
7
|
import { Mixer } from "../Mixer";
|
|
8
8
|
import { ProjectApi } from "./ProjectApi";
|
|
9
|
-
import { CaptureDevices } from "../capture
|
|
9
|
+
import { CaptureDevices } from "../capture";
|
|
10
10
|
import { EngineFacade } from "../EngineFacade";
|
|
11
11
|
import { EngineWorklet } from "../EngineWorklet";
|
|
12
|
-
import { MIDILearning } from "../midi
|
|
12
|
+
import { MIDILearning } from "../midi";
|
|
13
13
|
export type RestartWorklet = {
|
|
14
14
|
unload: Procedure<unknown>;
|
|
15
15
|
load: Procedure<EngineWorklet>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Project.d.ts","sourceRoot":"","sources":["../../src/project/Project.ts"],"names":[],"mappings":"AAAA,OAAO,EAKH,SAAS,EAET,UAAU,EACV,eAAe,EACf,UAAU,EAEb,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAC,QAAQ,EAAE,OAAO,EAAC,MAAM,kBAAkB,CAAA;AAClD,OAAO,EACH,WAAW,EACX,YAAY,EACZ,KAAK,EAGL,OAAO,EACP,WAAW,EAEX,gBAAgB,EACnB,MAAM,uBAAuB,CAAA;A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9
|
import { ProjectMigration } from "./ProjectMigration";
|
|
10
|
-
import { CaptureDevices } from "../capture
|
|
10
|
+
import { CaptureDevices, Recording } from "../capture";
|
|
11
11
|
import { EngineFacade } from "../EngineFacade";
|
|
12
|
-
import {
|
|
13
|
-
import { MIDILearning } from "../midi/MIDILearning";
|
|
12
|
+
import { MIDILearning } from "../midi";
|
|
14
13
|
import { ProjectValidation } from "./ProjectValidation";
|
|
15
14
|
// Main Entry Point for a Project
|
|
16
15
|
export class Project {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenSampleAPI.d.ts","sourceRoot":"","sources":["../../src/samples/OpenSampleAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,SAAS,EAGT,SAAS,EACT,IAAI,EACP,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"OpenSampleAPI.d.ts","sourceRoot":"","sources":["../../src/samples/OpenSampleAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,SAAS,EAGT,SAAS,EACT,IAAI,EACP,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EAAC,SAAS,EAAE,MAAM,EAAE,cAAc,EAAC,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAA;AAK9C,qBAAa,aAAc,YAAW,SAAS;IAC3C,MAAM,CAAC,QAAQ,CAAC,OAAO,wCAAuC;IAC9D,MAAM,CAAC,QAAQ,CAAC,QAAQ,2CAA0C;IAGlE,MAAM,CAAC,GAAG,IAAI,aAAa;IAE3B,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS;IAStD,OAAO;IAED,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAKrC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAQtC,IAAI,CAAC,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAmC3G,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC/E,YAAY,IAAI,OAAO;CAC1B"}
|
|
@@ -9,7 +9,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Arrays, asDefined, DefaultObservableValue, Lazy, panic, RuntimeNotifier, tryCatch, UUID } from "@opendaw/lib-std";
|
|
11
11
|
import { network, Promises } from "@opendaw/lib-runtime";
|
|
12
|
+
import { Sample } from "@opendaw/studio-adapters";
|
|
12
13
|
import { base64Credentials, OpenDAWHeaders } from "../OpenDAWHeaders";
|
|
14
|
+
import { z } from "zod";
|
|
13
15
|
// Standard openDAW samples (considered to be non-removable)
|
|
14
16
|
export class OpenSampleAPI {
|
|
15
17
|
static ApiRoot = "https://api.opendaw.studio/samples";
|
|
@@ -25,13 +27,13 @@ export class OpenSampleAPI {
|
|
|
25
27
|
}
|
|
26
28
|
constructor() { }
|
|
27
29
|
async all() {
|
|
28
|
-
return Promises.
|
|
29
|
-
.then(x => x.json(), () => []));
|
|
30
|
+
return Promises.guardedRetry(() => fetch(`${OpenSampleAPI.ApiRoot}/list.php`, OpenDAWHeaders)
|
|
31
|
+
.then(x => x.json().then(x => z.array(Sample).parse(x)), () => []), (_error, count) => count < 10);
|
|
30
32
|
}
|
|
31
33
|
async get(uuid) {
|
|
32
34
|
const url = `${OpenSampleAPI.ApiRoot}/get.php?uuid=${UUID.toString(uuid)}`;
|
|
33
35
|
const sample = await Promises.retry(() => network.limitFetch(url, OpenDAWHeaders)
|
|
34
|
-
.then(x => x.json()))
|
|
36
|
+
.then(x => x.json().then(x => Sample.parse(x))))
|
|
35
37
|
.then(x => { if ("error" in x) {
|
|
36
38
|
return panic(x.error);
|
|
37
39
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { Procedure } from "@opendaw/lib-std";
|
|
1
|
+
import { Class, Procedure } from "@opendaw/lib-std";
|
|
2
|
+
import { Box } from "@opendaw/lib-box";
|
|
2
3
|
import { Sample } from "@opendaw/studio-adapters";
|
|
3
4
|
import { AssetService } from "../AssetService";
|
|
4
5
|
export declare class SampleService extends AssetService<Sample> {
|
|
5
6
|
readonly audioContext: AudioContext;
|
|
6
7
|
protected readonly namePlural: string;
|
|
7
8
|
protected readonly nameSingular: string;
|
|
9
|
+
protected readonly boxType: Class<Box>;
|
|
10
|
+
protected readonly filePickerOptions: FilePickerOptions;
|
|
8
11
|
constructor(audioContext: AudioContext, onUpdate: Procedure<Sample>);
|
|
9
|
-
browse(multiple: boolean): Promise<ReadonlyArray<Sample>>;
|
|
10
12
|
importFile({ uuid, name, arrayBuffer, progressHandler }: AssetService.ImportArgs): Promise<Sample>;
|
|
13
|
+
protected collectAllFiles(): Promise<ReadonlyArray<Sample>>;
|
|
11
14
|
}
|
|
12
15
|
//# sourceMappingURL=SampleService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SampleService.d.ts","sourceRoot":"","sources":["../../src/samples/SampleService.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"SampleService.d.ts","sourceRoot":"","sources":["../../src/samples/SampleService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAe,SAAS,EAAiB,MAAM,kBAAkB,CAAA;AACtF,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AAKpC,OAAO,EAAY,MAAM,EAAiB,MAAM,0BAA0B,CAAA;AAC1E,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAM5C,qBAAa,aAAc,SAAQ,YAAY,CAAC,MAAM,CAAC;IAMvC,QAAQ,CAAC,YAAY,EAAE,YAAY;IAL/C,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAY;IACjD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAW;IAClD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAe;IACrD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAiC;gBAEnE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,CAAC,MAAM,CAAC;IAItE,UAAU,CAAC,EAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,eAAgC,EAAC,EACzD,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;cAqC5C,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;CAKpE"}
|
|
@@ -2,19 +2,22 @@ import { Arrays, isUndefined, Progress, UUID } from "@opendaw/lib-std";
|
|
|
2
2
|
import { estimateBpm } from "@opendaw/lib-dsp";
|
|
3
3
|
import { Promises } from "@opendaw/lib-runtime";
|
|
4
4
|
import { SamplePeaks } from "@opendaw/lib-fusion";
|
|
5
|
-
import {
|
|
5
|
+
import { AudioFileBox } from "@opendaw/studio-boxes";
|
|
6
6
|
import { AssetService } from "../AssetService";
|
|
7
|
+
import { FilePickerAcceptTypes } from "../FilePickerAcceptTypes";
|
|
8
|
+
import { Workers } from "../Workers";
|
|
9
|
+
import { SampleStorage } from "./SampleStorage";
|
|
10
|
+
import { OpenSampleAPI } from "./OpenSampleAPI";
|
|
7
11
|
export class SampleService extends AssetService {
|
|
8
12
|
audioContext;
|
|
9
13
|
namePlural = "Samples";
|
|
10
14
|
nameSingular = "Sample";
|
|
15
|
+
boxType = AudioFileBox;
|
|
16
|
+
filePickerOptions = FilePickerAcceptTypes.WavFiles;
|
|
11
17
|
constructor(audioContext, onUpdate) {
|
|
12
18
|
super(onUpdate);
|
|
13
19
|
this.audioContext = audioContext;
|
|
14
20
|
}
|
|
15
|
-
async browse(multiple) {
|
|
16
|
-
return this.browseFiles(multiple, FilePickerAcceptTypes.WavFiles);
|
|
17
|
-
}
|
|
18
21
|
async importFile({ uuid, name, arrayBuffer, progressHandler = Progress.Empty }) {
|
|
19
22
|
console.debug(`importSample '${name}' (${arrayBuffer.byteLength >> 10}kb)`);
|
|
20
23
|
console.time("UUID.sha256");
|
|
@@ -48,4 +51,9 @@ export class SampleService extends AssetService {
|
|
|
48
51
|
this.onUpdate(sample);
|
|
49
52
|
return sample;
|
|
50
53
|
}
|
|
54
|
+
async collectAllFiles() {
|
|
55
|
+
const stock = await OpenSampleAPI.get().all();
|
|
56
|
+
const local = await SampleStorage.get().list();
|
|
57
|
+
return Arrays.merge(stock, local, (sample, { uuid }) => sample.uuid === uuid);
|
|
58
|
+
}
|
|
51
59
|
}
|
|
@@ -13,7 +13,7 @@ export declare namespace SampleStorage {
|
|
|
13
13
|
export declare class SampleStorage extends Storage<Sample, SampleMetaData, SampleStorage.NewSample, [AudioData, Peaks, SampleMetaData]> {
|
|
14
14
|
static readonly Folder = "samples/v2";
|
|
15
15
|
static get(): SampleStorage;
|
|
16
|
-
static
|
|
16
|
+
static cleanDeprecated(): Promise<void>;
|
|
17
17
|
private constructor();
|
|
18
18
|
save({ uuid, audio, peaks, meta }: SampleStorage.NewSample): Promise<void>;
|
|
19
19
|
updateSampleMeta(uuid: UUID.Bytes, meta: SampleMetaData): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SampleStorage.d.ts","sourceRoot":"","sources":["../../src/samples/SampleStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,IAAI,EAAC,MAAM,kBAAkB,CAAA;AACtE,OAAO,EAAC,KAAK,EAAc,MAAM,qBAAqB,CAAA;AACtD,OAAO,EAAC,SAAS,EAAE,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AC,GAAG,IAAI,aAAa;WAEd,eAAe;IAE5B,OAAO;IAED,IAAI,CAAC,EAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAC,EAAE,aAAa,CAAC,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;IAexE,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAKvE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC;CAgB5E"}
|
|
@@ -15,7 +15,7 @@ import { Storage } from "../Storage";
|
|
|
15
15
|
export class SampleStorage extends Storage {
|
|
16
16
|
static Folder = "samples/v2";
|
|
17
17
|
static get() { return new SampleStorage(); }
|
|
18
|
-
static async
|
|
18
|
+
static async cleanDeprecated() { Workers.Opfs.delete("samples/v1").catch(EmptyExec); }
|
|
19
19
|
constructor() { super(SampleStorage.Folder); }
|
|
20
20
|
async save({ uuid, audio, peaks, meta }) {
|
|
21
21
|
const path = `${this.folder}/${UUID.toString(uuid)}`;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Observer, Option, Subscription, UUID } from "@opendaw/lib-std";
|
|
2
2
|
import { SoundfontLoader, SoundfontLoaderState, SoundfontMetaData } from "@opendaw/studio-adapters";
|
|
3
3
|
import { DefaultSoundfontLoaderManager } from "./DefaultSoundfontLoaderManager";
|
|
4
|
-
import { SoundFont2 } from "soundfont2";
|
|
4
|
+
import type { SoundFont2 } from "soundfont2";
|
|
5
5
|
export declare class DefaultSoundfontLoader implements SoundfontLoader {
|
|
6
6
|
#private;
|
|
7
7
|
constructor(manager: DefaultSoundfontLoaderManager, uuid: UUID.Bytes);
|
|
8
8
|
subscribe(observer: Observer<SoundfontLoaderState>): Subscription;
|
|
9
|
+
invalidate(): void;
|
|
9
10
|
get uuid(): UUID.Bytes;
|
|
10
11
|
get soundfont(): Option<SoundFont2>;
|
|
11
12
|
get meta(): Option<SoundfontMetaData>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSoundfontLoader.d.ts","sourceRoot":"","sources":["../../src/soundfont/DefaultSoundfontLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,MAAM,EAAY,YAAY,EAAc,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAErG,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AACjG,OAAO,EAAC,6BAA6B,EAAC,MAAM,iCAAiC,CAAA;AAE7E,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"DefaultSoundfontLoader.d.ts","sourceRoot":"","sources":["../../src/soundfont/DefaultSoundfontLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,QAAQ,EAAE,MAAM,EAAY,YAAY,EAAc,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAErG,OAAO,EAAC,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AACjG,OAAO,EAAC,6BAA6B,EAAC,MAAM,iCAAiC,CAAA;AAE7E,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,YAAY,CAAA;AAE1C,qBAAa,sBAAuB,YAAW,eAAe;;gBAY9C,OAAO,EAAE,6BAA6B,EAAE,IAAI,EAAE,IAAI,CAAC,KAAK;IAQpE,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,oBAAoB,CAAC,GAAG,YAAY;IAQjE,UAAU,IAAI,IAAI;IAOlB,IAAI,IAAI,IAAI,IAAI,CAAC,KAAK,CAAoB;IAC1C,IAAI,SAAS,IAAI,MAAM,CAAC,UAAU,CAAC,CAAyB;IAC5D,IAAI,IAAI,IAAI,MAAM,CAAC,iBAAiB,CAAC,CAAoB;IACzD,IAAI,KAAK,IAAI,oBAAoB,CAAqB;IAEtD,QAAQ,IAAI,MAAM;CA+CrB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Notifier, Option, Terminable, UUID } from "@opendaw/lib-std";
|
|
2
2
|
import { Promises } from "@opendaw/lib-runtime";
|
|
3
3
|
import { SoundfontStorage } from "./SoundfontStorage";
|
|
4
|
-
import { SoundFont2 } from "soundfont2";
|
|
5
4
|
export class DefaultSoundfontLoader {
|
|
6
5
|
#manager;
|
|
7
6
|
#uuid;
|
|
8
7
|
#notifier;
|
|
8
|
+
#soundFont2 = Promises.memoizeAsync(() => import("soundfont2"));
|
|
9
9
|
#meta = Option.None;
|
|
10
10
|
#soundfont = Option.None;
|
|
11
11
|
#state = { type: "progress", progress: 0.0 };
|
|
@@ -22,6 +22,12 @@ export class DefaultSoundfontLoader {
|
|
|
22
22
|
}
|
|
23
23
|
return this.#notifier.subscribe(observer);
|
|
24
24
|
}
|
|
25
|
+
invalidate() {
|
|
26
|
+
this.#state = { type: "progress", progress: 0.0 };
|
|
27
|
+
this.#meta = Option.None;
|
|
28
|
+
this.#soundfont = Option.None;
|
|
29
|
+
this.#get();
|
|
30
|
+
}
|
|
25
31
|
get uuid() { return this.#uuid; }
|
|
26
32
|
get soundfont() { return this.#soundfont; }
|
|
27
33
|
get meta() { return this.#meta; }
|
|
@@ -32,8 +38,8 @@ export class DefaultSoundfontLoader {
|
|
|
32
38
|
this.#notifier.notify(this.#state);
|
|
33
39
|
}
|
|
34
40
|
#get() {
|
|
35
|
-
SoundfontStorage.get().load(this.#uuid).then(([file, meta]) => {
|
|
36
|
-
this.#soundfont = Option.wrap(
|
|
41
|
+
SoundfontStorage.get().load(this.#uuid).then(async ([file, meta]) => {
|
|
42
|
+
this.#soundfont = Option.wrap(await this.#createSoundFont2(file));
|
|
37
43
|
this.#meta = Option.wrap(meta);
|
|
38
44
|
this.#setState({ type: "loaded" });
|
|
39
45
|
}, (error) => {
|
|
@@ -57,7 +63,7 @@ export class DefaultSoundfontLoader {
|
|
|
57
63
|
const [file, meta] = fetchResult.value;
|
|
58
64
|
const storeResult = await Promises.tryCatch(SoundfontStorage.get().save({ uuid: this.#uuid, file, meta }));
|
|
59
65
|
if (storeResult.status === "resolved") {
|
|
60
|
-
this.#soundfont = Option.wrap(
|
|
66
|
+
this.#soundfont = Option.wrap(await this.#createSoundFont2(file));
|
|
61
67
|
this.#meta = Option.wrap(meta);
|
|
62
68
|
this.#setState({ type: "loaded" });
|
|
63
69
|
}
|
|
@@ -66,4 +72,8 @@ export class DefaultSoundfontLoader {
|
|
|
66
72
|
this.#setState({ type: "error", reason: "N/A" });
|
|
67
73
|
}
|
|
68
74
|
}
|
|
75
|
+
async #createSoundFont2(buffer) {
|
|
76
|
+
const { SoundFont2 } = await this.#soundFont2();
|
|
77
|
+
return new SoundFont2(new Uint8Array(buffer));
|
|
78
|
+
}
|
|
69
79
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Progress, UUID } from "@opendaw/lib-std";
|
|
2
|
-
import { SoundfontProvider } from "./SoundfontProvider";
|
|
3
2
|
import { SoundfontLoader, SoundfontLoaderManager, SoundfontMetaData } from "@opendaw/studio-adapters";
|
|
3
|
+
import { SoundfontProvider } from "./SoundfontProvider";
|
|
4
4
|
export declare class DefaultSoundfontLoaderManager implements SoundfontLoaderManager, SoundfontProvider {
|
|
5
5
|
#private;
|
|
6
6
|
constructor(provider: SoundfontProvider);
|
|
7
7
|
fetch(uuid: UUID.Bytes, progress: Progress.Handler): Promise<[ArrayBuffer, SoundfontMetaData]>;
|
|
8
8
|
remove(uuid: UUID.Bytes): void;
|
|
9
9
|
getOrCreate(uuid: UUID.Bytes): SoundfontLoader;
|
|
10
|
+
invalidate(uuid: UUID.Bytes): void;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=DefaultSoundfontLoaderManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSoundfontLoaderManager.d.ts","sourceRoot":"","sources":["../../src/soundfont/DefaultSoundfontLoaderManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAa,IAAI,EAAC,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"DefaultSoundfontLoaderManager.d.ts","sourceRoot":"","sources":["../../src/soundfont/DefaultSoundfontLoaderManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAa,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC1D,OAAO,EAAC,eAAe,EAAE,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAEnG,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAA;AAErD,qBAAa,6BAA8B,YAAW,sBAAsB,EAAE,iBAAiB;;gBAI/E,QAAQ,EAAE,iBAAiB;IAKvC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;IAI9F,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK;IAEvB,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,eAAe;IAI9C,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK;CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenSoundfontAPI.d.ts","sourceRoot":"","sources":["../../src/soundfont/OpenSoundfontAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAmB,SAAS,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EAAC,SAAS,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"OpenSoundfontAPI.d.ts","sourceRoot":"","sources":["../../src/soundfont/OpenSoundfontAPI.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAmB,SAAS,EAAE,IAAI,EAAC,MAAM,kBAAkB,CAAA;AAC7F,OAAO,EAAC,SAAS,EAAE,iBAAiB,EAAC,MAAM,0BAA0B,CAAA;AAKrE,qBAAa,gBAAgB;;IACzB,MAAM,CAAC,QAAQ,CAAC,OAAO,2CAA0C;IACjE,MAAM,CAAC,QAAQ,CAAC,QAAQ,8CAA6C;IAGrE,MAAM,CAAC,GAAG,IAAI,gBAAgB;IAW9B,OAAO;IAED,GAAG,IAAI,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;IAExC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;IAMzC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,WAAW,EAAE,iBAAiB,CAAC,CAAC;CAyB1G"}
|
|
@@ -8,18 +8,21 @@ 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
10
|
import { asDefined, Lazy, RuntimeNotifier, UUID } from "@opendaw/lib-std";
|
|
11
|
+
import { Soundfont } from "@opendaw/studio-adapters";
|
|
11
12
|
import { OpenDAWHeaders } from "../OpenDAWHeaders";
|
|
12
13
|
import { Promises } from "@opendaw/lib-runtime";
|
|
14
|
+
import { z } from "zod";
|
|
13
15
|
export class OpenSoundfontAPI {
|
|
14
16
|
static ApiRoot = "https://api.opendaw.studio/soundfonts";
|
|
15
17
|
static FileRoot = "https://assets.opendaw.studio/soundfonts";
|
|
16
18
|
static get() { return new OpenSoundfontAPI(); }
|
|
17
|
-
#memoized = Promises.memoizeAsync(() => Promises.
|
|
19
|
+
#memoized = Promises.memoizeAsync(() => Promises.guardedRetry(() => fetch(`${OpenSoundfontAPI.ApiRoot}/list.json`, OpenDAWHeaders)
|
|
18
20
|
.then(x => x.json())
|
|
21
|
+
.then(x => z.array(Soundfont).parse(x))
|
|
19
22
|
.catch(reason => RuntimeNotifier.info({
|
|
20
23
|
headline: "OpenSoundfont API",
|
|
21
24
|
message: `Could not connect to OpenSoundfont API\nReason: '${reason}'`
|
|
22
|
-
}).then(() => []))));
|
|
25
|
+
}).then(() => [])), (_error, count) => count < 10));
|
|
23
26
|
constructor() { }
|
|
24
27
|
async all() { return this.#memoized(); }
|
|
25
28
|
async get(uuid) {
|
|
@@ -32,7 +35,6 @@ export class OpenSoundfontAPI {
|
|
|
32
35
|
const url = `${OpenSoundfontAPI.FileRoot}/${soundfont.uuid}`;
|
|
33
36
|
return fetch(url, OpenDAWHeaders)
|
|
34
37
|
.then(response => {
|
|
35
|
-
const total = parseInt(response.headers.get("Content-Length") ?? "0");
|
|
36
38
|
let loaded = 0;
|
|
37
39
|
return new Promise((resolve, reject) => {
|
|
38
40
|
const reader = asDefined(response.body, "No body in response").getReader();
|
|
@@ -44,7 +46,7 @@ export class OpenSoundfontAPI {
|
|
|
44
46
|
else {
|
|
45
47
|
chunks.push(value);
|
|
46
48
|
loaded += value.length;
|
|
47
|
-
progress(
|
|
49
|
+
progress(loaded / soundfont.size);
|
|
48
50
|
reader.read().then(nextChunk, reject);
|
|
49
51
|
}
|
|
50
52
|
};
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import { Option, Procedure } from "@opendaw/lib-std";
|
|
1
|
+
import { Class, Option, Procedure } from "@opendaw/lib-std";
|
|
2
|
+
import { Box } from "@opendaw/lib-box";
|
|
2
3
|
import { Soundfont } from "@opendaw/studio-adapters";
|
|
3
4
|
import { AssetService } from "../AssetService";
|
|
4
5
|
export declare class SoundfontService extends AssetService<Soundfont> {
|
|
5
6
|
#private;
|
|
6
7
|
protected readonly namePlural: string;
|
|
7
8
|
protected readonly nameSingular: string;
|
|
9
|
+
protected readonly boxType: Class<Box>;
|
|
10
|
+
protected readonly filePickerOptions: FilePickerOptions;
|
|
8
11
|
constructor(onUpdate: Procedure<Soundfont>);
|
|
9
12
|
get local(): Option<ReadonlyArray<Soundfont>>;
|
|
10
13
|
get remote(): Option<ReadonlyArray<Soundfont>>;
|
|
11
|
-
browse(multiple?: boolean): Promise<ReadonlyArray<Soundfont>>;
|
|
12
14
|
importFile({ uuid, arrayBuffer }: AssetService.ImportArgs): Promise<Soundfont>;
|
|
15
|
+
protected collectAllFiles(): Promise<ReadonlyArray<Soundfont>>;
|
|
13
16
|
}
|
|
14
17
|
//# sourceMappingURL=SoundfontService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SoundfontService.d.ts","sourceRoot":"","sources":["../../src/soundfont/SoundfontService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAS,SAAS,
|
|
1
|
+
{"version":3,"file":"SoundfontService.d.ts","sourceRoot":"","sources":["../../src/soundfont/SoundfontService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAE,MAAM,EAAS,SAAS,EAAwB,MAAM,kBAAkB,CAAA;AAC/F,OAAO,EAAC,GAAG,EAAC,MAAM,kBAAkB,CAAA;AAGpC,OAAO,EAAC,SAAS,EAAoB,MAAM,0BAA0B,CAAA;AAIrE,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAA;AAG5C,qBAAa,gBAAiB,SAAQ,YAAY,CAAC,SAAS,CAAC;;IACzD,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAe;IACpD,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAc;IACrD,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAmB;IACzD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAuC;gBAOlF,QAAQ,EAAE,SAAS,CAAC,SAAS,CAAC;IAY1C,IAAI,KAAK,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAqB;IAClE,IAAI,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAsB;IAE9D,UAAU,CAAC,EAAC,IAAI,EAAE,WAAW,EAAC,EAAE,YAAY,CAAC,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC;cA2ClE,eAAe,IAAI,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;CAUvE"}
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { Arrays, Option, panic, RuntimeNotifier,
|
|
2
|
-
import {
|
|
1
|
+
import { Arrays, Option, panic, RuntimeNotifier, UUID } from "@opendaw/lib-std";
|
|
2
|
+
import { Promises, Wait } from "@opendaw/lib-runtime";
|
|
3
|
+
import { SoundfontFileBox } from "@opendaw/studio-boxes";
|
|
3
4
|
import { SoundfontStorage } from "./SoundfontStorage";
|
|
4
5
|
import { FilePickerAcceptTypes } from "../FilePickerAcceptTypes";
|
|
5
6
|
import { OpenSoundfontAPI } from "./OpenSoundfontAPI";
|
|
6
7
|
import { AssetService } from "../AssetService";
|
|
7
|
-
import { Wait } from "@opendaw/lib-runtime";
|
|
8
8
|
export class SoundfontService extends AssetService {
|
|
9
9
|
namePlural = "Soundfonts";
|
|
10
10
|
nameSingular = "Soundfont";
|
|
11
|
+
boxType = SoundfontFileBox;
|
|
12
|
+
filePickerOptions = FilePickerAcceptTypes.SoundfontFiles;
|
|
13
|
+
#soundFont2 = Promises.memoizeAsync(() => import("soundfont2"));
|
|
11
14
|
#local = Option.None;
|
|
12
15
|
#remote = Option.None;
|
|
13
16
|
constructor(onUpdate) {
|
|
@@ -22,9 +25,6 @@ export class SoundfontService extends AssetService {
|
|
|
22
25
|
}
|
|
23
26
|
get local() { return this.#local; }
|
|
24
27
|
get remote() { return this.#remote; }
|
|
25
|
-
async browse(multiple = false) {
|
|
26
|
-
return this.browseFiles(multiple, FilePickerAcceptTypes.SoundfontFiles);
|
|
27
|
-
}
|
|
28
28
|
async importFile({ uuid, arrayBuffer }) {
|
|
29
29
|
if (this.#local.isEmpty()) {
|
|
30
30
|
return panic("Local soundfont storage has not been read.");
|
|
@@ -44,14 +44,15 @@ export class SoundfontService extends AssetService {
|
|
|
44
44
|
uuid ??= await UUID.sha256(arrayBuffer);
|
|
45
45
|
console.timeEnd("UUID.sha256");
|
|
46
46
|
console.time("SoundFont2");
|
|
47
|
-
const { status, value: soundFont2, error } = tryCatch((
|
|
47
|
+
const { status, value: soundFont2, error } = await Promises.tryCatch(this.#createSoundFont2(arrayBuffer));
|
|
48
48
|
console.timeEnd("SoundFont2");
|
|
49
|
-
if (status === "
|
|
49
|
+
if (status === "rejected") {
|
|
50
50
|
updater.terminate();
|
|
51
51
|
return panic(error);
|
|
52
52
|
}
|
|
53
53
|
const meta = {
|
|
54
54
|
name: soundFont2.metaData.name,
|
|
55
|
+
size: arrayBuffer.byteLength,
|
|
55
56
|
url: "unknown",
|
|
56
57
|
license: soundFont2.metaData.copyright ?? "No license provided",
|
|
57
58
|
origin: "import"
|
|
@@ -66,4 +67,13 @@ export class SoundfontService extends AssetService {
|
|
|
66
67
|
updater.terminate();
|
|
67
68
|
return soundfont;
|
|
68
69
|
}
|
|
70
|
+
async collectAllFiles() {
|
|
71
|
+
const stock = await OpenSoundfontAPI.get().all();
|
|
72
|
+
const local = await SoundfontStorage.get().list();
|
|
73
|
+
return Arrays.merge(stock, local, (a, b) => a.uuid === b.uuid);
|
|
74
|
+
}
|
|
75
|
+
async #createSoundFont2(buffer) {
|
|
76
|
+
const { SoundFont2 } = await this.#soundFont2();
|
|
77
|
+
return new SoundFont2(new Uint8Array(buffer));
|
|
78
|
+
}
|
|
69
79
|
}
|