smplr 0.10.3 → 0.11.1
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/README.md +30 -3
- package/dist/index.d.mts +73 -36
- package/dist/index.d.ts +73 -36
- package/dist/index.js +90 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -48
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -68,7 +68,7 @@ You can import directly from the browser. For example:
|
|
|
68
68
|
<button id="btn">play</button>
|
|
69
69
|
</body>
|
|
70
70
|
<script type="module">
|
|
71
|
-
import { SplendidGrandPiano } from "https://unpkg.com/smplr
|
|
71
|
+
import { SplendidGrandPiano } from "https://unpkg.com/smplr/dist/index.mjs"; // needs to be a url
|
|
72
72
|
const context = new AudioContext(); // create the audio context
|
|
73
73
|
const marimba = new SplendidGrandPiano(context); // create and load the instrument
|
|
74
74
|
|
|
@@ -114,6 +114,18 @@ const piano = await new SplendidGrandPiano(context).load;
|
|
|
114
114
|
|
|
115
115
|
⚠️ In versions lower than 0.8.0 a `loaded()` function was exposed instead.
|
|
116
116
|
|
|
117
|
+
#### Shared configuration options
|
|
118
|
+
|
|
119
|
+
All instruments share some configuration options that are passed as second argument of the constructor. As it name implies, all fields are optional:
|
|
120
|
+
|
|
121
|
+
- `volume`: A number from 0 to 127 representing the instrument global volume. 100 by default
|
|
122
|
+
- `destination`: An `AudioNode` that is the output of the instrument. `AudioContext.destination` is used by default
|
|
123
|
+
- `volumeToGain`: a function to convert the volume to gain. It uses MIDI standard as default.
|
|
124
|
+
- `scheduleLookaheadMs`: the lookahead of the scheduler. If the start time of the note is less than current time plus this lookahead time, the note will be started. 200ms by default.
|
|
125
|
+
- `scheduleIntervalMs`: the interval of the scheduler. 50ms by default.
|
|
126
|
+
- `onStart`: a function that is called when starting a note. It receives the note started as parameter. Bear in mind that the time this function is called is not precise, and it's determined by lookahead.
|
|
127
|
+
- `onEnded`: a function that is called when the note ends. It receives the started note as parameter.
|
|
128
|
+
|
|
117
129
|
### Play
|
|
118
130
|
|
|
119
131
|
#### Start and stop notes
|
|
@@ -190,7 +202,20 @@ piano.output.setVolume(80);
|
|
|
190
202
|
|
|
191
203
|
#### Events
|
|
192
204
|
|
|
193
|
-
|
|
205
|
+
Two events are supported `onStart` and `onEnded`. Both callbacks will receive as parameter started note.
|
|
206
|
+
|
|
207
|
+
Events can be configured globally:
|
|
208
|
+
|
|
209
|
+
```js
|
|
210
|
+
const context = new AudioContext();
|
|
211
|
+
const sampler = new Sample(context, {
|
|
212
|
+
onStart: (note) => {
|
|
213
|
+
console.log(note.time, context.currentTime);
|
|
214
|
+
},
|
|
215
|
+
});
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
or per note basis:
|
|
194
219
|
|
|
195
220
|
```js
|
|
196
221
|
piano.start({
|
|
@@ -202,7 +227,9 @@ piano.start({
|
|
|
202
227
|
});
|
|
203
228
|
```
|
|
204
229
|
|
|
205
|
-
|
|
230
|
+
Global callbacks will be invoked regardless of whether local events are defined.
|
|
231
|
+
|
|
232
|
+
⚠️ The invocation time of `onStart` is not exact. It triggers slightly before the actual start time and is influenced by the `scheduleLookaheadMs` parameter.
|
|
206
233
|
|
|
207
234
|
### Effects
|
|
208
235
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ type AudioInsert = {
|
|
|
3
3
|
output: AudioNode;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type ChannelConfig = {
|
|
7
7
|
destination: AudioNode;
|
|
8
8
|
volume: number;
|
|
9
9
|
volumeToGain: (volume: number) => number;
|
|
@@ -18,7 +18,7 @@ declare class Channel {
|
|
|
18
18
|
readonly context: BaseAudioContext;
|
|
19
19
|
readonly setVolume: (vol: number) => void;
|
|
20
20
|
readonly input: AudioNode;
|
|
21
|
-
constructor(context: BaseAudioContext, options
|
|
21
|
+
constructor(context: BaseAudioContext, options?: Partial<ChannelConfig>);
|
|
22
22
|
addInsert(effect: AudioNode | AudioInsert): void;
|
|
23
23
|
addEffect(name: string, effect: AudioNode | {
|
|
24
24
|
input: AudioNode;
|
|
@@ -27,28 +27,56 @@ declare class Channel {
|
|
|
27
27
|
disconnect(): void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
type StorageResponse = {
|
|
30
|
+
type StorageResponse$1 = {
|
|
31
31
|
readonly status: number;
|
|
32
32
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
33
33
|
json(): Promise<any>;
|
|
34
34
|
text(): Promise<string>;
|
|
35
35
|
};
|
|
36
|
-
type Storage = {
|
|
37
|
-
fetch: (url: string) => Promise<StorageResponse>;
|
|
36
|
+
type Storage$1 = {
|
|
37
|
+
fetch: (url: string) => Promise<StorageResponse$1>;
|
|
38
38
|
};
|
|
39
|
-
declare const HttpStorage: Storage;
|
|
40
|
-
declare class CacheStorage implements Storage {
|
|
39
|
+
declare const HttpStorage: Storage$1;
|
|
40
|
+
declare class CacheStorage implements Storage$1 {
|
|
41
41
|
#private;
|
|
42
42
|
constructor(name?: string);
|
|
43
|
-
fetch(url: string): Promise<StorageResponse>;
|
|
43
|
+
fetch(url: string): Promise<StorageResponse$1>;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
type AudioBuffers$1 = Record<string | number, AudioBuffer | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* A function that downloads audio into a AudioBuffers
|
|
49
|
+
*/
|
|
50
|
+
type AudioBuffersLoader$1 = (context: BaseAudioContext, buffers: AudioBuffers$1) => Promise<void>;
|
|
51
|
+
|
|
52
|
+
type StorageResponse = {
|
|
53
|
+
readonly status: number;
|
|
54
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
55
|
+
json(): Promise<any>;
|
|
56
|
+
text(): Promise<string>;
|
|
57
|
+
};
|
|
58
|
+
type Storage = {
|
|
59
|
+
fetch: (url: string) => Promise<StorageResponse>;
|
|
60
|
+
};
|
|
61
|
+
|
|
46
62
|
type AudioBuffers = Record<string | number, AudioBuffer | undefined>;
|
|
47
63
|
/**
|
|
48
64
|
* A function that downloads audio into a AudioBuffers
|
|
49
65
|
*/
|
|
50
66
|
type AudioBuffersLoader = (context: BaseAudioContext, buffers: AudioBuffers) => Promise<void>;
|
|
51
67
|
|
|
68
|
+
type SamplerConfig$1 = {
|
|
69
|
+
storage?: Storage;
|
|
70
|
+
detune: number;
|
|
71
|
+
volume: number;
|
|
72
|
+
velocity: number;
|
|
73
|
+
decayTime?: number;
|
|
74
|
+
lpfCutoffHz?: number;
|
|
75
|
+
destination: AudioNode;
|
|
76
|
+
buffers: Record<string | number, string | AudioBuffers> | AudioBuffersLoader;
|
|
77
|
+
volumeToGain: (volume: number) => number;
|
|
78
|
+
};
|
|
79
|
+
|
|
52
80
|
/**
|
|
53
81
|
* A function to unsubscribe from an event or control
|
|
54
82
|
*/
|
|
@@ -66,7 +94,7 @@ type Subscribe<T> = (listener: Listener<T>) => Unsubscribe;
|
|
|
66
94
|
* @private
|
|
67
95
|
*/
|
|
68
96
|
type InternalPlayer = {
|
|
69
|
-
readonly buffers: AudioBuffers;
|
|
97
|
+
readonly buffers: AudioBuffers$1;
|
|
70
98
|
readonly context: BaseAudioContext;
|
|
71
99
|
start(sample: SampleStart): (time?: number) => void;
|
|
72
100
|
stop(sample?: SampleStop): void;
|
|
@@ -91,6 +119,7 @@ type SampleStart = {
|
|
|
91
119
|
name?: string;
|
|
92
120
|
note: string | number;
|
|
93
121
|
onEnded?: (sample: SampleStart) => void;
|
|
122
|
+
onStart?: (sample: SampleStart) => void;
|
|
94
123
|
stop?: Subscribe<number>;
|
|
95
124
|
stopId?: string | number;
|
|
96
125
|
time?: number;
|
|
@@ -185,17 +214,28 @@ type RegionGroup = {
|
|
|
185
214
|
sample: Partial<SampleOptions>;
|
|
186
215
|
};
|
|
187
216
|
|
|
217
|
+
type QueuedPlayerConfig = {
|
|
218
|
+
scheduleLookaheadMs: number;
|
|
219
|
+
scheduleIntervalMs: number;
|
|
220
|
+
onStart?: (sample: SampleStart) => void;
|
|
221
|
+
onEnded?: (sample: SampleStart) => void;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type DefaultPlayerConfig = ChannelConfig & SamplerConfig$1 & QueuedPlayerConfig;
|
|
225
|
+
|
|
188
226
|
declare function getDrumMachineNames(): string[];
|
|
189
|
-
type DrumMachineConfig =
|
|
227
|
+
type DrumMachineConfig = {
|
|
190
228
|
instrument: string;
|
|
191
|
-
|
|
229
|
+
url: string;
|
|
230
|
+
storage: Storage$1;
|
|
192
231
|
};
|
|
232
|
+
type DrumMachineOptions = Partial<DrumMachineConfig & DefaultPlayerConfig>;
|
|
193
233
|
declare class DrumMachine {
|
|
194
234
|
#private;
|
|
195
235
|
private readonly player;
|
|
196
236
|
readonly load: Promise<this>;
|
|
197
237
|
readonly output: OutputChannel;
|
|
198
|
-
constructor(context: AudioContext, options?:
|
|
238
|
+
constructor(context: AudioContext, options?: DrumMachineOptions);
|
|
199
239
|
loaded(): Promise<this>;
|
|
200
240
|
get sampleNames(): string[];
|
|
201
241
|
getVariations(name: string): string[];
|
|
@@ -277,7 +317,7 @@ type WebsfzRegion = {
|
|
|
277
317
|
*/
|
|
278
318
|
type SfzSamplerConfig = {
|
|
279
319
|
instrument: SfzInstrument | Websfz | string;
|
|
280
|
-
storage?: Storage;
|
|
320
|
+
storage?: Storage$1;
|
|
281
321
|
destination: AudioNode;
|
|
282
322
|
volume: number;
|
|
283
323
|
velocity: number;
|
|
@@ -291,7 +331,7 @@ declare class SfzSampler {
|
|
|
291
331
|
readonly options: Readonly<Partial<SfzSamplerConfig>>;
|
|
292
332
|
private readonly player;
|
|
293
333
|
readonly load: Promise<this>;
|
|
294
|
-
constructor(context: AudioContext, options: Partial<SfzSamplerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
334
|
+
constructor(context: AudioContext, options: Partial<SfzSamplerConfig & DefaultPlayerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
295
335
|
get output(): OutputChannel;
|
|
296
336
|
loaded(): Promise<this>;
|
|
297
337
|
start(sample: SampleStart | string | number): void;
|
|
@@ -310,12 +350,12 @@ declare class ElectricPiano extends SfzSampler {
|
|
|
310
350
|
}
|
|
311
351
|
|
|
312
352
|
declare function getVersilianInstruments(): Promise<string[]>;
|
|
313
|
-
declare function VcslInstrumentLoader(instrument: string, buffers: AudioBuffers, group: RegionGroup): (context: BaseAudioContext, storage: Storage) => Promise<void[]>;
|
|
353
|
+
declare function VcslInstrumentLoader(instrument: string, buffers: AudioBuffers$1, group: RegionGroup): (context: BaseAudioContext, storage: Storage$1) => Promise<void[]>;
|
|
314
354
|
type VersilianConfig = {
|
|
315
355
|
instrument: string;
|
|
316
|
-
storage: Storage;
|
|
356
|
+
storage: Storage$1;
|
|
317
357
|
};
|
|
318
|
-
type VersilianOptions = Partial<VersilianConfig &
|
|
358
|
+
type VersilianOptions = Partial<VersilianConfig & DefaultPlayerConfig>;
|
|
319
359
|
/**
|
|
320
360
|
* Versilian
|
|
321
361
|
*
|
|
@@ -328,7 +368,7 @@ declare class Versilian implements InternalPlayer {
|
|
|
328
368
|
private config;
|
|
329
369
|
constructor(context: BaseAudioContext, options?: VersilianOptions);
|
|
330
370
|
get output(): OutputChannel;
|
|
331
|
-
get buffers(): AudioBuffers;
|
|
371
|
+
get buffers(): AudioBuffers$1;
|
|
332
372
|
get context(): BaseAudioContext;
|
|
333
373
|
start(sample: SampleStart | string | number): (time?: number | undefined) => void;
|
|
334
374
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -344,9 +384,9 @@ declare const NAME_TO_PATH: Record<string, string | undefined>;
|
|
|
344
384
|
declare function getMellotronNames(): string[];
|
|
345
385
|
type MellotronConfig = {
|
|
346
386
|
instrument: string;
|
|
347
|
-
storage: Storage;
|
|
387
|
+
storage: Storage$1;
|
|
348
388
|
};
|
|
349
|
-
type MellotronOptions = Partial<
|
|
389
|
+
type MellotronOptions = Partial<MellotronConfig & DefaultPlayerConfig>;
|
|
350
390
|
declare class Mellotron implements InternalPlayer {
|
|
351
391
|
readonly context: BaseAudioContext;
|
|
352
392
|
private readonly config;
|
|
@@ -354,7 +394,7 @@ declare class Mellotron implements InternalPlayer {
|
|
|
354
394
|
private readonly group;
|
|
355
395
|
readonly load: Promise<this>;
|
|
356
396
|
constructor(context: BaseAudioContext, options: MellotronOptions);
|
|
357
|
-
get buffers(): AudioBuffers;
|
|
397
|
+
get buffers(): AudioBuffers$1;
|
|
358
398
|
get output(): OutputChannel;
|
|
359
399
|
start(sample: SampleStart | string | number): (time?: number | undefined) => void;
|
|
360
400
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -374,14 +414,14 @@ declare class Reverb {
|
|
|
374
414
|
}
|
|
375
415
|
|
|
376
416
|
type SamplerConfig = {
|
|
377
|
-
storage?: Storage;
|
|
417
|
+
storage?: Storage$1;
|
|
378
418
|
detune: number;
|
|
379
419
|
volume: number;
|
|
380
420
|
velocity: number;
|
|
381
421
|
decayTime?: number;
|
|
382
422
|
lpfCutoffHz?: number;
|
|
383
423
|
destination: AudioNode;
|
|
384
|
-
buffers: Record<string | number, string | AudioBuffers> | AudioBuffersLoader;
|
|
424
|
+
buffers: Record<string | number, string | AudioBuffers$1> | AudioBuffersLoader$1;
|
|
385
425
|
volumeToGain: (volume: number) => number;
|
|
386
426
|
};
|
|
387
427
|
/**
|
|
@@ -405,9 +445,9 @@ declare class Sampler {
|
|
|
405
445
|
declare function getSmolkenNames(): string[];
|
|
406
446
|
type SmolkenConfig = {
|
|
407
447
|
instrument: string;
|
|
408
|
-
storage: Storage;
|
|
448
|
+
storage: Storage$1;
|
|
409
449
|
};
|
|
410
|
-
type SmolkenOptions = Partial<SmolkenConfig &
|
|
450
|
+
type SmolkenOptions = Partial<SmolkenConfig & DefaultPlayerConfig>;
|
|
411
451
|
declare class Smolken implements InternalPlayer {
|
|
412
452
|
private readonly player;
|
|
413
453
|
private readonly group;
|
|
@@ -416,7 +456,7 @@ declare class Smolken implements InternalPlayer {
|
|
|
416
456
|
private seqNum;
|
|
417
457
|
constructor(context: BaseAudioContext, options?: SmolkenOptions);
|
|
418
458
|
get output(): OutputChannel;
|
|
419
|
-
get buffers(): AudioBuffers;
|
|
459
|
+
get buffers(): AudioBuffers$1;
|
|
420
460
|
get context(): BaseAudioContext;
|
|
421
461
|
start(sample: SampleStart | string | number): (time?: number) => void;
|
|
422
462
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -429,12 +469,12 @@ type SoundfontConfig = {
|
|
|
429
469
|
kit: "FluidR3_GM" | "MusyngKite" | string;
|
|
430
470
|
instrument?: string;
|
|
431
471
|
instrumentUrl: string;
|
|
432
|
-
storage: Storage;
|
|
472
|
+
storage: Storage$1;
|
|
433
473
|
extraGain: number;
|
|
434
474
|
loadLoopData: boolean;
|
|
435
475
|
loopDataUrl?: string;
|
|
436
476
|
};
|
|
437
|
-
type SoundfontOptions = Partial<SoundfontConfig &
|
|
477
|
+
type SoundfontOptions = Partial<SoundfontConfig & DefaultPlayerConfig>;
|
|
438
478
|
declare class Soundfont {
|
|
439
479
|
#private;
|
|
440
480
|
readonly context: AudioContext;
|
|
@@ -456,14 +496,11 @@ declare class Soundfont {
|
|
|
456
496
|
*/
|
|
457
497
|
type SplendidGrandPianoConfig = {
|
|
458
498
|
baseUrl: string;
|
|
459
|
-
|
|
460
|
-
storage: Storage;
|
|
499
|
+
storage: Storage$1;
|
|
461
500
|
detune: number;
|
|
462
|
-
volume: number;
|
|
463
501
|
velocity: number;
|
|
464
|
-
decayTime
|
|
465
|
-
|
|
466
|
-
};
|
|
502
|
+
decayTime: number;
|
|
503
|
+
} & Partial<DefaultPlayerConfig>;
|
|
467
504
|
declare class SplendidGrandPiano {
|
|
468
505
|
#private;
|
|
469
506
|
readonly context: AudioContext;
|
|
@@ -472,7 +509,7 @@ declare class SplendidGrandPiano {
|
|
|
472
509
|
readonly load: Promise<this>;
|
|
473
510
|
constructor(context: AudioContext, options?: Partial<SplendidGrandPianoConfig>);
|
|
474
511
|
get output(): OutputChannel;
|
|
475
|
-
get buffers(): AudioBuffers;
|
|
512
|
+
get buffers(): AudioBuffers$1;
|
|
476
513
|
loaded(): Promise<this>;
|
|
477
514
|
start(sampleOrNote: SampleStart | number | string): (time?: number | undefined) => void;
|
|
478
515
|
stop(sample?: SampleStop | number | string): void;
|
|
@@ -489,4 +526,4 @@ declare const LAYERS: ({
|
|
|
489
526
|
cutoff?: undefined;
|
|
490
527
|
})[];
|
|
491
528
|
|
|
492
|
-
export { CacheStorage, DrumMachine,
|
|
529
|
+
export { CacheStorage, DrumMachine, DrumMachineOptions, ElectricPiano, HttpStorage, LAYERS, Mallet, Mellotron, MellotronConfig, MellotronOptions, NAME_TO_PATH, Reverb, Sampler, SamplerConfig, Smolken, SmolkenConfig, SmolkenOptions, Soundfont, SoundfontOptions, SplendidGrandPiano, SplendidGrandPianoConfig, Storage$1 as Storage, StorageResponse$1 as StorageResponse, VcslInstrumentLoader, Versilian, VersilianConfig, VersilianOptions, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ type AudioInsert = {
|
|
|
3
3
|
output: AudioNode;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
type
|
|
6
|
+
type ChannelConfig = {
|
|
7
7
|
destination: AudioNode;
|
|
8
8
|
volume: number;
|
|
9
9
|
volumeToGain: (volume: number) => number;
|
|
@@ -18,7 +18,7 @@ declare class Channel {
|
|
|
18
18
|
readonly context: BaseAudioContext;
|
|
19
19
|
readonly setVolume: (vol: number) => void;
|
|
20
20
|
readonly input: AudioNode;
|
|
21
|
-
constructor(context: BaseAudioContext, options
|
|
21
|
+
constructor(context: BaseAudioContext, options?: Partial<ChannelConfig>);
|
|
22
22
|
addInsert(effect: AudioNode | AudioInsert): void;
|
|
23
23
|
addEffect(name: string, effect: AudioNode | {
|
|
24
24
|
input: AudioNode;
|
|
@@ -27,28 +27,56 @@ declare class Channel {
|
|
|
27
27
|
disconnect(): void;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
type StorageResponse = {
|
|
30
|
+
type StorageResponse$1 = {
|
|
31
31
|
readonly status: number;
|
|
32
32
|
arrayBuffer(): Promise<ArrayBuffer>;
|
|
33
33
|
json(): Promise<any>;
|
|
34
34
|
text(): Promise<string>;
|
|
35
35
|
};
|
|
36
|
-
type Storage = {
|
|
37
|
-
fetch: (url: string) => Promise<StorageResponse>;
|
|
36
|
+
type Storage$1 = {
|
|
37
|
+
fetch: (url: string) => Promise<StorageResponse$1>;
|
|
38
38
|
};
|
|
39
|
-
declare const HttpStorage: Storage;
|
|
40
|
-
declare class CacheStorage implements Storage {
|
|
39
|
+
declare const HttpStorage: Storage$1;
|
|
40
|
+
declare class CacheStorage implements Storage$1 {
|
|
41
41
|
#private;
|
|
42
42
|
constructor(name?: string);
|
|
43
|
-
fetch(url: string): Promise<StorageResponse>;
|
|
43
|
+
fetch(url: string): Promise<StorageResponse$1>;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
type AudioBuffers$1 = Record<string | number, AudioBuffer | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* A function that downloads audio into a AudioBuffers
|
|
49
|
+
*/
|
|
50
|
+
type AudioBuffersLoader$1 = (context: BaseAudioContext, buffers: AudioBuffers$1) => Promise<void>;
|
|
51
|
+
|
|
52
|
+
type StorageResponse = {
|
|
53
|
+
readonly status: number;
|
|
54
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
55
|
+
json(): Promise<any>;
|
|
56
|
+
text(): Promise<string>;
|
|
57
|
+
};
|
|
58
|
+
type Storage = {
|
|
59
|
+
fetch: (url: string) => Promise<StorageResponse>;
|
|
60
|
+
};
|
|
61
|
+
|
|
46
62
|
type AudioBuffers = Record<string | number, AudioBuffer | undefined>;
|
|
47
63
|
/**
|
|
48
64
|
* A function that downloads audio into a AudioBuffers
|
|
49
65
|
*/
|
|
50
66
|
type AudioBuffersLoader = (context: BaseAudioContext, buffers: AudioBuffers) => Promise<void>;
|
|
51
67
|
|
|
68
|
+
type SamplerConfig$1 = {
|
|
69
|
+
storage?: Storage;
|
|
70
|
+
detune: number;
|
|
71
|
+
volume: number;
|
|
72
|
+
velocity: number;
|
|
73
|
+
decayTime?: number;
|
|
74
|
+
lpfCutoffHz?: number;
|
|
75
|
+
destination: AudioNode;
|
|
76
|
+
buffers: Record<string | number, string | AudioBuffers> | AudioBuffersLoader;
|
|
77
|
+
volumeToGain: (volume: number) => number;
|
|
78
|
+
};
|
|
79
|
+
|
|
52
80
|
/**
|
|
53
81
|
* A function to unsubscribe from an event or control
|
|
54
82
|
*/
|
|
@@ -66,7 +94,7 @@ type Subscribe<T> = (listener: Listener<T>) => Unsubscribe;
|
|
|
66
94
|
* @private
|
|
67
95
|
*/
|
|
68
96
|
type InternalPlayer = {
|
|
69
|
-
readonly buffers: AudioBuffers;
|
|
97
|
+
readonly buffers: AudioBuffers$1;
|
|
70
98
|
readonly context: BaseAudioContext;
|
|
71
99
|
start(sample: SampleStart): (time?: number) => void;
|
|
72
100
|
stop(sample?: SampleStop): void;
|
|
@@ -91,6 +119,7 @@ type SampleStart = {
|
|
|
91
119
|
name?: string;
|
|
92
120
|
note: string | number;
|
|
93
121
|
onEnded?: (sample: SampleStart) => void;
|
|
122
|
+
onStart?: (sample: SampleStart) => void;
|
|
94
123
|
stop?: Subscribe<number>;
|
|
95
124
|
stopId?: string | number;
|
|
96
125
|
time?: number;
|
|
@@ -185,17 +214,28 @@ type RegionGroup = {
|
|
|
185
214
|
sample: Partial<SampleOptions>;
|
|
186
215
|
};
|
|
187
216
|
|
|
217
|
+
type QueuedPlayerConfig = {
|
|
218
|
+
scheduleLookaheadMs: number;
|
|
219
|
+
scheduleIntervalMs: number;
|
|
220
|
+
onStart?: (sample: SampleStart) => void;
|
|
221
|
+
onEnded?: (sample: SampleStart) => void;
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
type DefaultPlayerConfig = ChannelConfig & SamplerConfig$1 & QueuedPlayerConfig;
|
|
225
|
+
|
|
188
226
|
declare function getDrumMachineNames(): string[];
|
|
189
|
-
type DrumMachineConfig =
|
|
227
|
+
type DrumMachineConfig = {
|
|
190
228
|
instrument: string;
|
|
191
|
-
|
|
229
|
+
url: string;
|
|
230
|
+
storage: Storage$1;
|
|
192
231
|
};
|
|
232
|
+
type DrumMachineOptions = Partial<DrumMachineConfig & DefaultPlayerConfig>;
|
|
193
233
|
declare class DrumMachine {
|
|
194
234
|
#private;
|
|
195
235
|
private readonly player;
|
|
196
236
|
readonly load: Promise<this>;
|
|
197
237
|
readonly output: OutputChannel;
|
|
198
|
-
constructor(context: AudioContext, options?:
|
|
238
|
+
constructor(context: AudioContext, options?: DrumMachineOptions);
|
|
199
239
|
loaded(): Promise<this>;
|
|
200
240
|
get sampleNames(): string[];
|
|
201
241
|
getVariations(name: string): string[];
|
|
@@ -277,7 +317,7 @@ type WebsfzRegion = {
|
|
|
277
317
|
*/
|
|
278
318
|
type SfzSamplerConfig = {
|
|
279
319
|
instrument: SfzInstrument | Websfz | string;
|
|
280
|
-
storage?: Storage;
|
|
320
|
+
storage?: Storage$1;
|
|
281
321
|
destination: AudioNode;
|
|
282
322
|
volume: number;
|
|
283
323
|
velocity: number;
|
|
@@ -291,7 +331,7 @@ declare class SfzSampler {
|
|
|
291
331
|
readonly options: Readonly<Partial<SfzSamplerConfig>>;
|
|
292
332
|
private readonly player;
|
|
293
333
|
readonly load: Promise<this>;
|
|
294
|
-
constructor(context: AudioContext, options: Partial<SfzSamplerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
334
|
+
constructor(context: AudioContext, options: Partial<SfzSamplerConfig & DefaultPlayerConfig> & Pick<SfzSamplerConfig, "instrument">);
|
|
295
335
|
get output(): OutputChannel;
|
|
296
336
|
loaded(): Promise<this>;
|
|
297
337
|
start(sample: SampleStart | string | number): void;
|
|
@@ -310,12 +350,12 @@ declare class ElectricPiano extends SfzSampler {
|
|
|
310
350
|
}
|
|
311
351
|
|
|
312
352
|
declare function getVersilianInstruments(): Promise<string[]>;
|
|
313
|
-
declare function VcslInstrumentLoader(instrument: string, buffers: AudioBuffers, group: RegionGroup): (context: BaseAudioContext, storage: Storage) => Promise<void[]>;
|
|
353
|
+
declare function VcslInstrumentLoader(instrument: string, buffers: AudioBuffers$1, group: RegionGroup): (context: BaseAudioContext, storage: Storage$1) => Promise<void[]>;
|
|
314
354
|
type VersilianConfig = {
|
|
315
355
|
instrument: string;
|
|
316
|
-
storage: Storage;
|
|
356
|
+
storage: Storage$1;
|
|
317
357
|
};
|
|
318
|
-
type VersilianOptions = Partial<VersilianConfig &
|
|
358
|
+
type VersilianOptions = Partial<VersilianConfig & DefaultPlayerConfig>;
|
|
319
359
|
/**
|
|
320
360
|
* Versilian
|
|
321
361
|
*
|
|
@@ -328,7 +368,7 @@ declare class Versilian implements InternalPlayer {
|
|
|
328
368
|
private config;
|
|
329
369
|
constructor(context: BaseAudioContext, options?: VersilianOptions);
|
|
330
370
|
get output(): OutputChannel;
|
|
331
|
-
get buffers(): AudioBuffers;
|
|
371
|
+
get buffers(): AudioBuffers$1;
|
|
332
372
|
get context(): BaseAudioContext;
|
|
333
373
|
start(sample: SampleStart | string | number): (time?: number | undefined) => void;
|
|
334
374
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -344,9 +384,9 @@ declare const NAME_TO_PATH: Record<string, string | undefined>;
|
|
|
344
384
|
declare function getMellotronNames(): string[];
|
|
345
385
|
type MellotronConfig = {
|
|
346
386
|
instrument: string;
|
|
347
|
-
storage: Storage;
|
|
387
|
+
storage: Storage$1;
|
|
348
388
|
};
|
|
349
|
-
type MellotronOptions = Partial<
|
|
389
|
+
type MellotronOptions = Partial<MellotronConfig & DefaultPlayerConfig>;
|
|
350
390
|
declare class Mellotron implements InternalPlayer {
|
|
351
391
|
readonly context: BaseAudioContext;
|
|
352
392
|
private readonly config;
|
|
@@ -354,7 +394,7 @@ declare class Mellotron implements InternalPlayer {
|
|
|
354
394
|
private readonly group;
|
|
355
395
|
readonly load: Promise<this>;
|
|
356
396
|
constructor(context: BaseAudioContext, options: MellotronOptions);
|
|
357
|
-
get buffers(): AudioBuffers;
|
|
397
|
+
get buffers(): AudioBuffers$1;
|
|
358
398
|
get output(): OutputChannel;
|
|
359
399
|
start(sample: SampleStart | string | number): (time?: number | undefined) => void;
|
|
360
400
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -374,14 +414,14 @@ declare class Reverb {
|
|
|
374
414
|
}
|
|
375
415
|
|
|
376
416
|
type SamplerConfig = {
|
|
377
|
-
storage?: Storage;
|
|
417
|
+
storage?: Storage$1;
|
|
378
418
|
detune: number;
|
|
379
419
|
volume: number;
|
|
380
420
|
velocity: number;
|
|
381
421
|
decayTime?: number;
|
|
382
422
|
lpfCutoffHz?: number;
|
|
383
423
|
destination: AudioNode;
|
|
384
|
-
buffers: Record<string | number, string | AudioBuffers> | AudioBuffersLoader;
|
|
424
|
+
buffers: Record<string | number, string | AudioBuffers$1> | AudioBuffersLoader$1;
|
|
385
425
|
volumeToGain: (volume: number) => number;
|
|
386
426
|
};
|
|
387
427
|
/**
|
|
@@ -405,9 +445,9 @@ declare class Sampler {
|
|
|
405
445
|
declare function getSmolkenNames(): string[];
|
|
406
446
|
type SmolkenConfig = {
|
|
407
447
|
instrument: string;
|
|
408
|
-
storage: Storage;
|
|
448
|
+
storage: Storage$1;
|
|
409
449
|
};
|
|
410
|
-
type SmolkenOptions = Partial<SmolkenConfig &
|
|
450
|
+
type SmolkenOptions = Partial<SmolkenConfig & DefaultPlayerConfig>;
|
|
411
451
|
declare class Smolken implements InternalPlayer {
|
|
412
452
|
private readonly player;
|
|
413
453
|
private readonly group;
|
|
@@ -416,7 +456,7 @@ declare class Smolken implements InternalPlayer {
|
|
|
416
456
|
private seqNum;
|
|
417
457
|
constructor(context: BaseAudioContext, options?: SmolkenOptions);
|
|
418
458
|
get output(): OutputChannel;
|
|
419
|
-
get buffers(): AudioBuffers;
|
|
459
|
+
get buffers(): AudioBuffers$1;
|
|
420
460
|
get context(): BaseAudioContext;
|
|
421
461
|
start(sample: SampleStart | string | number): (time?: number) => void;
|
|
422
462
|
stop(sample?: SampleStop | string | number): void;
|
|
@@ -429,12 +469,12 @@ type SoundfontConfig = {
|
|
|
429
469
|
kit: "FluidR3_GM" | "MusyngKite" | string;
|
|
430
470
|
instrument?: string;
|
|
431
471
|
instrumentUrl: string;
|
|
432
|
-
storage: Storage;
|
|
472
|
+
storage: Storage$1;
|
|
433
473
|
extraGain: number;
|
|
434
474
|
loadLoopData: boolean;
|
|
435
475
|
loopDataUrl?: string;
|
|
436
476
|
};
|
|
437
|
-
type SoundfontOptions = Partial<SoundfontConfig &
|
|
477
|
+
type SoundfontOptions = Partial<SoundfontConfig & DefaultPlayerConfig>;
|
|
438
478
|
declare class Soundfont {
|
|
439
479
|
#private;
|
|
440
480
|
readonly context: AudioContext;
|
|
@@ -456,14 +496,11 @@ declare class Soundfont {
|
|
|
456
496
|
*/
|
|
457
497
|
type SplendidGrandPianoConfig = {
|
|
458
498
|
baseUrl: string;
|
|
459
|
-
|
|
460
|
-
storage: Storage;
|
|
499
|
+
storage: Storage$1;
|
|
461
500
|
detune: number;
|
|
462
|
-
volume: number;
|
|
463
501
|
velocity: number;
|
|
464
|
-
decayTime
|
|
465
|
-
|
|
466
|
-
};
|
|
502
|
+
decayTime: number;
|
|
503
|
+
} & Partial<DefaultPlayerConfig>;
|
|
467
504
|
declare class SplendidGrandPiano {
|
|
468
505
|
#private;
|
|
469
506
|
readonly context: AudioContext;
|
|
@@ -472,7 +509,7 @@ declare class SplendidGrandPiano {
|
|
|
472
509
|
readonly load: Promise<this>;
|
|
473
510
|
constructor(context: AudioContext, options?: Partial<SplendidGrandPianoConfig>);
|
|
474
511
|
get output(): OutputChannel;
|
|
475
|
-
get buffers(): AudioBuffers;
|
|
512
|
+
get buffers(): AudioBuffers$1;
|
|
476
513
|
loaded(): Promise<this>;
|
|
477
514
|
start(sampleOrNote: SampleStart | number | string): (time?: number | undefined) => void;
|
|
478
515
|
stop(sample?: SampleStop | number | string): void;
|
|
@@ -489,4 +526,4 @@ declare const LAYERS: ({
|
|
|
489
526
|
cutoff?: undefined;
|
|
490
527
|
})[];
|
|
491
528
|
|
|
492
|
-
export { CacheStorage, DrumMachine,
|
|
529
|
+
export { CacheStorage, DrumMachine, DrumMachineOptions, ElectricPiano, HttpStorage, LAYERS, Mallet, Mellotron, MellotronConfig, MellotronOptions, NAME_TO_PATH, Reverb, Sampler, SamplerConfig, Smolken, SmolkenConfig, SmolkenOptions, Soundfont, SoundfontOptions, SplendidGrandPiano, SplendidGrandPianoConfig, Storage$1 as Storage, StorageResponse$1 as StorageResponse, VcslInstrumentLoader, Versilian, VersilianConfig, VersilianOptions, getDrumMachineNames, getElectricPianoNames, getMalletNames, getMellotronNames, getSmolkenNames, getSoundfontKits, getSoundfontNames, getVersilianInstruments };
|