diff options
Diffstat (limited to 'apps/codecs/libgme/ym2413_emu.h')
-rw-r--r-- | apps/codecs/libgme/ym2413_emu.h | 122 |
1 files changed, 61 insertions, 61 deletions
diff --git a/apps/codecs/libgme/ym2413_emu.h b/apps/codecs/libgme/ym2413_emu.h index 68d8fe3d8f..8f52b04fbd 100644 --- a/apps/codecs/libgme/ym2413_emu.h +++ b/apps/codecs/libgme/ym2413_emu.h | |||
@@ -1,61 +1,61 @@ | |||
1 | // YM2413 FM sound chip emulator interface | 1 | // YM2413 FM sound chip emulator interface |
2 | 2 | ||
3 | // Game_Music_Emu 0.6-pre | 3 | // Game_Music_Emu 0.6-pre |
4 | #ifndef YM2413_EMU_H | 4 | #ifndef YM2413_EMU_H |
5 | #define YM2413_EMU_H | 5 | #define YM2413_EMU_H |
6 | 6 | ||
7 | #include "blargg_common.h" | 7 | #include "blargg_common.h" |
8 | #include "emu2413.h" | 8 | #include "emu2413.h" |
9 | 9 | ||
10 | enum { out_chan_count = 2 }; // stereo | 10 | enum { out_chan_count = 2 }; // stereo |
11 | enum { channel_count = 14 }; | 11 | enum { channel_count = 14 }; |
12 | enum { disabled_time = -1 }; | 12 | enum { disabled_time = -1 }; |
13 | 13 | ||
14 | struct Ym2413_Emu { | 14 | struct Ym2413_Emu { |
15 | OPLL opll; | 15 | OPLL opll; |
16 | 16 | ||
17 | // Impl | 17 | // Impl |
18 | int last_time; | 18 | int last_time; |
19 | short* out; | 19 | short* out; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | void Ym2413_init( struct Ym2413_Emu* this ); | 22 | void Ym2413_init( struct Ym2413_Emu* this ); |
23 | 23 | ||
24 | static inline bool Ym2413_supported( void ) { return true; } | 24 | static inline bool Ym2413_supported( void ) { return true; } |
25 | 25 | ||
26 | // Sets output sample rate and chip clock rates, in Hz. Returns non-zero | 26 | // Sets output sample rate and chip clock rates, in Hz. Returns non-zero |
27 | // if error. | 27 | // if error. |
28 | int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); | 28 | int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); |
29 | 29 | ||
30 | // Resets to power-up state | 30 | // Resets to power-up state |
31 | void Ym2413_reset( struct Ym2413_Emu* this ); | 31 | void Ym2413_reset( struct Ym2413_Emu* this ); |
32 | 32 | ||
33 | // Mutes voice n if bit n (1 << n) of mask is set | 33 | // Mutes voice n if bit n (1 << n) of mask is set |
34 | void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ); | 34 | void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ); |
35 | 35 | ||
36 | // Writes data to addr | 36 | // Writes data to addr |
37 | void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ); | 37 | void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ); |
38 | 38 | ||
39 | // Runs and writes pair_count*2 samples to output | 39 | // Runs and writes pair_count*2 samples to output |
40 | void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ); | 40 | void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ); |
41 | 41 | ||
42 | static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; } | 42 | static inline void Ym2413_enable( struct Ym2413_Emu* this, bool b ) { this->last_time = b ? 0 : disabled_time; } |
43 | static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; } | 43 | static inline bool Ym2413_enabled( struct Ym2413_Emu* this ) { return this->last_time != disabled_time; } |
44 | static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; } | 44 | static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; } |
45 | 45 | ||
46 | static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time ) | 46 | static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time ) |
47 | { | 47 | { |
48 | int count = time - this->last_time; | 48 | int count = time - this->last_time; |
49 | if ( count > 0 ) | 49 | if ( count > 0 ) |
50 | { | 50 | { |
51 | if ( this->last_time < 0 ) | 51 | if ( this->last_time < 0 ) |
52 | return false; | 52 | return false; |
53 | this->last_time = time; | 53 | this->last_time = time; |
54 | short* p = this->out; | 54 | short* p = this->out; |
55 | this->out += count * out_chan_count; | 55 | this->out += count * out_chan_count; |
56 | Ym2413_run( this, count, p ); | 56 | Ym2413_run( this, count, p ); |
57 | } | 57 | } |
58 | return true; | 58 | return true; |
59 | } | 59 | } |
60 | 60 | ||
61 | #endif | 61 | #endif |