Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/quicknes/nes_emu/Nes_Buffer.h
2 views
1
2
// NES non-linear audio buffer
3
4
// Nes_Emu 0.7.0
5
6
#ifndef NES_BUFFER_H
7
#define NES_BUFFER_H
8
9
#include "Multi_Buffer.h"
10
class Nes_Apu;
11
12
class Nes_Nonlinearizer {
13
private:
14
enum { table_bits = 11 };
15
enum { table_size = 1 << table_bits };
16
BOOST::int16_t table [table_size];
17
Nes_Apu* apu;
18
long accum;
19
long prev;
20
21
public:
22
Nes_Nonlinearizer();
23
bool enabled;
24
void clear();
25
void set_apu( Nes_Apu* a ) { apu = a; }
26
Nes_Apu* enable( bool, Blip_Buffer* tnd );
27
long make_nonlinear( Blip_Buffer& buf, long count );
28
};
29
30
class Nes_Buffer : public Multi_Buffer {
31
public:
32
Nes_Buffer();
33
~Nes_Buffer();
34
35
// Setup APU for use with buffer, including setting its output to this buffer.
36
// If you're using Nes_Emu, this is automatically called for you.
37
void set_apu( Nes_Apu* apu ) { nonlin.set_apu( apu ); }
38
39
// Enable/disable non-linear output
40
void enable_nonlinearity( bool = true );
41
42
// Blip_Buffer to output other sound chips to
43
Blip_Buffer* buffer() { return &buf; }
44
45
// See Multi_Buffer.h
46
blargg_err_t set_sample_rate( long rate, int msec = blip_default_length );
47
48
#if 0 // What is this?
49
Multi_Buffer::sample_rate;
50
#endif
51
52
void clock_rate( long );
53
void bass_freq( int );
54
void clear();
55
channel_t channel( int );
56
void end_frame( blip_time_t, bool unused = true );
57
long samples_avail() const;
58
long read_samples( blip_sample_t*, long );
59
60
private:
61
Blip_Buffer buf;
62
Blip_Buffer tnd;
63
Nes_Nonlinearizer nonlin;
64
friend Multi_Buffer* set_apu( Nes_Buffer*, Nes_Apu* );
65
};
66
67
#endif
68
69
70