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/sms_apu.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/sms_apu.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/sms_apu.h | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/lib/rbcodec/codecs/libgme/sms_apu.h b/lib/rbcodec/codecs/libgme/sms_apu.h new file mode 100644 index 0000000000..6dd65591ce --- /dev/null +++ b/lib/rbcodec/codecs/libgme/sms_apu.h | |||
@@ -0,0 +1,63 @@ | |||
1 | // Sega Master System SN76489 PSG sound chip emulator | ||
2 | |||
3 | // Sms_Snd_Emu 0.1.2 | ||
4 | #ifndef SMS_APU_H | ||
5 | #define SMS_APU_H | ||
6 | |||
7 | #include "blargg_common.h" | ||
8 | #include "blip_buffer.h" | ||
9 | |||
10 | // 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise | ||
11 | enum { sms_osc_count = 4 }; // 0 <= chan < osc_count | ||
12 | |||
13 | struct Osc | ||
14 | { | ||
15 | struct Blip_Buffer* outputs [4]; // NULL, right, left, center | ||
16 | struct Blip_Buffer* output; | ||
17 | int last_amp; | ||
18 | |||
19 | int volume; | ||
20 | int period; | ||
21 | int delay; | ||
22 | unsigned phase; | ||
23 | }; | ||
24 | |||
25 | struct Sms_Apu { | ||
26 | struct Osc oscs [sms_osc_count]; | ||
27 | int ggstereo; | ||
28 | int latch; | ||
29 | |||
30 | blip_time_t last_time; | ||
31 | int min_tone_period; | ||
32 | unsigned noise_feedback; | ||
33 | unsigned looped_feedback; | ||
34 | struct Blip_Synth synth; | ||
35 | }; | ||
36 | |||
37 | // Basics | ||
38 | |||
39 | void Sms_apu_init( struct Sms_Apu* this ); | ||
40 | |||
41 | // Sets buffer(s) to generate sound into, or 0 to mute. If only center is not 0, | ||
42 | // output is mono. | ||
43 | void Sms_apu_set_output( struct Sms_Apu* this, int i, struct Blip_Buffer* center, struct Blip_Buffer* left, struct Blip_Buffer* right); | ||
44 | |||
45 | // Emulates to time t, then writes data to Game Gear left/right assignment byte | ||
46 | void Sms_apu_write_ggstereo( struct Sms_Apu* this, blip_time_t t, int data ); | ||
47 | |||
48 | // Emulates to time t, then writes data | ||
49 | void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t t, int data ); | ||
50 | |||
51 | // Emulates to time t, then subtracts t from the current time. | ||
52 | // OK if previous write call had time slightly after t. | ||
53 | void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t t ); | ||
54 | |||
55 | // More features | ||
56 | |||
57 | // Resets sound chip and sets noise feedback bits and width | ||
58 | void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); | ||
59 | |||
60 | // Sets overall volume, where 1.0 is normal | ||
61 | void Sms_apu_volume( struct Sms_Apu* this, int vol ); | ||
62 | |||
63 | #endif | ||