diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/ym2413_emu.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libgme/ym2413_emu.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/ym2413_emu.h | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/ym2413_emu.h b/lib/rbcodec/codecs/libgme/ym2413_emu.h new file mode 100644 index 0000000000..8f52b04fbd --- /dev/null +++ b/lib/rbcodec/codecs/libgme/ym2413_emu.h | |||
@@ -0,0 +1,61 @@ | |||
1 | // YM2413 FM sound chip emulator interface | ||
2 | |||
3 | // Game_Music_Emu 0.6-pre | ||
4 | #ifndef YM2413_EMU_H | ||
5 | #define YM2413_EMU_H | ||
6 | |||
7 | #include "blargg_common.h" | ||
8 | #include "emu2413.h" | ||
9 | |||
10 | enum { out_chan_count = 2 }; // stereo | ||
11 | enum { channel_count = 14 }; | ||
12 | enum { disabled_time = -1 }; | ||
13 | |||
14 | struct Ym2413_Emu { | ||
15 | OPLL opll; | ||
16 | |||
17 | // Impl | ||
18 | int last_time; | ||
19 | short* out; | ||
20 | }; | ||
21 | |||
22 | void Ym2413_init( struct Ym2413_Emu* this ); | ||
23 | |||
24 | static inline bool Ym2413_supported( void ) { return true; } | ||
25 | |||
26 | // Sets output sample rate and chip clock rates, in Hz. Returns non-zero | ||
27 | // if error. | ||
28 | int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); | ||
29 | |||
30 | // Resets to power-up state | ||
31 | void Ym2413_reset( struct Ym2413_Emu* this ); | ||
32 | |||
33 | // Mutes voice n if bit n (1 << n) of mask is set | ||
34 | void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask ); | ||
35 | |||
36 | // Writes data to addr | ||
37 | void Ym2413_write( struct Ym2413_Emu* this, int addr, int data ); | ||
38 | |||
39 | // Runs and writes pair_count*2 samples to output | ||
40 | void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out ); | ||
41 | |||
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; } | ||
44 | static inline void Ym2413_begin_frame( struct Ym2413_Emu* this, short* buf ) { this->out = buf; this->last_time = 0; } | ||
45 | |||
46 | static inline int Ym2413_run_until( struct Ym2413_Emu* this, int time ) | ||
47 | { | ||
48 | int count = time - this->last_time; | ||
49 | if ( count > 0 ) | ||
50 | { | ||
51 | if ( this->last_time < 0 ) | ||
52 | return false; | ||
53 | this->last_time = time; | ||
54 | short* p = this->out; | ||
55 | this->out += count * out_chan_count; | ||
56 | Ym2413_run( this, count, p ); | ||
57 | } | ||
58 | return true; | ||
59 | } | ||
60 | |||
61 | #endif | ||