UNPKG

soundfont2

Version:

A SoundFont2 parser for Node.js and web browsers

88 lines (87 loc) 2.75 kB
import { Bank, Instrument, Key, MetaData, Preset, PresetData, Sample } from './types'; import { SF2Chunk } from './chunk'; export declare class SoundFont2 { /** * Create a new `SoundFont2` instance from a raw input buffer. * * @param {Uint8Array} buffer * @deprecated Replaced with `new SoundFont2(buffer: Uint8Array);` */ static from(buffer: Uint8Array): SoundFont2; /** * The raw RIFF chunk data. */ readonly chunk: SF2Chunk; /** * The meta data. */ readonly metaData: MetaData; /** * The raw sample data. */ readonly sampleData: Uint8Array; /** * The parsed samples. */ readonly samples: Sample[]; /** * The unparsed preset data. */ readonly presetData: PresetData; /** * The parsed instuments. */ readonly instruments: Instrument[]; /** * The parsed presets. */ readonly presets: Preset[]; /** * The parsed banks. */ readonly banks: Bank[]; /** * Load a SoundFont2 file from a `Uint8Array` or a `SF2Chunk`. The recommended way is to use a * Uint8Array, loading a SoundFont2 from a `SF2Chunk` only exists for backwards compatibility and * will likely be removed in a future version. * * @param {Uint8Array|SF2Chunk} chunk */ constructor(chunk: Uint8Array | SF2Chunk); /** * Get the key data by MIDI bank, preset and key number. May return null if no instrument was * found for the given inputs. Note that this does not process any of the generators that are * specific to the key number. * * The result is memoized based on all arguments, to prevent having to check all presets, * instruments etc. every time. * * @param {number} memoizedKeyNumber - The MIDI key number * @param {number} [memoizedBankNumber] - The bank index number, defaults to 0 * @param {number} [memoizedPresetNumber] - The preset number, defaults to 0 */ getKeyData(memoizedKeyNumber: number, memoizedBankNumber?: number, memoizedPresetNumber?: number): Key | null; /** * Checks if a MIDI key number is in the range of a zone. * * @param {ZoneItems} zone - The zone to check * @param {number} keyNumber - The MIDI key number, must be between 0 and 127 */ private isKeyInRange; /** * Parse the presets to banks. */ private getBanks; /** * Parse the raw preset data to presets. */ private getPresets; /** * Parse the raw instrument data (found in the preset data) to instruments. */ private getInstruments; /** * Parse the raw sample data and sample headers to samples. */ private getSamples; }