summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/ym2413_emu.c
diff options
context:
space:
mode:
authorSean Bartell <wingedtachikoma@gmail.com>2011-06-25 21:32:25 -0400
committerNils Wallménius <nils@rockbox.org>2012-04-25 22:13:20 +0200
commitf40bfc9267b13b54e6379dfe7539447662879d24 (patch)
tree9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/ym2413_emu.c
parenta0009907de7a0107d49040d8a180f140e2eff299 (diff)
downloadrockbox-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.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}