summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/ym2413_emu.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/ym2413_emu.c')
-rw-r--r--lib/rbcodec/codecs/libgme/ym2413_emu.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/ym2413_emu.c b/lib/rbcodec/codecs/libgme/ym2413_emu.c
new file mode 100644
index 0000000000..d9ada431ca
--- /dev/null
+++ b/lib/rbcodec/codecs/libgme/ym2413_emu.c
@@ -0,0 +1,45 @@
1// Game_Music_Emu 0.5.5. http://www.slack.net/~ant/
2
3#include "ym2413_emu.h"
4
5void Ym2413_init( struct Ym2413_Emu* this )
6{
7 this->last_time = disabled_time; this->out = 0;
8}
9
10int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate )
11{
12 OPLL_new ( &this->opll, clock_rate, sample_rate );
13 OPLL_reset_patch( &this->opll, OPLL_2413_TONE );
14
15 Ym2413_reset( this );
16 return 0;
17}
18
19void Ym2413_reset( struct Ym2413_Emu* this )
20{
21 OPLL_reset( &this->opll );
22 OPLL_setMask( &this->opll, 0 );
23}
24
25void Ym2413_write( struct Ym2413_Emu* this, int addr, int data )
26{
27 OPLL_writeIO( &this->opll, 0, addr );
28 OPLL_writeIO( &this->opll, 1, data );
29}
30
31void Ym2413_mute_voices( struct Ym2413_Emu* this, int mask )
32{
33 OPLL_setMask( &this->opll, mask );
34}
35
36void Ym2413_run( struct Ym2413_Emu* this, int pair_count, short* out )
37{
38 while ( pair_count-- )
39 {
40 int s = OPLL_calc( &this->opll ) << 1;
41 out [0] = s;
42 out [1] = s;
43 out += 2;
44 }
45}