summaryrefslogtreecommitdiff
path: root/plugins/gme/game-music-emu-0.6pre/gme/Sms_Fm_Apu.h
blob: 5fc2ea1ee37bb4d05bf36d4e2676ea3005daeed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef SMS_FM_APU_H
#define SMS_FM_APU_H

#include "Blip_Buffer.h"
#include "Ym2413_Emu.h"

class Sms_Fm_Apu {
public:
	static bool supported()                     { return Ym2413_Emu::supported(); }
	blargg_err_t init( double clock_rate, double sample_rate );
	
	void set_output( Blip_Buffer* b, Blip_Buffer* = NULL, Blip_Buffer* = NULL ) { output_ = b; }
	void volume( double v )                     { synth.volume( 0.4 / 4096 * v ); }
	void treble_eq( blip_eq_t const& eq )       { synth.treble_eq( eq ); }
	
	void reset();
	
	void write_addr( int data )                 { addr = data; }
	void write_data( blip_time_t, int data );
	
	void end_frame( blip_time_t t );

// Implementation
public:
	Sms_Fm_Apu();
	~Sms_Fm_Apu();
	BLARGG_DISABLE_NOTHROW
	enum { osc_count = 1 };
	void set_output( int i, Blip_Buffer* b, Blip_Buffer* = NULL, Blip_Buffer* = NULL ) { output_ = b; }

private:
	Blip_Buffer* output_;
	blip_time_t next_time;
	int last_amp;
	int addr;
	
	int clock_;
	int rate_;
	blip_time_t period_;
	
	Blip_Synth_Norm synth;
	Ym2413_Emu apu;
	
	void run_until( blip_time_t );
};

#endif