spessasynth_lib 3.16.1 → 3.16.3

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 (89) hide show
  1. package/@types/index.d.ts +0 -2
  2. package/@types/soundfont/basic_soundfont/basic_instrument.d.ts +29 -0
  3. package/@types/soundfont/basic_soundfont/basic_preset.d.ts +76 -0
  4. package/@types/soundfont/basic_soundfont/basic_sample.d.ts +82 -0
  5. package/@types/soundfont/basic_soundfont/basic_soundfont.d.ts +80 -0
  6. package/@types/soundfont/basic_soundfont/basic_zone.d.ts +42 -0
  7. package/@types/soundfont/basic_soundfont/basic_zones.d.ts +18 -0
  8. package/@types/soundfont/{read → basic_soundfont}/riff_chunk.d.ts +2 -1
  9. package/@types/soundfont/basic_soundfont/write_sf2/ibag.d.ts +6 -0
  10. package/@types/soundfont/basic_soundfont/write_sf2/igen.d.ts +6 -0
  11. package/@types/soundfont/basic_soundfont/write_sf2/imod.d.ts +6 -0
  12. package/@types/soundfont/basic_soundfont/write_sf2/inst.d.ts +6 -0
  13. package/@types/soundfont/basic_soundfont/write_sf2/pbag.d.ts +6 -0
  14. package/@types/soundfont/basic_soundfont/write_sf2/pgen.d.ts +6 -0
  15. package/@types/soundfont/basic_soundfont/write_sf2/phdr.d.ts +6 -0
  16. package/@types/soundfont/basic_soundfont/write_sf2/pmod.d.ts +6 -0
  17. package/@types/soundfont/basic_soundfont/write_sf2/sdta.d.ts +11 -0
  18. package/@types/soundfont/basic_soundfont/write_sf2/shdr.d.ts +8 -0
  19. package/@types/soundfont/{write → basic_soundfont/write_sf2}/write.d.ts +2 -2
  20. package/@types/soundfont/{read → read_sf2}/generators.d.ts +2 -1
  21. package/@types/soundfont/{read → read_sf2}/instruments.d.ts +3 -24
  22. package/@types/soundfont/read_sf2/presets.d.ts +28 -0
  23. package/@types/soundfont/read_sf2/samples.d.ts +56 -0
  24. package/@types/soundfont/{read → read_sf2}/zones.d.ts +11 -53
  25. package/@types/soundfont/soundfont.d.ts +6 -67
  26. package/midi_parser/midi_loader.js +1 -1
  27. package/midi_parser/rmidi_writer.js +11 -11
  28. package/midi_parser/used_keys_loaded.js +1 -1
  29. package/package.json +1 -1
  30. package/sequencer/worklet_sequencer/song_control.js +1 -1
  31. package/soundfont/basic_soundfont/basic_instrument.js +73 -0
  32. package/soundfont/{read/presets.js → basic_soundfont/basic_preset.js} +54 -87
  33. package/soundfont/basic_soundfont/basic_sample.js +132 -0
  34. package/soundfont/basic_soundfont/basic_soundfont.js +193 -0
  35. package/soundfont/basic_soundfont/basic_zone.js +39 -0
  36. package/soundfont/basic_soundfont/basic_zones.js +47 -0
  37. package/soundfont/{read → basic_soundfont}/riff_chunk.js +8 -1
  38. package/soundfont/{write → basic_soundfont/write_sf2}/ibag.js +4 -4
  39. package/soundfont/{write → basic_soundfont/write_sf2}/igen.js +5 -5
  40. package/soundfont/{write → basic_soundfont/write_sf2}/imod.js +4 -4
  41. package/soundfont/{write → basic_soundfont/write_sf2}/inst.js +5 -5
  42. package/soundfont/{write → basic_soundfont/write_sf2}/pbag.js +4 -4
  43. package/soundfont/{write → basic_soundfont/write_sf2}/pgen.js +5 -5
  44. package/soundfont/{write → basic_soundfont/write_sf2}/phdr.js +5 -5
  45. package/soundfont/{write → basic_soundfont/write_sf2}/pmod.js +4 -4
  46. package/soundfont/{write → basic_soundfont/write_sf2}/sdta.js +5 -5
  47. package/soundfont/{write → basic_soundfont/write_sf2}/shdr.js +5 -5
  48. package/soundfont/{write → basic_soundfont/write_sf2}/soundfont_trimmer.js +5 -5
  49. package/soundfont/{write → basic_soundfont/write_sf2}/write.js +8 -9
  50. package/soundfont/{read → read_sf2}/generators.js +2 -1
  51. package/soundfont/{read → read_sf2}/instruments.js +4 -63
  52. package/soundfont/{read → read_sf2}/modulators.js +1 -1
  53. package/soundfont/read_sf2/presets.js +78 -0
  54. package/soundfont/{read → read_sf2}/samples.js +4 -138
  55. package/soundfont/{read → read_sf2}/zones.js +14 -60
  56. package/soundfont/soundfont.js +21 -188
  57. package/synthetizer/worklet_processor.min.js +6 -6
  58. package/synthetizer/worklet_system/message_protocol/message_sending.js +1 -1
  59. package/synthetizer/worklet_system/worklet_methods/data_entry.js +1 -1
  60. package/synthetizer/worklet_system/worklet_methods/note_off.js +1 -1
  61. package/synthetizer/worklet_system/worklet_methods/note_on.js +1 -1
  62. package/synthetizer/worklet_system/worklet_methods/program_control.js +1 -1
  63. package/synthetizer/worklet_system/worklet_methods/reset_controllers.js +1 -1
  64. package/synthetizer/worklet_system/worklet_methods/tuning_control.js +1 -1
  65. package/synthetizer/worklet_system/worklet_methods/voice_control.js +1 -1
  66. package/synthetizer/worklet_system/worklet_methods/worklet_soundfont_manager/worklet_soundfont_manager.js +1 -1
  67. package/synthetizer/worklet_system/worklet_utilities/lowpass_filter.js +1 -1
  68. package/synthetizer/worklet_system/worklet_utilities/modulation_envelope.js +2 -2
  69. package/synthetizer/worklet_system/worklet_utilities/modulator_curves.js +1 -1
  70. package/synthetizer/worklet_system/worklet_utilities/volume_envelope.js +4 -4
  71. package/synthetizer/worklet_system/worklet_utilities/worklet_modulator.js +2 -2
  72. package/synthetizer/worklet_system/worklet_utilities/worklet_processor_channel.js +1 -1
  73. package/synthetizer/worklet_system/worklet_utilities/worklet_voice.js +1 -1
  74. package/utils/buffer_to_wav.js +6 -6
  75. package/@types/midi_parser/used_keys_loaded.d.ts +0 -10
  76. package/@types/soundfont/read/presets.d.ts +0 -88
  77. package/@types/soundfont/read/samples.d.ts +0 -138
  78. package/@types/soundfont/write/ibag.d.ts +0 -6
  79. package/@types/soundfont/write/igen.d.ts +0 -6
  80. package/@types/soundfont/write/imod.d.ts +0 -6
  81. package/@types/soundfont/write/inst.d.ts +0 -6
  82. package/@types/soundfont/write/pbag.d.ts +0 -6
  83. package/@types/soundfont/write/pgen.d.ts +0 -6
  84. package/@types/soundfont/write/phdr.d.ts +0 -6
  85. package/@types/soundfont/write/pmod.d.ts +0 -6
  86. package/@types/soundfont/write/sdta.d.ts +0 -11
  87. package/@types/soundfont/write/shdr.d.ts +0 -8
  88. package/@types/soundfont/write/soundfont_trimmer.d.ts +0 -6
  89. /package/@types/soundfont/{read → read_sf2}/modulators.d.ts +0 -0
package/@types/index.d.ts CHANGED
@@ -3,8 +3,6 @@ import { Synthetizer } from './synthetizer/synthetizer.js';
3
3
  import { DEFAULT_PERCUSSION } from './synthetizer/synthetizer.js';
4
4
  import { VOICE_CAP } from './synthetizer/synthetizer.js';
5
5
  import { SoundFont2 } from './soundfont/soundfont.js';
6
- import { trimSoundfont } from './soundfont/write/soundfont_trimmer.js';
7
- import { modulatorSources } from './soundfont/read/modulators.js';
8
6
  import { encodeVorbis } from "./utils/encode_vorbis.js";
9
7
  import { MIDI } from './midi_parser/midi_loader.js';
10
8
  import { IndexedByteArray } from './utils/indexed_array.js';
@@ -0,0 +1,29 @@
1
+ export class BasicInstrument {
2
+ /**
3
+ * The instrument's name
4
+ * @type {string}
5
+ */
6
+ instrumentName: string;
7
+ /**
8
+ * The instrument's zones
9
+ * @type {BasicInstrumentZone[]}
10
+ */
11
+ instrumentZones: BasicInstrumentZone[];
12
+ _useCount: number;
13
+ addUseCount(): void;
14
+ removeUseCount(): void;
15
+ /**
16
+ * @returns {number}
17
+ */
18
+ get useCount(): number;
19
+ deleteInstrument(): void;
20
+ /**
21
+ * @param index {number}
22
+ * @returns {boolean} is the zone has been deleted
23
+ */
24
+ safeDeleteZone(index: number): boolean;
25
+ /**
26
+ * @param index {number}
27
+ */
28
+ deleteZone(index: number): void;
29
+ }
@@ -0,0 +1,76 @@
1
+ export class BasicPreset {
2
+ /**
3
+ * The preset's name
4
+ * @type {string}
5
+ */
6
+ presetName: string;
7
+ /**
8
+ * The preset's MIDI program number
9
+ * @type {number}
10
+ */
11
+ program: number;
12
+ /**
13
+ * The preset's MIDI bank number
14
+ * @type {number}
15
+ */
16
+ bank: number;
17
+ /**
18
+ * The preset's zones
19
+ * @type {BasicPresetZone[]}
20
+ */
21
+ presetZones: BasicPresetZone[];
22
+ /**
23
+ * SampleID offset for this preset
24
+ * @type {number}
25
+ */
26
+ sampleIDOffset: number;
27
+ /**
28
+ * Stores already found getSamplesAndGenerators for reuse
29
+ * @type {SampleAndGenerators[][][]}
30
+ */
31
+ foundSamplesAndGenerators: SampleAndGenerators[][][];
32
+ /**
33
+ * unused metadata
34
+ * @type {number}
35
+ */
36
+ library: number;
37
+ /**
38
+ * unused metadata
39
+ * @type {number}
40
+ */
41
+ genre: number;
42
+ /**
43
+ * unused metadata
44
+ * @type {number}
45
+ */
46
+ morphology: number;
47
+ deletePreset(): void;
48
+ /**
49
+ * @param index {number}
50
+ */
51
+ deleteZone(index: number): void;
52
+ /**
53
+ * Preloads all samples (async)
54
+ */
55
+ preload(keyMin: any, keyMax: any): void;
56
+ /**
57
+ * Preloads a specific key/velocity combo
58
+ * @param key {number}
59
+ * @param velocity {number}
60
+ */
61
+ preloadSpecific(key: number, velocity: number): void;
62
+ /**
63
+ * Returns generatorTranslator and generators for given note
64
+ * @param midiNote {number}
65
+ * @param velocity {number}
66
+ * @returns {SampleAndGenerators[]}
67
+ */
68
+ getSamplesAndGenerators(midiNote: number, velocity: number): SampleAndGenerators[];
69
+ }
70
+ export type SampleAndGenerators = {
71
+ instrumentGenerators: Generator[];
72
+ presetGenerators: Generator[];
73
+ modulators: Modulator[];
74
+ sample: BasicSample;
75
+ sampleID: number;
76
+ };
@@ -0,0 +1,82 @@
1
+ export class BasicSample {
2
+ /**
3
+ * The basic representation of a soundfont sample
4
+ * @param sampleName {string}
5
+ * @param sampleRate {number}
6
+ * @param samplePitch {number}
7
+ * @param samplePitchCorrection {number}
8
+ * @param sampleLink {number}
9
+ * @param sampleType {number}
10
+ * @param loopStart {number} relative to sample start
11
+ * @param loopEnd {number} relative to sample start
12
+ */
13
+ constructor(sampleName: string, sampleRate: number, samplePitch: number, samplePitchCorrection: number, sampleLink: number, sampleType: number, loopStart: number, loopEnd: number);
14
+ /**
15
+ * Sample's name
16
+ * @type {string}
17
+ */
18
+ sampleName: string;
19
+ /**
20
+ * Sample rate in Hz
21
+ * @type {number}
22
+ */
23
+ sampleRate: number;
24
+ /**
25
+ * Original pitch of the sample as a MIDI note number
26
+ * @type {number}
27
+ */
28
+ samplePitch: number;
29
+ /**
30
+ * Pitch correction, in cents. Can be negative
31
+ * @type {number}
32
+ */
33
+ samplePitchCorrection: number;
34
+ /**
35
+ * Sample link, currently unused.
36
+ * @type {number}
37
+ */
38
+ sampleLink: number;
39
+ /**
40
+ * Type of the sample, an enum
41
+ * @type {number}
42
+ */
43
+ sampleType: number;
44
+ /**
45
+ * Relative to start of the sample, bytes
46
+ * @type {number}
47
+ */
48
+ sampleLoopStartIndex: number;
49
+ /**
50
+ * Relative to start of the sample, in bytes
51
+ * @type {number}
52
+ */
53
+ sampleLoopEndIndex: number;
54
+ /**
55
+ * Indicates if the sample is compressed
56
+ * @type {boolean}
57
+ */
58
+ isCompressed: boolean;
59
+ /**
60
+ * The compressed sample data if it was compressed by spessasynth
61
+ * @type {Uint8Array}
62
+ */
63
+ compressedData: Uint8Array;
64
+ /**
65
+ * The sample's use count
66
+ * @type {number}
67
+ */
68
+ useCount: number;
69
+ /**
70
+ * @returns {Uint8Array|IndexedByteArray}
71
+ */
72
+ getRawData(): Uint8Array | IndexedByteArray;
73
+ /**
74
+ * @param quality {number}
75
+ * @param encodeVorbis {EncodeVorbisFunction}
76
+ */
77
+ compressSample(quality: number, encodeVorbis: EncodeVorbisFunction): void;
78
+ /**
79
+ * @returns {Float32Array}
80
+ */
81
+ getAudioData(): Float32Array;
82
+ }
@@ -0,0 +1,80 @@
1
+ export class BasicSoundFont {
2
+ /**
3
+ * Merges soundfonts with the given order. Keep in mind that the info read is copied from the first one
4
+ * @param soundfonts {...BasicSoundFont} the soundfonts to merge, the first overwrites the last
5
+ * @returns {BasicSoundFont}
6
+ */
7
+ static mergeSoundfonts(...soundfonts: BasicSoundFont[]): BasicSoundFont;
8
+ /**
9
+ * Creates a new basic soundfont template
10
+ * @param data {undefined|{presets: BasicPreset[], info: Object<string, string>}}
11
+ */
12
+ constructor(data?: undefined | {
13
+ presets: BasicPreset[];
14
+ info: {
15
+ [x: string]: string;
16
+ };
17
+ });
18
+ /**
19
+ * Soundfont's info stored as name: value. ifil and iver are stored as string representation of float (e.g. 2.1)
20
+ * @type {Object<string, string>}
21
+ */
22
+ soundFontInfo: {
23
+ [x: string]: string;
24
+ };
25
+ /**
26
+ * The soundfont's presets
27
+ * @type {BasicPreset[]}
28
+ */
29
+ presets: BasicPreset[];
30
+ /**
31
+ * The soundfont's samples
32
+ * @type {BasicSample[]}
33
+ */
34
+ samples: BasicSample[];
35
+ /**
36
+ * The soundfont's instruments
37
+ * @type {BasicInstrument[]}
38
+ */
39
+ instruments: BasicInstrument[];
40
+ removeUnusedElements(): void;
41
+ /**
42
+ * @param instrument {BasicInstrument}
43
+ */
44
+ deleteInstrument(instrument: BasicInstrument): void;
45
+ /**
46
+ * @param sample {BasicSample}
47
+ */
48
+ deleteSample(sample: BasicSample): void;
49
+ /**
50
+ * @param preset {BasicPreset}
51
+ */
52
+ deletePreset(preset: BasicPreset): void;
53
+ /**
54
+ * Get the appropriate preset, undefined if not foun d
55
+ * @param bankNr {number}
56
+ * @param presetNr {number}
57
+ * @return {BasicPreset}
58
+ */
59
+ getPresetNoFallback(bankNr: number, presetNr: number): BasicPreset;
60
+ /**
61
+ * To avoid overlapping on multiple desfonts
62
+ * @param offset {number}
63
+ */
64
+ setSampleIDOffset(offset: number): void;
65
+ /**
66
+ * Get the appropriate preset
67
+ * @param bankNr {number}
68
+ * @param presetNr {number}
69
+ * @returns {BasicPreset}
70
+ */
71
+ getPreset(bankNr: number, presetNr: number): BasicPreset;
72
+ /**
73
+ * gets preset by name
74
+ * @param presetName {string}
75
+ * @returns {BasicPreset}
76
+ */
77
+ getPresetByName(presetName: string): BasicPreset;
78
+ write: typeof write;
79
+ }
80
+ import { write } from './write_sf2/write.js';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * @typedef {Object} SoundFontRange
3
+ * @property {number} min - the minimum midi note
4
+ * @property {number} max - the maximum midi note
5
+ */
6
+ export class BasicZone {
7
+ /**
8
+ * The zone's generators
9
+ * @type {Generator[]}
10
+ */
11
+ generators: Generator[];
12
+ /**
13
+ * The zone's modulators
14
+ * @type {Modulator[]}
15
+ */
16
+ modulators: Modulator[];
17
+ /**
18
+ * Indicates if the zone is global
19
+ * @type {boolean}
20
+ */
21
+ isGlobal: boolean;
22
+ /**
23
+ * The zone's key range
24
+ * @type {SoundFontRange}
25
+ */
26
+ keyRange: SoundFontRange;
27
+ /**
28
+ * The zone's velocity range
29
+ * @type {SoundFontRange}
30
+ */
31
+ velRange: SoundFontRange;
32
+ }
33
+ export type SoundFontRange = {
34
+ /**
35
+ * - the minimum midi note
36
+ */
37
+ min: number;
38
+ /**
39
+ * - the maximum midi note
40
+ */
41
+ max: number;
42
+ };
@@ -0,0 +1,18 @@
1
+ export class BasicInstrumentZone extends BasicZone {
2
+ /**
3
+ * Zone's sample. Undefined if global
4
+ * @type {BasicSample|undefined}
5
+ */
6
+ sample: BasicSample | undefined;
7
+ useCount: number;
8
+ deleteZone(): void;
9
+ }
10
+ export class BasicPresetZone extends BasicZone {
11
+ /**
12
+ * Zone's instrument. Undefined if global
13
+ * @type {BasicInstrument|undefined}
14
+ */
15
+ instrument: BasicInstrument | undefined;
16
+ deleteZone(): void;
17
+ }
18
+ import { BasicZone } from './basic_zone.js';
@@ -14,9 +14,10 @@ export function writeRIFFChunk(chunk: RiffChunk, prepend?: IndexedByteArray): In
14
14
  /**
15
15
  * @param header {string}
16
16
  * @param data {Uint8Array}
17
+ * @param addZeroByte {Boolean}
17
18
  * @returns {IndexedByteArray}
18
19
  */
19
- export function writeRIFFOddSize(header: string, data: Uint8Array): IndexedByteArray;
20
+ export function writeRIFFOddSize(header: string, data: Uint8Array, addZeroByte?: boolean): IndexedByteArray;
20
21
  /**
21
22
  * riff_chunk.js
22
23
  * reads a riff read and stores it as a class
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getIBAG(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getIGEN(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getIMOD(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getINST(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getPBAG(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getPGEN(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getPHDR(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @returns {IndexedByteArray}
4
+ */
5
+ export function getPMOD(this: BasicSoundFont): IndexedByteArray;
6
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @param smplStartOffsets {number[]}
4
+ * @param smplEndOffsets {number[]}
5
+ * @param compress {boolean}
6
+ * @param quality {number}
7
+ * @param vorbisFunc {EncodeVorbisFunction}
8
+ * @returns {IndexedByteArray}
9
+ */
10
+ export function getSDTA(this: BasicSoundFont, smplStartOffsets: number[], smplEndOffsets: number[], compress: boolean, quality: number, vorbisFunc: EncodeVorbisFunction): IndexedByteArray;
11
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @this {BasicSoundFont}
3
+ * @param smplStartOffsets {number[]}
4
+ * @param smplEndOffsets {number[]}
5
+ * @returns {IndexedByteArray}
6
+ */
7
+ export function getSHDR(this: BasicSoundFont, smplStartOffsets: number[], smplEndOffsets: number[]): IndexedByteArray;
8
+ import { IndexedByteArray } from '../../../utils/indexed_array.js';
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * Write the soundfont as an .sf2 file. This method is DESTRUCTIVE
3
- * @this {SoundFont2}
3
+ * @this {BasicSoundFont}
4
4
  * @param {SoundFont2WriteOptions} options
5
5
  * @returns {Uint8Array}
6
6
  */
7
- export function write(this: SoundFont2, options?: SoundFont2WriteOptions): Uint8Array;
7
+ export function write(this: BasicSoundFont, options?: SoundFont2WriteOptions): Uint8Array;
8
8
  export type SoundFont2WriteOptions = {
9
9
  /**
10
10
  * - if the soundfont should be compressed with the ogg vorbis codec
@@ -12,6 +12,7 @@ export function addAndClampGenerator(generatorType: number, presetGens: Generato
12
12
  export function readGenerators(generatorChunk: RiffChunk): Generator[];
13
13
  export type generatorTypes = number;
14
14
  export namespace generatorTypes {
15
+ let INVALID: number;
15
16
  let startAddrsOffset: number;
16
17
  let endAddrOffset: number;
17
18
  let startloopAddrsOffset: number;
@@ -94,5 +95,5 @@ export class Generator {
94
95
  generatorType: generatorTypes;
95
96
  generatorValue: number;
96
97
  }
97
- import { RiffChunk } from './riff_chunk.js';
98
+ import { RiffChunk } from '../basic_soundfont/riff_chunk.js';
98
99
  import { IndexedByteArray } from '../../utils/indexed_array.js';
@@ -9,36 +9,14 @@ export function readInstruments(instrumentChunk: RiffChunk, instrumentZones: Ins
9
9
  * instrument.js
10
10
  * purpose: parses soundfont instrument and stores them as a class
11
11
  */
12
- export class Instrument {
12
+ export class Instrument extends BasicInstrument {
13
13
  /**
14
14
  * Creates an instrument
15
15
  * @param instrumentChunk {RiffChunk}
16
16
  */
17
17
  constructor(instrumentChunk: RiffChunk);
18
- instrumentName: string;
19
18
  instrumentZoneIndex: number;
20
19
  instrumentZonesAmount: number;
21
- /**
22
- * @type {InstrumentZone[]}
23
- */
24
- instrumentZones: InstrumentZone[];
25
- _useCount: number;
26
- addUseCount(): void;
27
- removeUseCount(): void;
28
- /**
29
- * @returns {number}
30
- */
31
- get useCount(): number;
32
- deleteInstrument(): void;
33
- /**
34
- * @param index {number}
35
- * @returns {boolean} is the zone has been deleted
36
- */
37
- safeDeleteZone(index: number): boolean;
38
- /**
39
- * @param index {number}
40
- */
41
- deleteZone(index: number): void;
42
20
  /**
43
21
  * Loads all the instrument zones, given the amount
44
22
  * @param amount {number}
@@ -46,5 +24,6 @@ export class Instrument {
46
24
  */
47
25
  getInstrumentZones(amount: number, zones: InstrumentZone[]): void;
48
26
  }
49
- import { RiffChunk } from "./riff_chunk.js";
27
+ import { RiffChunk } from "../basic_soundfont/riff_chunk.js";
50
28
  import { InstrumentZone } from "./zones.js";
29
+ import { BasicInstrument } from '../basic_soundfont/basic_instrument.js';
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Reads the presets
3
+ * @param presetChunk {RiffChunk}
4
+ * @param presetZones {PresetZone[]}
5
+ * @returns {Preset[]}
6
+ */
7
+ export function readPresets(presetChunk: RiffChunk, presetZones: PresetZone[]): Preset[];
8
+ /**
9
+ * parses soundfont presets, also includes function for getting the generators and samples from midi note and velocity
10
+ */
11
+ export class Preset extends BasicPreset {
12
+ /**
13
+ * Creates a preset
14
+ * @param presetChunk {RiffChunk}
15
+ */
16
+ constructor(presetChunk: RiffChunk);
17
+ presetZoneStartIndex: number;
18
+ presetZonesAmount: number;
19
+ /**
20
+ * Loads all the preset zones, given the amount
21
+ * @param amount {number}
22
+ * @param zones {PresetZone[]}
23
+ */
24
+ getPresetZones(amount: number, zones: PresetZone[]): void;
25
+ }
26
+ import { RiffChunk } from "../basic_soundfont/riff_chunk.js";
27
+ import { PresetZone } from "./zones.js";
28
+ import { BasicPreset } from '../basic_soundfont/basic_preset.js';
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Reads the generatorTranslator from the shdr read
3
+ * @param sampleHeadersChunk {RiffChunk}
4
+ * @param smplChunkData {IndexedByteArray|Float32Array}
5
+ * @param isSmplDataRaw {boolean}
6
+ * @returns {LoadedSample[]}
7
+ */
8
+ export function readSamples(sampleHeadersChunk: RiffChunk, smplChunkData: IndexedByteArray | Float32Array, isSmplDataRaw?: boolean): LoadedSample[];
9
+ export class LoadedSample extends BasicSample {
10
+ /**
11
+ * Creates a sample
12
+ * @param sampleName {string}
13
+ * @param sampleStartIndex {number}
14
+ * @param sampleEndIndex {number}
15
+ * @param sampleLoopStartIndex {number}
16
+ * @param sampleLoopEndIndex {number}
17
+ * @param sampleRate {number}
18
+ * @param samplePitch {number}
19
+ * @param samplePitchCorrection {number}
20
+ * @param sampleLink {number}
21
+ * @param sampleType {number}
22
+ * @param smplArr {IndexedByteArray|Float32Array}
23
+ * @param sampleIndex {number} initial sample index when loading the sfont
24
+ * @param isDataRaw {boolean} if false, the data is decoded as float32.
25
+ * Used for SF2Pack support
26
+ */
27
+ constructor(sampleName: string, sampleStartIndex: number, sampleEndIndex: number, sampleLoopStartIndex: number, sampleLoopEndIndex: number, sampleRate: number, samplePitch: number, samplePitchCorrection: number, sampleLink: number, sampleType: number, smplArr: IndexedByteArray | Float32Array, sampleIndex: number, isDataRaw: boolean);
28
+ sampleStartIndex: number;
29
+ sampleEndIndex: number;
30
+ isSampleLoaded: boolean;
31
+ sampleID: number;
32
+ sampleLength: number;
33
+ sampleDataArray: Float32Array | IndexedByteArray;
34
+ sampleData: Float32Array;
35
+ isDataRaw: boolean;
36
+ /**
37
+ * Get raw data, whether it's compressed or not as we simply write it to the file
38
+ * @return {Uint8Array}
39
+ */
40
+ getRawData(): Uint8Array;
41
+ /**
42
+ * Decode binary vorbis into a float32 pcm
43
+ */
44
+ decodeVorbis(): void;
45
+ /**
46
+ * @returns {Float32Array}
47
+ */
48
+ loadUncompressedData(): Float32Array;
49
+ /**
50
+ * @returns {Float32Array}
51
+ */
52
+ getUncompressedReadyData(): Float32Array;
53
+ }
54
+ import { RiffChunk } from '../basic_soundfont/riff_chunk.js';
55
+ import { IndexedByteArray } from '../../utils/indexed_array.js';
56
+ import { BasicSample } from '../basic_soundfont/basic_sample.js';