Submit initial patch from FS#12176. Adds support for several new game music formats...
[kugel-rb.git] / apps / codecs / libgme / sms_apu.h
blob25f4e74ae502ea53e1f6a603963f679b57e1c65d
1 // Sega Master System SN76489 PSG sound chip emulator
3 // Sms_Snd_Emu 0.1.2
4 #ifndef SMS_APU_H
5 #define SMS_APU_H
7 #include "blargg_common.h"
8 #include "blip_buffer.h"
10 // 0: Square 1, 1: Square 2, 2: Square 3, 3: Noise
11 enum { sms_osc_count = 4 }; // 0 <= chan < osc_count
13 struct Osc
15 struct Blip_Buffer* outputs [4]; // NULL, right, left, center
16 struct Blip_Buffer* output;
17 int last_amp;
19 int volume;
20 int period;
21 int delay;
22 unsigned phase;
25 struct Sms_Apu {
26 struct Osc oscs [sms_osc_count];
27 int ggstereo;
28 int latch;
30 blip_time_t last_time;
31 int min_tone_period;
32 unsigned noise_feedback;
33 unsigned looped_feedback;
34 struct Blip_Synth synth;
37 // Basics
39 void Sms_apu_init( struct Sms_Apu* this );
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);
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 ) ICODE_ATTR;
48 // Emulates to time t, then writes data
49 void Sms_apu_write_data( struct Sms_Apu* this, blip_time_t t, int data ) ICODE_ATTR;
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 ) ICODE_ATTR;
55 // More features
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 );
60 // Sets overall volume, where 1.0 is normal
61 void Sms_apu_volume( struct Sms_Apu* this, double vol );
63 #endif