import { DX7Voice } from './DX7Voice.js'; /** * Represents a DX7 bank (collection of 32 voices) loaded from a SYX file. * DX7 banks contain 32 voices in a packed 128-byte format with a 6-byte SysEx header, * 4096 bytes of voice data, 1 byte checksum, and 0xF7 trailer. Provides methods for * loading from files, converting to/from SysEx format, and manipulating voices. * * @example * // Load from file * const fileInput = document.getElementById("file-input"); * fileInput.addEventListener("change", async (e) => { * const file = e.target.files[0]; * const bank = await DX7Bank.fromFile(file); * console.log(bank.getVoiceNames()); * }); * * @example * // Create from SysEx data * const syxData = new Uint8Array([0xF0, 0x43, 0x00, 0x09, 0x20, 0x00, 0xF7]); * const bank = DX7Bank.fromSysEx(syxData, "My Bank"); * * @example * // Manipulate voices * const bank = new DX7Bank(); * const voice = DX7Voice.fromName("BASS 1"); * bank.replaceVoice(0, voice); // Replace first voice * console.log(bank.getVoice(0).name); // "BASS 1" * * @example * // Export to SysEx * const bank = await DX7Bank.fromFile(file); * const syxData = bank.toSysEx(); * download(syxData, "my-bank.syx"); * * @example * // Convert to JSON for storage * const bank = await DX7Bank.fromFile(file); * const json = bank.toJSON(); * localStorage.setItem("dx7-bank", JSON.stringify(json)); */ export class DX7Bank { static SYSEX_START: number; static SYSEX_END: number; static SYSEX_YAMAHA_ID: number; static SYSEX_SUB_STATUS: number; static SYSEX_FORMAT_32_VOICES: number; static SYSEX_BYTE_COUNT_MSB: number; static SYSEX_BYTE_COUNT_LSB: number; static SYSEX_HEADER: number[]; static SYSEX_HEADER_SIZE: number; static VOICE_DATA_SIZE: number; static SYSEX_SIZE: number; static VOICE_SIZE: number; static NUM_VOICES: number; static CHECKSUM_MODULO: number; static MASK_7BIT: number; /** * Calculate DX7 SysEx checksum * @private * @param {Uint8Array} data - Data to checksum * @param {number} size - Number of bytes * @returns {number} Checksum byte */ private static _calculateChecksum; /** * Load a DX7 bank from a file * @param {File|Blob} file - SYX file to load * @returns {Promise} * @throws {DX7ParseError} If file is a single voice file * @throws {DX7ValidationError} If data is not valid DX7 SYX format * @throws {Error} If file cannot be read (FileReader error) */ static fromFile(file: File | Blob): Promise; /** * Create a DX7Bank from SysEx data * @param {Array|ArrayBuffer|Uint8Array} data - SysEx data (4104 bytes with header/footer) or raw voice data (4096 bytes) * @param {string} name - Optional bank name * @returns {DX7Bank} * @throws {DX7ParseError} If SysEx header is invalid * @throws {DX7ValidationError} If data length is invalid */ static fromSysEx(data: Array | ArrayBuffer | Uint8Array, name?: string): DX7Bank; /** * Create a DX7Bank from a JSON object * @param {DX7BankJSON} json - JSON representation of a DX7 bank * @returns {DX7Bank} * @throws {DX7ValidationError} If JSON structure is invalid */ static fromJSON(json: DX7BankJSON): DX7Bank; /** * Create a DX7Bank instance. Can be initialized with SYX data or created empty. * When data is provided, it's validated and parsed. When no data is provided, * the bank is initialized with 32 default "Init Voice" patches. * * @param {Array|ArrayBuffer|Uint8Array} [data] - Bank SYX data (4104 bytes with SysEx wrapper or 4096 bytes raw) * @param {string} [name=""] - Optional bank name (e.g., filename without extension) * @returns {DX7Bank} * * @example * // Create empty bank with default voices * const bank = new DX7Bank(); * console.log(bank.getVoiceNames()); // ["Init Voice", "Init Voice", ...] * * @example * // Create from SysEx data * const syxData = new Uint8Array([0xF0, 0x43, 0x00, 0x09, 0x20, 0x00, 0xF7]); * const bank = new DX7Bank(syxData, "My Bank"); * * @example * // Create from raw voice data (no SysEx wrapper) * const voiceData = new Uint8Array(4096); // 32 voices × 128 bytes * const bank = new DX7Bank(voiceData, "Raw Bank"); */ constructor(data?: Array | ArrayBuffer | Uint8Array, name?: string); voices: any[]; name: string; /** * Load and validate bank data * @private * @param {Array|ArrayBuffer|Uint8Array} data */ private _load; /** * Replace a voice at the specified index (0-31). Validates the index and creates a copy * of the voice data to ensure the bank maintains its own independent copy. * * @param {number} index - Voice index (0-31) * @param {DX7Voice} voice - Voice to insert * @returns {void} * @throws {DX7ValidationError} If index is out of range (0-31) * * @example * // Replace first voice with a custom voice * const bank = await DX7Bank.fromFile(file); * const customVoice = DX7Voice.fromName("LEAD 1"); * bank.replaceVoice(0, customVoice); * console.log(bank.getVoice(0).name); // "LEAD 1" * * @example * // Swap voices between banks * const bank1 = await DX7Bank.fromFile(file1); * const bank2 = await DX7Bank.fromFile(file2); * const voiceFromBank2 = bank2.getVoice(5); * bank1.replaceVoice(0, voiceFromBank2); // Copy voice from bank2 to bank1 */ replaceVoice(index: number, voice: DX7Voice): void; /** * Add a voice to the first empty slot * @param {DX7Voice} voice - Voice to add * @returns {number} Index where voice was added, or -1 if bank is full */ addVoice(voice: DX7Voice): number; /** * Get all voices in the bank * @returns {DX7Voice[]} */ getVoices(): DX7Voice[]; /** * Get a specific voice by index * @param {number} index - Voice index (0-31) * @returns {DX7Voice|null} */ getVoice(index: number): DX7Voice | null; /** * Get all voice names * @returns {string[]} */ getVoiceNames(): string[]; /** * Find a voice by name (case-insensitive, partial match) * @param {string} name - Voice name to search for * @returns {DX7Voice|null} */ findVoiceByName(name: string): DX7Voice | null; /** * Export bank to SysEx format * @returns {Uint8Array} Full SysEx data (4104 bytes) */ toSysEx(): Uint8Array; /** * Convert bank to JSON format * @returns {object} Bank data in JSON format */ toJSON(): object; } //# sourceMappingURL=DX7Bank.d.ts.map