Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
folium-app
GitHub Repository: folium-app/Folium
Path: blob/a-new-beginning/Cherry/Core/include/audio/Sms_Apu.h
2 views
1
// Sega Master System SN76489 PSG sound chip emulator
2
3
// Sms_Snd_Emu 0.1.4
4
#ifndef SMS_APU_H
5
#define SMS_APU_H
6
7
#include "Sms_Oscs.h"
8
9
class Sms_Apu {
10
public:
11
// Set overall volume of all oscillators, where 1.0 is full volume
12
void volume( double );
13
14
// Set treble equalization
15
void treble_eq( const blip_eq_t& );
16
17
// Outputs can be assigned to a single buffer for mono output, or to three
18
// buffers for stereo output (using Stereo_Buffer to do the mixing).
19
20
// Assign all oscillator outputs to specified buffer(s). If buffer
21
// is NULL, silences all oscillators.
22
void output( Blip_Buffer* mono );
23
void output( Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right );
24
25
// Assign single oscillator output to buffer(s). Valid indicies are 0 to 3,
26
// which refer to Square 1, Square 2, Square 3, and Noise. If buffer is NULL,
27
// silences oscillator.
28
enum { osc_count = 4 };
29
void osc_output( int index, Blip_Buffer* mono );
30
void osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right );
31
32
// Reset oscillators and internal state
33
void reset( unsigned noise_feedback = 0, int noise_width = 0 );
34
35
// Write GameGear left/right assignment byte
36
void write_ggstereo( blip_time_t, int );
37
38
// Write to data port
39
void write_data( blip_time_t, int );
40
41
// Run all oscillators up to specified time, end current frame, then
42
// start a new frame at time 0.
43
void end_frame( blip_time_t );
44
45
public:
46
Sms_Apu();
47
~Sms_Apu();
48
private:
49
// noncopyable
50
Sms_Apu( const Sms_Apu& );
51
Sms_Apu& operator = ( const Sms_Apu& );
52
53
Sms_Osc* oscs [osc_count];
54
Sms_Square squares [3];
55
Sms_Square::Synth square_synth; // used by squares
56
blip_time_t last_time;
57
int latch;
58
Sms_Noise noise;
59
unsigned noise_feedback;
60
unsigned looped_feedback;
61
unsigned int ggstereo_save;
62
63
void run_until( blip_time_t );
64
};
65
66
inline void Sms_Apu::output( Blip_Buffer* b ) { output( b, b, b ); }
67
68
inline void Sms_Apu::osc_output( int i, Blip_Buffer* b ) { osc_output( i, b, b, b ); }
69
70
#endif
71
72