Mercurial > spc_convert
view snes_spc/dsp.h @ 5:b6e64e348e47
script will restore lost files now
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 21 Oct 2011 07:12:40 -0700 |
parents | e38dacceb958 |
children |
line wrap: on
line source
1 /* SNES SPC-700 DSP emulator C interface (also usable from C++) */3 /* snes_spc 0.9.0 */4 #ifndef DSP_H5 #define DSP_H7 #include <stddef.h>9 #ifdef __cplusplus10 extern "C" {11 #endif13 typedef struct SPC_DSP SPC_DSP;15 /* Creates new DSP emulator. NULL if out of memory. */16 SPC_DSP* spc_dsp_new( void );18 /* Frees DSP emulator */19 void spc_dsp_delete( SPC_DSP* );21 /* Initializes DSP and has it use the 64K RAM provided */22 void spc_dsp_init( SPC_DSP*, void* ram_64k );24 /* Sets destination for output samples. If out is NULL or out_size is 0,25 doesn't generate any. */26 typedef short spc_dsp_sample_t;27 void spc_dsp_set_output( SPC_DSP*, spc_dsp_sample_t* out, int out_size );29 /* Number of samples written to output since it was last set, always30 a multiple of 2. Undefined if more samples were generated than31 output buffer could hold. */32 int spc_dsp_sample_count( SPC_DSP const* );35 /**** Emulation *****/37 /* Resets DSP to power-on state */38 void spc_dsp_reset( SPC_DSP* );40 /* Emulates pressing reset switch on SNES */41 void spc_dsp_soft_reset( SPC_DSP* );43 /* Reads/writes DSP registers. For accuracy, you must first call spc_dsp_run() */44 /* to catch the DSP up to present. */45 int spc_dsp_read ( SPC_DSP const*, int addr );46 void spc_dsp_write( SPC_DSP*, int addr, int data );48 /* Runs DSP for specified number of clocks (~1024000 per second). Every 32 clocks */49 /* a pair of samples is be generated. */50 void spc_dsp_run( SPC_DSP*, int clock_count );53 /**** Sound control *****/55 /* Mutes voices corresponding to non-zero bits in mask. Reduces emulation accuracy. */56 enum { spc_dsp_voice_count = 8 };57 void spc_dsp_mute_voices( SPC_DSP*, int mask );59 /* If true, prevents channels and global volumes from being phase-negated.60 Only supported by fast DSP; has no effect on accurate DSP. */61 void spc_dsp_disable_surround( SPC_DSP*, int disable );64 /**** State save/load *****/66 /* Resets DSP and uses supplied values to initialize registers */67 enum { spc_dsp_register_count = 128 };68 void spc_dsp_load( SPC_DSP*, unsigned char const regs [spc_dsp_register_count] );70 /* Saves/loads exact emulator state (accurate DSP only) */71 enum { spc_dsp_state_size = 640 }; /* maximum space needed when saving */72 typedef void (*spc_dsp_copy_func_t)( unsigned char** io, void* state, size_t );73 void spc_dsp_copy_state( SPC_DSP*, unsigned char** io, spc_dsp_copy_func_t );75 /* Returns non-zero if new key-on events occurred since last call (accurate DSP only) */76 int spc_dsp_check_kon( SPC_DSP* );79 #ifdef __cplusplus80 }81 #endif83 #endif