LMMS
Loading...
Searching...
No Matches
Gb_Apu.h
Go to the documentation of this file.
1// Nintendo Game Boy PAPU sound chip emulator
2
3// Gb_Snd_Emu 0.1.5
4#ifndef GB_APU_H
5#define GB_APU_H
6
7#include "Gb_Oscs.h"
8
9class Gb_Apu {
10public:
11
12 // Set overall volume of all oscillators, where 1.0 is full volume
13 void volume( double );
14
15 // Set treble equalization
16 void treble_eq( const blip_eq_t& );
17
18 // Outputs can be assigned to a single buffer for mono output, or to three
19 // buffers for stereo output (using Stereo_Buffer to do the mixing).
20
21 // Assign all oscillator outputs to specified buffer(s). If buffer
22 // is NULL, silences all oscillators.
23 void output( Blip_Buffer* mono );
25
26 // Assign single oscillator output to buffer(s). Valid indicies are 0 to 3,
27 // which refer to Square 1, Square 2, Wave, and Noise. If buffer is NULL,
28 // silences oscillator.
29 enum { osc_count = 4 };
30 void osc_output( int index, Blip_Buffer* mono );
31 void osc_output( int index, Blip_Buffer* center, Blip_Buffer* left, Blip_Buffer* right );
32
33 // Reset oscillators and internal state
34 void reset();
35
36 // Reads and writes at addr must satisfy start_addr <= addr <= end_addr
37 enum { start_addr = 0xFF10 };
38 enum { end_addr = 0xFF3F };
40
41 // Write 'data' to address at specified time
42 void write_register( blip_time_t, unsigned addr, int data );
43
44 // Read from address at specified time
45 int read_register( blip_time_t, unsigned addr );
46
47 // Run all oscillators up to specified time, end current time frame, then
48 // start a new frame at time 0.
49 void end_frame( blip_time_t );
50
51 void set_tempo( double );
52
53public:
54 Gb_Apu();
55private:
56 // noncopyable
57 Gb_Apu( const Gb_Apu& );
59
66
72 Gb_Square::Synth square_synth; // used by squares
73 Gb_Wave::Synth other_synth; // used by wave and noise
74
75 void update_volume();
76 void run_until( blip_time_t );
77 void write_osc( int index, int reg, int data );
78};
79
80inline void Gb_Apu::output( Blip_Buffer* b ) { output( b, b, b ); }
81
82inline void Gb_Apu::osc_output( int i, Blip_Buffer* b ) { osc_output( i, b, b, b ); }
83
84inline void Gb_Apu::volume( double vol )
85{
86 volume_unit = 0.60 / osc_count / 15 /*steps*/ / 2 /*?*/ / 8 /*master vol range*/ * vol;
88}
89
90#endif
blip_long blip_time_t
Definition Blip_Buffer.h:17
Definition Blip_Buffer.h:23
void write_osc(int index, int reg, int data)
Definition Gb_Oscs.cpp:308
int read_register(blip_time_t, unsigned addr)
Definition Gb_Apu.cpp:286
Gb_Apu & operator=(const Gb_Apu &)
Gb_Square::Synth square_synth
Definition Gb_Apu.h:72
void end_frame(blip_time_t)
Definition Gb_Apu.cpp:188
@ end_addr
Definition Gb_Apu.h:38
uint8_t regs[register_count]
Definition Gb_Apu.h:71
void treble_eq(const blip_eq_t &)
Definition Gb_Apu.cpp:51
Gb_Wave wave
Definition Gb_Apu.h:69
void run_until(blip_time_t)
Definition Gb_Apu.cpp:129
void update_volume()
Definition Gb_Apu.cpp:74
Gb_Wave::Synth other_synth
Definition Gb_Apu.h:73
Gb_Apu()
Definition Gb_Apu.cpp:23
Gb_Noise noise
Definition Gb_Apu.h:70
void reset()
Definition Gb_Apu.cpp:102
blip_time_t last_time
Definition Gb_Apu.h:62
Gb_Osc * oscs[osc_count]
Definition Gb_Apu.h:60
void output(Blip_Buffer *mono)
Definition Gb_Apu.h:80
Gb_Apu(const Gb_Apu &)
Gb_Square square2
Definition Gb_Apu.h:68
int frame_count
Definition Gb_Apu.h:65
Gb_Square square1
Definition Gb_Apu.h:67
void volume(double)
Definition Gb_Apu.h:84
blip_time_t next_frame_time
Definition Gb_Apu.h:61
@ register_count
Definition Gb_Apu.h:39
void set_tempo(double)
Definition Gb_Apu.cpp:95
@ osc_count
Definition Gb_Apu.h:29
@ start_addr
Definition Gb_Apu.h:37
double volume_unit
Definition Gb_Apu.h:64
void osc_output(int index, Blip_Buffer *mono)
Definition Gb_Apu.h:82
blip_time_t frame_period
Definition Gb_Apu.h:63
void write_register(blip_time_t, unsigned addr, int data)
Definition Gb_Apu.cpp:200
Definition Blip_Buffer.h:239
register unsigned i
Definition inflate.c:1575
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 left
struct @113205115357366127300225113341150224053346037032::@137033172036070230260373056156374243321245367362 right
JSAMPIMAGE data
Definition jpeglib.h:945
unsigned char uint8_t
Definition mid.cpp:98
Definition Gb_Oscs.h:57
Definition Gb_Oscs.h:11
Definition Gb_Oscs.h:41
Blip_Synth< blip_good_quality, 1 > Synth
Definition Gb_Oscs.h:45
Definition Gb_Oscs.h:66
Blip_Synth< blip_med_quality, 1 > Synth
Definition Gb_Oscs.h:67
b
Definition crypt.c:628