spessasynth_core 4.4.7 → 4.4.8
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/index.d.ts +120 -41
- package/dist/index.js +292 -181
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -31,6 +31,35 @@ export interface WaveWriteOptions {
|
|
|
31
31
|
*/
|
|
32
32
|
metadata: Partial<WaveMetadata>;
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The result of reading a WAVE file with {@link wavToAudio}.
|
|
36
|
+
*
|
|
37
|
+
* @group Utilities
|
|
38
|
+
*/
|
|
39
|
+
export interface WaveReadResult {
|
|
40
|
+
/**
|
|
41
|
+
* The PCM audio data, one array per channel.
|
|
42
|
+
*/
|
|
43
|
+
audioData: Float32Array[];
|
|
44
|
+
/**
|
|
45
|
+
* The sample rate, in Hertz.
|
|
46
|
+
*/
|
|
47
|
+
sampleRate: number;
|
|
48
|
+
/**
|
|
49
|
+
* The loop of the file, undefined if it has none.
|
|
50
|
+
* The points are in sample frames, not seconds.
|
|
51
|
+
*/
|
|
52
|
+
loop?: {
|
|
53
|
+
/**
|
|
54
|
+
* The loop start, in sample frames.
|
|
55
|
+
*/
|
|
56
|
+
start: number;
|
|
57
|
+
/**
|
|
58
|
+
* The loop end, in sample frames.
|
|
59
|
+
*/
|
|
60
|
+
end: number;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
34
63
|
/**
|
|
35
64
|
* Metadata to write into a WAVE file.
|
|
36
65
|
*
|
|
@@ -148,6 +177,25 @@ declare function readVariableLengthQuantity(midiByteArray: IndexedByteArray): nu
|
|
|
148
177
|
* @group Utilities
|
|
149
178
|
*/
|
|
150
179
|
export declare function audioToWav(audioData: Float32Array[], sampleRate: number, options?: Partial<WaveWriteOptions>): ArrayBuffer;
|
|
180
|
+
/**
|
|
181
|
+
* Reads a WAVE file into PCM audio data, the counterpart of {@link audioToWav}.
|
|
182
|
+
*
|
|
183
|
+
* It reads 8, 16, 24 and 32-bit integer PCM and 32 and 64-bit float files (including `WAVE_FORMAT_EXTENSIBLE`).
|
|
184
|
+
* The loop is read from the first loop of the `smpl` chunk. Without one, the first two points of the `cue ` chunk
|
|
185
|
+
* are taken as the loop start and end, which is how {@link audioToWav} writes it.
|
|
186
|
+
* Other files may use cue points as plain markers, so such a loop is only reliable for files written by core.
|
|
187
|
+
*
|
|
188
|
+
* > **Note**
|
|
189
|
+
* >
|
|
190
|
+
* > The returned loop end is exclusive, like the SoundFont loop end.
|
|
191
|
+
*
|
|
192
|
+
* @param buffer The binary WAVE file.
|
|
193
|
+
* @returns The audio data (one array per channel), the sample rate and the loop, if the file has one.
|
|
194
|
+
* @throws Error if the file is not a valid or supported WAVE file.
|
|
195
|
+
*
|
|
196
|
+
* @group Utilities
|
|
197
|
+
*/
|
|
198
|
+
export declare function wavToAudio(buffer: ArrayBuffer): WaveReadResult;
|
|
151
199
|
/**
|
|
152
200
|
* SpessaSynth can print out additional info to the console or print nothing at all.
|
|
153
201
|
*
|
|
@@ -353,17 +401,6 @@ export interface GeneratorLimit {
|
|
|
353
401
|
* SoundFont2 NRPN scale factor for this generator type.
|
|
354
402
|
*/
|
|
355
403
|
nrpn: number;
|
|
356
|
-
/**
|
|
357
|
-
* Minimum value of this generator in a preset zone.
|
|
358
|
-
* Preset generators are offsets added to the instrument, so they can go below the instrument range.
|
|
359
|
-
* If not set, it is the same as `min`.
|
|
360
|
-
*/
|
|
361
|
-
presetMin?: number;
|
|
362
|
-
/**
|
|
363
|
-
* Maximum value of this generator in a preset zone.
|
|
364
|
-
* If not set, it is the same as `max`.
|
|
365
|
-
*/
|
|
366
|
-
presetMax?: number;
|
|
367
404
|
}
|
|
368
405
|
/**
|
|
369
406
|
* Limits and defaults for all the {@link BasicSoundBank} generator types.
|
|
@@ -524,6 +561,15 @@ export declare class ModulatorSource {
|
|
|
524
561
|
* This field specifies how the minimum value approaches the maximum value.
|
|
525
562
|
*/
|
|
526
563
|
curveType: ModulatorCurveType;
|
|
564
|
+
/**
|
|
565
|
+
* Creates a new modulator source.
|
|
566
|
+
* @param index The controller or MIDI CC number, see `isCC`.
|
|
567
|
+
* @param curveType How the minimum value approaches the maximum value.
|
|
568
|
+
* @param isCC If the index is a MIDI CC instead of a general controller.
|
|
569
|
+
* @param isBipolar If the source is bipolar (-1 to 1) instead of unipolar (0 to 1).
|
|
570
|
+
* @param isNegative If the direction of the source is flipped.
|
|
571
|
+
*/
|
|
572
|
+
constructor(index?: ModulatorSourceIndex, curveType?: ModulatorCurveType, isCC?: boolean, isBipolar?: boolean, isNegative?: boolean);
|
|
527
573
|
private get sourceName();
|
|
528
574
|
private get curveTypeName();
|
|
529
575
|
toString(): string;
|
|
@@ -1090,6 +1136,7 @@ export declare class BasicSoundBank {
|
|
|
1090
1136
|
* @param options Options associated with setting the sample format.
|
|
1091
1137
|
* @returns The samples whose sample rate or loop points changed.
|
|
1092
1138
|
* Compressing resamples samples outside 8000 to 96000 Hz.
|
|
1139
|
+
* @throws Error if `rejectOnFailure` is set and one of the samples has failed to compress.
|
|
1093
1140
|
*/
|
|
1094
1141
|
setSampleFormat(options: SetSampleFormatOptions): Promise<BasicSample[]>;
|
|
1095
1142
|
/**
|
|
@@ -1187,8 +1234,10 @@ export declare class BasicSoundBank {
|
|
|
1187
1234
|
clonePreset(preset: BasicPreset, options?: Partial<SoundBankCloneOptions>): BasicPreset;
|
|
1188
1235
|
/**
|
|
1189
1236
|
* Updates internal values. Call after updating the preset list.
|
|
1237
|
+
* @param sort If the presets should be sorted. Set it to `false` to keep a custom order,
|
|
1238
|
+
* only the internal values (like {@link isXGBank}) are then recomputed.
|
|
1190
1239
|
*/
|
|
1191
|
-
flush(): void;
|
|
1240
|
+
flush(sort?: boolean): void;
|
|
1192
1241
|
/**
|
|
1193
1242
|
* Trims the sound bank _in-place_ to only contain samples in a given MIDI file.
|
|
1194
1243
|
*
|
|
@@ -1236,6 +1285,7 @@ export declare class BasicSoundBank {
|
|
|
1236
1285
|
* Deletes everything irreversibly.
|
|
1237
1286
|
*/
|
|
1238
1287
|
destroySoundBank(): void;
|
|
1288
|
+
protected addElements<T>(list: T[], elements: readonly T[]): void;
|
|
1239
1289
|
protected parsingError(error: string): never;
|
|
1240
1290
|
/**
|
|
1241
1291
|
* Parses the bank after loading is done
|
|
@@ -1254,16 +1304,6 @@ interface LinkableZoneChild<P> {
|
|
|
1254
1304
|
* The element's name.
|
|
1255
1305
|
*/
|
|
1256
1306
|
name: string;
|
|
1257
|
-
/**
|
|
1258
|
-
* Links the element to a parent.
|
|
1259
|
-
* @param parent The parent that uses the element.
|
|
1260
|
-
*/
|
|
1261
|
-
linkTo(parent: P): void;
|
|
1262
|
-
/**
|
|
1263
|
-
* Unlinks the element from a parent.
|
|
1264
|
-
* @param parent The parent that no longer uses the element.
|
|
1265
|
-
*/
|
|
1266
|
-
unlinkFrom(parent: P): void;
|
|
1267
1307
|
}
|
|
1268
1308
|
/**
|
|
1269
1309
|
* A zone that belongs to a parent and uses a child: a preset zone with its instrument,
|
|
@@ -1297,6 +1337,15 @@ export declare abstract class BasicLinkedZone<P, C extends LinkableZoneChild<P>>
|
|
|
1297
1337
|
* @param link If the child should be linked to the parent.
|
|
1298
1338
|
*/
|
|
1299
1339
|
protected constructor(parent: P, child: C, link: boolean);
|
|
1340
|
+
/**
|
|
1341
|
+
* Links the child to the parent, unless this zone was created without linking.
|
|
1342
|
+
* Use it to put a zone back after {@link unlinkChild}, for example when undoing a zone deletion.
|
|
1343
|
+
*/
|
|
1344
|
+
linkChild(): void;
|
|
1345
|
+
/**
|
|
1346
|
+
* Unlinks the child from the parent, unless this zone was created without linking.
|
|
1347
|
+
*/
|
|
1348
|
+
unlinkChild(): void;
|
|
1300
1349
|
/**
|
|
1301
1350
|
* Replaces the child, moving the link from the previous one to the new one.
|
|
1302
1351
|
* @param child The new child.
|
|
@@ -1378,11 +1427,6 @@ export declare class BasicInstrument {
|
|
|
1378
1427
|
* > An instrument with unlinked zones must not be added to a sound bank!
|
|
1379
1428
|
*/
|
|
1380
1429
|
createZone(sample: BasicSample, link?: boolean): BasicInstrumentZone;
|
|
1381
|
-
/**
|
|
1382
|
-
* Unlinks the instrument from a given preset.
|
|
1383
|
-
* @param preset The preset to unlink from.
|
|
1384
|
-
*/
|
|
1385
|
-
unlinkFrom(preset: BasicPreset): void;
|
|
1386
1430
|
/**
|
|
1387
1431
|
* Unlinks everything from this instrument.
|
|
1388
1432
|
* This is what {@link BasicSoundBank.deleteInstrument} calls, the instrument itself stays intact.
|
|
@@ -1549,6 +1593,12 @@ export declare class BasicSample {
|
|
|
1549
1593
|
* How many instruments is this sample used by.
|
|
1550
1594
|
*/
|
|
1551
1595
|
get useCount(): number;
|
|
1596
|
+
/**
|
|
1597
|
+
* If the decoded float data is currently held in memory.
|
|
1598
|
+
* Check it before {@link getAudioData} to know if the call has to decode,
|
|
1599
|
+
* then use {@link releaseDecoded} to drop the copy again.
|
|
1600
|
+
*/
|
|
1601
|
+
get isDecoded(): boolean;
|
|
1552
1602
|
/**
|
|
1553
1603
|
* Get raw data for writing the file, either a compressed bit stream or signed 16-bit little endian PCM data.
|
|
1554
1604
|
* @param allowVorbis if vorbis file data is allowed.
|
|
@@ -1603,11 +1653,6 @@ export declare class BasicSample {
|
|
|
1603
1653
|
* @param type Either left, right or linked. The linked sample will be set appropriately as well.
|
|
1604
1654
|
*/
|
|
1605
1655
|
setLinkedSample(sample: BasicSample, type: SampleType): void;
|
|
1606
|
-
/**
|
|
1607
|
-
* Unlinks the sample from a given instrument
|
|
1608
|
-
* @param instrument the instrument to unlink from
|
|
1609
|
-
*/
|
|
1610
|
-
unlinkFrom(instrument: BasicInstrument): void;
|
|
1611
1656
|
/**
|
|
1612
1657
|
* Get the PCM Float32 audio data of this sample.
|
|
1613
1658
|
* This either decodes the compressed data or passes the ready sampleData.
|
|
@@ -2216,6 +2261,13 @@ export type SetSampleFormatOptions = {
|
|
|
2216
2261
|
* It must be provided if `compressed` format is chosen.
|
|
2217
2262
|
*/
|
|
2218
2263
|
compressionFunction: SampleEncodingFunction;
|
|
2264
|
+
/**
|
|
2265
|
+
* If the returned promise should reject when a sample fails to compress.
|
|
2266
|
+
* By default, such a sample is left uncompressed (and a warning is logged),
|
|
2267
|
+
* but the bank is still set to version 3.0.
|
|
2268
|
+
* With this on, the method throws after trying every sample and the bank's version stays the same.
|
|
2269
|
+
*/
|
|
2270
|
+
rejectOnFailure?: boolean;
|
|
2219
2271
|
});
|
|
2220
2272
|
/**
|
|
2221
2273
|
* Options for writing a sound bank file.
|
|
@@ -2361,11 +2413,15 @@ export interface SoundBankCloneOptions {
|
|
|
2361
2413
|
*/
|
|
2362
2414
|
reuseByName: boolean;
|
|
2363
2415
|
/**
|
|
2364
|
-
*
|
|
2365
|
-
*
|
|
2416
|
+
* How the instruments and samples used by a cloned element are reused instead of copied.
|
|
2417
|
+
* - `name` - reuse the first element in the bank with the same name.
|
|
2418
|
+
* - `identity` - reuse the element itself if it is already in the bank.
|
|
2419
|
+
* Use it to duplicate elements within one bank, as names often repeat in real banks.
|
|
2420
|
+
* - `none` - always copy them, under a free name if needed.
|
|
2421
|
+
*
|
|
2366
2422
|
* A stereo partner of a copied sample is always copied with it.
|
|
2367
2423
|
*/
|
|
2368
|
-
|
|
2424
|
+
reuseChildren: "name" | "identity" | "none";
|
|
2369
2425
|
/**
|
|
2370
2426
|
* If the new elements are added to the bank.
|
|
2371
2427
|
* When false, they are only listed in {@link SoundBankCloner.created}.
|
|
@@ -3731,6 +3787,7 @@ export declare class SoundBankManager {
|
|
|
3731
3787
|
*/
|
|
3732
3788
|
soundBankList: SoundBankManagerListEntry[];
|
|
3733
3789
|
private readonly presetListChangeCallback;
|
|
3790
|
+
private readonly bankRemovedCallback?;
|
|
3734
3791
|
private selectablePresetList;
|
|
3735
3792
|
private _presetList;
|
|
3736
3793
|
/**
|
|
@@ -3760,17 +3817,21 @@ export declare class SoundBankManager {
|
|
|
3760
3817
|
/**
|
|
3761
3818
|
* This method removes a sound bank with a given ID from the sound bank list.
|
|
3762
3819
|
* @param id The ID of the sound bank to delete.
|
|
3820
|
+
* @param reset If the synthesizer should reset (put every channel's controllers back to defaults) after the change.
|
|
3821
|
+
* Set it to `false` to keep a song playing, the channels then only update to the new presets.
|
|
3763
3822
|
* @throws Error An error if there's no sound bank with the given ID.
|
|
3764
3823
|
*/
|
|
3765
|
-
deleteSoundBank(id: string): void;
|
|
3824
|
+
deleteSoundBank(id: string, reset?: boolean): void;
|
|
3766
3825
|
/**
|
|
3767
3826
|
* Adds a new sound bank with a given ID, or replaces an existing one.
|
|
3768
3827
|
* @param bank The sound bank to add.
|
|
3769
3828
|
* @param id The unique ID to assign to the sound bank.
|
|
3770
3829
|
* If a sound bank with this ID already exists, it will be replaced.
|
|
3771
3830
|
* @param bankOffset The bank offset of the sound bank. Offsets the bank MSB value of all presets in this sound bank.
|
|
3831
|
+
* @param reset If the synthesizer should reset (put every channel's controllers back to defaults) after the change.
|
|
3832
|
+
* Set it to `false` to keep a song playing, the channels then only update to the new presets.
|
|
3772
3833
|
*/
|
|
3773
|
-
addSoundBank(bank: BasicSoundBank, id: string, bankOffset?: number): void;
|
|
3834
|
+
addSoundBank(bank: BasicSoundBank, id: string, bankOffset?: number, reset?: boolean): void;
|
|
3774
3835
|
/**
|
|
3775
3836
|
* Rebuilds the preset list from the current sound banks.
|
|
3776
3837
|
* Call it after editing a sound bank that is already added,
|
|
@@ -3780,6 +3841,7 @@ export declare class SoundBankManager {
|
|
|
3780
3841
|
* see {@link SpessaSynthProcessor.refreshPresets}.
|
|
3781
3842
|
*/
|
|
3782
3843
|
refresh(): void;
|
|
3844
|
+
private bankRemoved;
|
|
3783
3845
|
private generatePresetList;
|
|
3784
3846
|
}
|
|
3785
3847
|
/**
|
|
@@ -4115,10 +4177,6 @@ export declare class SpessaSynthProcessor {
|
|
|
4115
4177
|
* All MIDI channels of the synthesizer.
|
|
4116
4178
|
*/
|
|
4117
4179
|
readonly midiChannels: MIDIChannel[];
|
|
4118
|
-
/**
|
|
4119
|
-
* The sound bank manager, which manages all sound banks and presets.
|
|
4120
|
-
*/
|
|
4121
|
-
readonly soundBankManager: SoundBankManager;
|
|
4122
4180
|
/**
|
|
4123
4181
|
* The sample rate, in Hertz.
|
|
4124
4182
|
*/
|
|
@@ -4147,6 +4205,10 @@ export declare class SpessaSynthProcessor {
|
|
|
4147
4205
|
* @param event The event that occurred.
|
|
4148
4206
|
*/
|
|
4149
4207
|
onEventCall?: (event: SynthesizerEventCallback) => unknown;
|
|
4208
|
+
/**
|
|
4209
|
+
* The sound bank manager, which manages all sound banks and presets.
|
|
4210
|
+
*/
|
|
4211
|
+
readonly soundBankManager: SoundBankManager;
|
|
4150
4212
|
/**
|
|
4151
4213
|
* Left float32 buffer for processing XG insertion effects in-place.
|
|
4152
4214
|
* (channel outputs are double precision)
|
|
@@ -8724,6 +8786,19 @@ export declare class SoundBankCloner {
|
|
|
8724
8786
|
* @param options The options for this session.
|
|
8725
8787
|
*/
|
|
8726
8788
|
constructor(bank: BasicSoundBank, options?: Partial<SoundBankCloneOptions>);
|
|
8789
|
+
private get ownReuse();
|
|
8790
|
+
/**
|
|
8791
|
+
* Gets the clone this session made of an element.
|
|
8792
|
+
* @param source The sample or instrument that was cloned.
|
|
8793
|
+
* @returns The clone, or undefined if the session has not cloned the element.
|
|
8794
|
+
*/
|
|
8795
|
+
getClone(source: BasicSample): BasicSample | undefined;
|
|
8796
|
+
/**
|
|
8797
|
+
* Gets the clone this session made of an element.
|
|
8798
|
+
* @param source The sample or instrument that was cloned.
|
|
8799
|
+
* @returns The clone, or undefined if the session has not cloned the element.
|
|
8800
|
+
*/
|
|
8801
|
+
getClone(source: BasicInstrument): BasicInstrument | undefined;
|
|
8727
8802
|
/**
|
|
8728
8803
|
* Clones a sample and its stereo partner.
|
|
8729
8804
|
* The data is shared with the original, not copied.
|
|
@@ -8745,6 +8820,10 @@ export declare class SoundBankCloner {
|
|
|
8745
8820
|
clonePreset(preset: BasicPreset): BasicPreset;
|
|
8746
8821
|
private copyInstrument;
|
|
8747
8822
|
private copySample;
|
|
8823
|
+
/**
|
|
8824
|
+
* Finds the element to use instead of a copy, if the options allow one.
|
|
8825
|
+
*/
|
|
8826
|
+
private findReused;
|
|
8748
8827
|
private getFreeName;
|
|
8749
8828
|
}
|
|
8750
8829
|
/**
|