Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/quicknes/nes_emu/Effects_Buffer.h
2 views
1
2
// Multi-channel effects buffer with panning, echo and reverb
3
4
// Game_Music_Emu 0.3.0
5
6
#ifndef EFFECTS_BUFFER_H
7
#define EFFECTS_BUFFER_H
8
9
#include "Multi_Buffer.h"
10
11
// Effects_Buffer uses several buffers and outputs stereo sample pairs.
12
class Effects_Buffer : public Multi_Buffer {
13
public:
14
// If center_only is true, only center buffers are created and
15
// less memory is used.
16
Effects_Buffer( bool center_only = false );
17
18
// Channel Effect Center Pan
19
// ---------------------------------
20
// 0,5 reverb pan_1
21
// 1,6 reverb pan_2
22
// 2,7 echo -
23
// 3 echo -
24
// 4 echo -
25
26
// Channel configuration
27
struct config_t {
28
double pan_1; // -1.0 = left, 0.0 = center, 1.0 = right
29
double pan_2;
30
double echo_delay; // msec
31
double echo_level; // 0.0 to 1.0
32
double reverb_delay; // msec
33
double delay_variance; // difference between left/right delays (msec)
34
double reverb_level; // 0.0 to 1.0
35
bool effects_enabled; // if false, use optimized simple mixer
36
config_t();
37
};
38
39
// Set configuration of buffer
40
virtual void config( const config_t& );
41
void set_depth( double );
42
43
public:
44
~Effects_Buffer();
45
blargg_err_t set_sample_rate( long samples_per_sec, int msec = blip_default_length );
46
void clock_rate( long );
47
void bass_freq( int );
48
void clear();
49
channel_t channel( int );
50
void end_frame( blip_time_t, bool was_stereo = true );
51
long read_samples( blip_sample_t*, long );
52
long samples_avail() const;
53
private:
54
typedef long fixed_t;
55
56
enum { max_buf_count = 7 };
57
Blip_Buffer bufs [max_buf_count];
58
enum { chan_count = 5 };
59
channel_t channels [chan_count];
60
config_t config_;
61
long stereo_remain;
62
long effect_remain;
63
int buf_count;
64
bool effects_enabled;
65
66
blip_sample_t* reverb_buf;
67
blip_sample_t* echo_buf;
68
int reverb_pos;
69
int echo_pos;
70
71
struct {
72
fixed_t pan_1_levels [2];
73
fixed_t pan_2_levels [2];
74
int echo_delay_l;
75
int echo_delay_r;
76
fixed_t echo_level;
77
int reverb_delay_l;
78
int reverb_delay_r;
79
fixed_t reverb_level;
80
} chans;
81
82
void mix_mono( blip_sample_t*, long );
83
void mix_stereo( blip_sample_t*, long );
84
void mix_enhanced( blip_sample_t*, long );
85
void mix_mono_enhanced( blip_sample_t*, long );
86
};
87
88
inline Effects_Buffer::channel_t Effects_Buffer::channel( int i ) {
89
return channels [i % chan_count];
90
}
91
92
#endif
93
94
95