Submit initial patch from FS#12176. Adds support for several new game music formats...
[kugel-rb.git] / apps / codecs / libgme / nes_vrc7_apu.h
blob5453e6b4030cc97318e2a6a8810e0895523fbc62
1 // Konami VRC7 sound chip emulator
3 #ifndef NES_VRC7_APU_H
4 #define NES_VRC7_APU_H
6 #include "blargg_common.h"
7 #include "blip_buffer.h"
9 #include "emu2413.h"
11 enum { vrc7_osc_count = 6 };
13 struct vrc7_osc_t {
14 struct Blip_Buffer* output;
15 int last_amp;
18 struct Nes_Vrc7_Apu {
19 OPLL opll;
20 int addr;
21 blip_time_t next_time;
22 struct vrc7_osc_t osc;
23 struct Blip_Synth synth;
24 e_uint32 mask;
27 // See Nes_Apu.h for reference
28 void Vrc7_init( struct Nes_Vrc7_Apu* this );
29 void Vrc7_reset( struct Nes_Vrc7_Apu* this );
30 void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, double r );
31 void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ) ICODE_ATTR;
33 void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ) ICODE_ATTR;
34 void Vrc7_write_data( struct Nes_Vrc7_Apu* this, blip_time_t, int data ) ICODE_ATTR;
36 void output_changed( struct Nes_Vrc7_Apu* this );
37 static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Blip_Buffer* buf )
39 assert( (unsigned) i < vrc7_osc_count );
40 this->mask |= 1 << i;
42 // Will use OPLL_setMask to mute voices
43 if ( buf ) {
44 this->mask ^= 1 << i;
45 this->osc.output = buf;
49 // DB2LIN_AMP_BITS == 11, * 2
50 static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / 3 / 4096 * v ); }
52 #endif