UNPKG

snes-disassembler

Version:

A Super Nintendo (SNES) ROM disassembler for 65816 assembly

222 lines 6.29 kB
/** * SNES Audio Type Definitions * * This file contains TypeScript interfaces and types for SNES audio-related * data structures including BRR samples, SPC files, DSP registers, and * voice configurations used in audio processing and conversion. */ /** * BRR block header containing compression and loop information */ export interface BRRBlockHeader { /** Compression range (0-12, determines shift amount) */ range: number; /** Compression filter (0-3, affects how samples are decoded) */ filter: number; /** End flag - indicates if this is the last block */ end: boolean; /** Loop flag - indicates if playback should loop back */ loop: boolean; } /** * A single BRR compressed audio block (9 bytes total) */ export interface BRRBlock { /** Block header (1 byte) */ header: BRRBlockHeader; /** Compressed sample data (8 bytes, 16 4-bit samples) */ samples: number[]; } /** * SPC file header (standard SPC format) */ export interface SPCHeader { /** File signature "SNES-SPC700 Sound File Data" */ signature: string; /** Version marker (26-27) */ version: number; /** PC register value */ pc: number; /** A register value */ a: number; /** X register value */ x: number; /** Y register value */ y: number; /** PSW (Processor Status Word) */ psw: number; /** Stack pointer */ sp: number; /** Song title (32 bytes) */ title: string; /** Game title (32 bytes) */ game: string; /** Dumper name (16 bytes) */ dumper: string; /** Comments (32 bytes) */ comments: string; /** Date dumped (11 bytes) */ date: string; /** Seconds to play before fading */ playTime: number; /** Fade length in milliseconds */ fadeLength: number; /** Artist name (32 bytes) */ artist: string; /** Default channel disabled flags */ channelDisabled: number; /** Emulator used for dumping */ emulator: number; } /** * Complete SPC file structure */ export interface SPCFile { /** SPC file header */ header: SPCHeader; /** 64KB SPC700 RAM dump */ ram: Uint8Array; /** 128 bytes of DSP register data */ dspRegisters: Uint8Array; /** Extended ID666 tag data (optional) */ extendedTags?: Record<string, string>; } /** * DSP register constants for the Sony SPC700 DSP */ export declare const DSP_REGISTERS: { readonly VOICE_LEFT_VOL: 0; readonly VOICE_RIGHT_VOL: 1; readonly VOICE_PITCH_LOW: 2; readonly VOICE_PITCH_HIGH: 3; readonly VOICE_SRC_NUM: 4; readonly VOICE_ADSR1: 5; readonly VOICE_ADSR2: 6; readonly VOICE_GAIN: 7; readonly VOICE_ENV_VAL: 8; readonly VOICE_OUT_VAL: 9; readonly MAIN_LEFT_VOL: 12; readonly MAIN_RIGHT_VOL: 28; readonly ECHO_LEFT_VOL: 44; readonly ECHO_RIGHT_VOL: 60; readonly KEY_ON: 76; readonly KEY_OFF: 92; readonly FLAGS: 108; readonly ENDX: 124; readonly ECHO_FEEDBACK: 13; readonly PITCH_MOD: 45; readonly NOISE_ON: 61; readonly ECHO_ON: 77; readonly SOURCE_DIR: 93; readonly ECHO_START: 109; readonly ECHO_DELAY: 125; readonly FIR_C0: 15; readonly FIR_C1: 31; readonly FIR_C2: 47; readonly FIR_C3: 63; readonly FIR_C4: 79; readonly FIR_C5: 95; readonly FIR_C6: 111; readonly FIR_C7: 127; }; /** * ADSR (Attack, Decay, Sustain, Release) envelope parameters */ export interface ADSREnvelope { /** Attack rate (0-15) */ attack: number; /** Decay rate (0-7) */ decay: number; /** Sustain level (0-7) */ sustain: number; /** Release rate (0-31) */ release: number; /** Enable ADSR mode (vs GAIN mode) */ enabled: boolean; } /** * Alternative GAIN envelope parameters (when ADSR disabled) */ interface GainEnvelope { /** Gain mode (0=direct, 1=linear decrease, 2=exponential decrease, 3=linear increase, 4=bent increase) */ mode: number; /** Gain value (0-127) */ value: number; } /** * Voice configuration for a single DSP voice */ export interface VoiceConfig { /** Voice number (0-7) */ voiceNumber: number; /** Left channel volume (0-127, can be negative for phase inversion) */ leftVolume: number; /** Right channel volume (0-127, can be negative for phase inversion) */ rightVolume: number; /** Pitch value (0-16383, determines playback frequency) */ pitch: number; /** Source number (index into sample directory) */ sourceNumber: number; /** ADSR envelope settings */ adsr: ADSREnvelope; /** GAIN envelope settings (used when ADSR disabled) */ gain: GainEnvelope; /** Current envelope value (read-only) */ envelopeValue?: number; /** Current output value (read-only) */ outputValue?: number; } /** * Complete DSP state */ export interface DSPState { /** Configuration for all 8 voices */ voices: VoiceConfig[]; /** Main output volume (left/right) */ mainVolume: { left: number; right: number; }; /** Echo output volume (left/right) */ echoVolume: { left: number; right: number; }; /** Key on flags (which voices to start) */ keyOn: number; /** Key off flags (which voices to stop) */ keyOff: number; /** Solo flags (which voices to solo) */ solo: number; /** Noise enable flags */ noiseEnable: number; /** Echo enable flags */ echoEnable: number; /** Pitch modulation enable flags */ pitchModEnable: number; /** Source directory address */ sourceDirectory: number; /** Echo buffer start address */ echoStartAddress: number; /** Echo delay (buffer size) */ echoDelay: number; /** Echo feedback amount */ echoFeedback: number; /** FIR filter coefficients for echo */ firCoefficients: number[]; /** Global flags (reset, mute, echo write disable) */ flags: number; /** End flags for each voice (read-only) */ endFlags?: number; } /** * Sample directory entry (4 bytes each) */ export interface SampleDirectoryEntry { /** Start address of BRR sample */ startAddress: number; /** Loop address (where to restart when looping) */ loopAddress: number; } export {}; //# sourceMappingURL=audio-types.d.ts.map