/** * JSON representation of a DX7 operator (human-readable) * @typedef {Object} DX7OperatorJSON * @memberof DX7Voice * @property {number} id - Operator number (1-6) * @property {Object} osc - Oscillator parameters (frequency, detune) * @property {Object} eg - Envelope generator (rates and levels) * @property {Object} key - Key scaling parameters (break point, velocity) * @property {Object} output - Output parameters (level, amp mod sensitivity) * @property {Object} scale - Keyboard scaling (left/right curves and depths) */ /** * JSON representation of a DX7 voice (patch) * @typedef {Object} DX7VoiceJSON * @memberof DX7Voice * @property {string} name - Voice/patch name (max 10 characters) * @property {DX7OperatorJSON[]} operators - Array of 6 operators * @property {Object} pitchEG - Pitch envelope generator (rates and levels) * @property {Object} lfo - Low frequency oscillator parameters * @property {Object} global - Global voice parameters (algorithm, feedback, transpose, etc.) */ /** * JSON representation of a DX7 voice with bank index * @typedef {Object} DX7VoiceIndexJSON * @memberof DX7Voice * @property {number} index - Voice index in bank (1-32) * @property {string} name - Voice/patch name * @property {DX7OperatorJSON[]} operators - Array of 6 operators * @property {Object} pitchEG - Pitch envelope parameters * @property {Object} lfo - LFO parameters * @property {Object} global - Global voice parameters */ /** * @typedef {Object} DX7BankJSON - JSON representation of a DX7 bank * @memberof DX7Voice * @property {string} version - Version string (e.g., "1.0") * @property {string} name - Bank name (e.g., filename) * @property {DX7VoiceIndexJSON[]} voices - Array of 32 voices */ /** * DX7 Voice (patch) structure * Represents a single DX7 voice/patch with 6 operators, algorithm selection, * LFO, pitch envelope, and global parameters. * * Supports two formats: * - **Packed format (128 bytes)**: DX7 internal format with bit-packed parameters * - **Unpacked format (169 bytes)**: Decompressed format with all parameters expanded * * Each voice contains: * - 6 FM operators with individual EGs, frequency, output level, and scaling * - Algorithm selection (1-32) for operator routing * - Feedback loop (0-7) for algorithm feedback * - LFO parameters (speed, delay, depth, wave shape) * - Pitch envelope generator (4 rates, 4 levels) * - Global parameters (transpose, pitch mod sensitivity, etc.) * - 10-character voice name * * @example * // Create a voice from packed DX7 bank data * const bankData = new Uint8Array(...); // 4096 bytes for 32 voices * const voiceIndex = 5; // 6th voice in bank * const voiceData = bankData.subarray(voiceIndex * 128, (voiceIndex + 1) * 128); * const voice = new DX7Voice(voiceData, voiceIndex); * console.log(voice.name); // e.g., "BASS 1" * * @example * // Load a voice from a single-voice SYX file * const file = document.getElementById("voice-file").files[0]; * const voice = await DX7Voice.fromFile(file); * console.log(voice.toJSON()); * * @example * // Create from JSON and export to SysEx * const json = loadVoiceData(); * const voice = DX7Voice.fromJSON(json); * const syxData = voice.toSysEx(); // For single voice synths like Volca FM * const packed = voice.data; // 128 bytes for DX7 bank * * @example * // Modify operator parameters * const voice = await DX7Voice.fromFile(file); * const unpacked = voice.unpack(); * unpacked[DX7Voice.UNPACKED_OP_OUTPUT_LEVEL] = 80; // Change OP1 output level * unpacked[DX7Voice.UNPACKED_ALGORITHM] = 5; // Change to algorithm 6 * const modifiedVoice = DX7Voice.fromUnpacked(unpacked); */ export class DX7Voice { static PACKED_SIZE: number; static PACKED_OP_SIZE: number; static NUM_OPERATORS: number; static PACKED_OP_EG_RATE_1: number; static PACKED_OP_EG_RATE_2: number; static PACKED_OP_EG_RATE_3: number; static PACKED_OP_EG_RATE_4: number; static PACKED_OP_EG_LEVEL_1: number; static PACKED_OP_EG_LEVEL_2: number; static PACKED_OP_EG_LEVEL_3: number; static PACKED_OP_EG_LEVEL_4: number; static PACKED_OP_BREAK_POINT: number; static PACKED_OP_L_SCALE_DEPTH: number; static PACKED_OP_R_SCALE_DEPTH: number; static PACKED_OP_CURVES: number; static PACKED_OP_RATE_SCALING: number; static PACKED_OP_MOD_SENS: number; static PACKED_OP_OUTPUT_LEVEL: number; static PACKED_OP_MODE_FREQ: number; static PACKED_OP_DETUNE_FINE: number; static PACKED_PITCH_EG_RATE_1: number; static PACKED_PITCH_EG_RATE_2: number; static PACKED_PITCH_EG_RATE_3: number; static PACKED_PITCH_EG_RATE_4: number; static PACKED_PITCH_EG_LEVEL_1: number; static PACKED_PITCH_EG_LEVEL_2: number; static PACKED_PITCH_EG_LEVEL_3: number; static PACKED_PITCH_EG_LEVEL_4: number; static OFFSET_ALGORITHM: number; static OFFSET_FEEDBACK: number; static OFFSET_LFO_SPEED: number; static OFFSET_LFO_DELAY: number; static OFFSET_LFO_PM_DEPTH: number; static OFFSET_LFO_AM_DEPTH: number; static OFFSET_LFO_SYNC_WAVE: number; static OFFSET_TRANSPOSE: number; static OFFSET_AMP_MOD_SENS: number; static OFFSET_EG_BIAS_SENS: number; static PACKED_NAME_START: number; static NAME_LENGTH: number; static UNPACKED_SIZE: number; static UNPACKED_OP_SIZE: number; static UNPACKED_OP_EG_RATE_1: number; static UNPACKED_OP_EG_RATE_2: number; static UNPACKED_OP_EG_RATE_3: number; static UNPACKED_OP_EG_RATE_4: number; static UNPACKED_OP_EG_LEVEL_1: number; static UNPACKED_OP_EG_LEVEL_2: number; static UNPACKED_OP_EG_LEVEL_3: number; static UNPACKED_OP_EG_LEVEL_4: number; static UNPACKED_OP_BREAK_POINT: number; static UNPACKED_OP_L_SCALE_DEPTH: number; static UNPACKED_OP_R_SCALE_DEPTH: number; static UNPACKED_OP_L_CURVE: number; static UNPACKED_OP_R_CURVE: number; static UNPACKED_OP_RATE_SCALING: number; static UNPACKED_OP_DETUNE: number; static UNPACKED_OP_AMP_MOD_SENS: number; static UNPACKED_OP_OUTPUT_LEVEL: number; static UNPACKED_OP_MODE: number; static UNPACKED_OP_KEY_VEL_SENS: number; static UNPACKED_OP_FREQ_COARSE: number; static UNPACKED_OP_FREQ_FINE: number; static UNPACKED_PITCH_EG_RATE_1: number; static UNPACKED_PITCH_EG_RATE_2: number; static UNPACKED_PITCH_EG_RATE_3: number; static UNPACKED_PITCH_EG_RATE_4: number; static UNPACKED_PITCH_EG_LEVEL_1: number; static UNPACKED_PITCH_EG_LEVEL_2: number; static UNPACKED_PITCH_EG_LEVEL_3: number; static UNPACKED_PITCH_EG_LEVEL_4: number; static UNPACKED_ALGORITHM: number; static UNPACKED_FEEDBACK: number; static UNPACKED_OSC_SYNC: number; static UNPACKED_LFO_SPEED: number; static UNPACKED_LFO_DELAY: number; static UNPACKED_LFO_PM_DEPTH: number; static UNPACKED_LFO_AM_DEPTH: number; static UNPACKED_LFO_KEY_SYNC: number; static UNPACKED_LFO_WAVE: number; static UNPACKED_LFO_PM_SENS: number; static UNPACKED_AMP_MOD_SENS: number; static UNPACKED_TRANSPOSE: number; static UNPACKED_EG_BIAS_SENS: number; static UNPACKED_NAME_START: number; static VCED_SIZE: number; static VCED_HEADER_SIZE: number; static VCED_DATA_SIZE: number; static VCED_SYSEX_START: number; static VCED_YAMAHA_ID: number; static VCED_SUB_STATUS: number; static VCED_FORMAT_SINGLE: number; static VCED_BYTE_COUNT_MSB: number; static VCED_BYTE_COUNT_LSB: number; static VCED_SYSEX_END: number; static MASK_7BIT: number; static MASK_2BIT: number; static MASK_3BIT: number; static MASK_4BIT: number; static MASK_5BIT: number; static MASK_1BIT: number; static TRANSPOSE_CENTER: number; static CHAR_YEN: number; static CHAR_ARROW_RIGHT: number; static CHAR_ARROW_LEFT: number; static CHAR_REPLACEMENT_Y: number; static CHAR_REPLACEMENT_GT: number; static CHAR_REPLACEMENT_LT: number; static CHAR_SPACE: number; static CHAR_MIN_PRINTABLE: number; static CHAR_MAX_PRINTABLE: number; static DEFAULT_EG_RATE: number; static DEFAULT_EG_LEVEL_MAX: number; static DEFAULT_EG_LEVEL_MIN: number; static DEFAULT_BREAK_POINT: number; static DEFAULT_OUTPUT_LEVEL: number; static DEFAULT_PITCH_EG_LEVEL: number; static DEFAULT_LFO_SPEED: number; static DEFAULT_LFO_PM_SENS: number; static DEFAULT_DETUNE: number; static DEFAULT_FREQ_COARSE: number; static DEFAULT_ALGORITHM: number; static DEFAULT_FEEDBACK: number; static DEFAULT_OSC_SYNC: number; static DEFAULT_LFO_KEY_SYNC: number; static MIDI_OCTAVE_OFFSET: number; static MIDI_BREAK_POINT_OFFSET: number; /** * Pack 169-byte unpacked data to 128-byte format * @param {Array|Uint8Array} unpacked - 169 bytes of unpacked data (159 parameters + 10 name bytes) * @returns {Uint8Array} 128 bytes of packed data */ static pack(unpacked: Array | Uint8Array): Uint8Array; /** * Pack all 6 operators from unpacked to packed format * @private */ private static _packOperators; /** * Pack a single operator's parameters * @private */ private static _packOperator; /** * Pack operator EG rates and levels * @private */ private static _packOperatorEG; /** * Pack operator keyboard scaling parameters * @private */ private static _packOperatorScaling; /** * Pack operator bit-packed parameters * @private */ private static _packOperatorPackedParams; /** * Pack operator frequency parameters * @private */ private static _packOperatorFrequency; /** * Pack pitch envelope generator parameters * @private */ private static _packPitchEG; /** * Pack global voice parameters (algorithm, feedback, LFO, etc.) * @private */ private static _packGlobalParams; /** * Copy voice name from unpacked to packed format * @private */ private static _packName; /** * Create a default/empty voice * @param {number} index - Voice index * @returns {DX7Voice} */ static createDefault(index?: number): DX7Voice; /** * Create a voice from unpacked 169-byte data * @param {Array|Uint8Array} unpacked - 169 bytes of unpacked data (159 parameters + 10 name bytes) * @param {number} index - Voice index * @returns {DX7Voice} */ static fromUnpacked(unpacked: Array | Uint8Array, index?: number): DX7Voice; /** * Load a DX7 voice from a single voice SYX file * @param {File|Blob} file - SYX file (single voice in VCED format) * @returns {Promise} * @throws {DX7ParseError} If file has invalid VCED header * @throws {Error} If file cannot be read (FileReader error) */ static fromFile(file: File | Blob): Promise; /** * Create a DX7Voice from SysEx data * @param {Array|ArrayBuffer|Uint8Array} data - Voice data (128 bytes of packed voice data) or VCED SysEx data (163 bytes with header/footer) * @param {number} index - Voice index (optional, defaults to 0) * @returns {DX7Voice} * @throws {DX7ParseError} If VCED header is invalid * @throws {DX7ValidationError} If data length is invalid */ static fromSysEx(data: Array | ArrayBuffer | Uint8Array, index?: number): DX7Voice; /** * Create a DX7Voice from a JSON object * @param {DX7VoiceJSON} json - JSON representation of a DX7 voice * @param {number} index - Voice index (optional, defaults to 0) * @returns {DX7Voice} * @throws {DX7ValidationError} If JSON structure is invalid */ static fromJSON(json: DX7VoiceJSON, index?: number): DX7Voice; /** * Create a DX7Voice from raw 128-byte data * @param {Array|Uint8Array} data - 128 bytes of voice data * @param {number} index - Voice index (0-31) * @throws {DX7ValidationError} If data length is not exactly 128 bytes */ constructor(data: Array | Uint8Array, index?: number); index: number; data: Uint8Array; name: string; _unpackedCache: Uint8Array; /** * Extract the voice name from the data (10 characters at offset 118) * @private */ private _extractName; /** * Get a raw parameter value from the packed data * @param {number} offset - Byte offset in the voice data (0-127) * @returns {number} Parameter value (0-127) * @throws {DX7ValidationError} If offset is out of range */ getParameter(offset: number): number; /** * Get a parameter value from the unpacked 169-byte format * @param {number} offset - Byte offset in the unpacked data (0-168) * @returns {number} Parameter value (0-127) * @throws {DX7ValidationError} If offset is out of range */ getUnpackedParameter(offset: number): number; /** * Set a raw parameter value in the packed data * @param {number} offset - Byte offset in the voice data * @param {number} value - Parameter value (0-127) */ setParameter(offset: number, value: number): void; /** * Unpack the voice data to 169-byte unpacked format * This converts the packed 128-byte format to the full DX7 parameter set * @returns {Uint8Array} 169 bytes of unpacked voice data (138 operator + 8 pitch EG + 13 global + 10 name = 169 bytes) */ unpack(): Uint8Array; /** * Unpack all 6 operators from packed to unpacked format * @private */ private _unpackOperators; /** * Unpack a single operator's parameters * @private */ private _unpackOperator; /** * Unpack operator EG rates and levels * @private */ private _unpackOperatorEG; /** * Unpack operator keyboard scaling parameters * @private */ private _unpackOperatorScaling; /** * Unpack operator bit-packed parameters (curves, rate scaling, mod sens) * @private */ private _unpackOperatorPackedParams; /** * Unpack operator frequency parameters * @private */ private _unpackOperatorFrequency; /** * Unpack pitch envelope generator parameters * @private */ private _unpackPitchEG; /** * Unpack global voice parameters (algorithm, feedback, LFO, etc.) * @private */ private _unpackGlobalParams; /** * Copy voice name from packed to unpacked format * @private */ private _unpackName; /** * Export voice to DX7 single voice SysEx format (VCED format) * This is useful for synths that only support single voice dumps (e.g., KORG Volca FM) * Converts from 169-byte unpacked format to 155-byte VCED format * @returns {Uint8Array} Single voice SysEx data (163 bytes) */ toSysEx(): Uint8Array; /** * Convert voice to JSON format * @returns {object} Voice data in JSON format */ toJSON(): object; } /** * JSON representation of a DX7 operator (human-readable) */ export type DX7OperatorJSON = any; /** * JSON representation of a DX7 voice (patch) */ export type DX7VoiceJSON = any; /** * JSON representation of a DX7 voice with bank index */ export type DX7VoiceIndexJSON = any; /** * - JSON representation of a DX7 bank */ export type DX7BankJSON = any; //# sourceMappingURL=DX7Voice.d.ts.map