Browse code

[GSF] Some more code cleanup, also removed a few files that were unneeded.

Naram Qashat authored on 2013/05/16 01:25:34
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,141 +0,0 @@
1
-// Multi-channel effects buffer with echo and individual panning for each channel
2
-
3
-// Game_Music_Emu $vers
4
-#ifndef EFFECTS_BUFFER_H
5
-#define EFFECTS_BUFFER_H
6
-
7
-#include <vector>
8
-#include "Multi_Buffer.h"
9
-
10
-// See Simple_Effects_Buffer (below) for a simpler interface
11
-
12
-class Effects_Buffer : public Multi_Buffer
13
-{
14
-public:
15
-	// To reduce memory usage, fewer buffers can be used (with a best-fit
16
-	// approach if there are too few), and maximum echo delay can be reduced
17
-	Effects_Buffer(int max_bufs = 32, long echo_size = 24 * 1024L);
18
-
19
-	struct pan_vol_t
20
-	{
21
-		float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal
22
-		float pan; // -1.0 = left, 0.0 = center, +1.0 = right
23
-	};
24
-
25
-	// Global configuration
26
-	struct config_t
27
-	{
28
-		bool enabled; // false = disable all effects
29
-
30
-		// Current sound is echoed at adjustable left/right delay,
31
-		// with reduced treble and volume (feedback).
32
-		float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent
33
-		int delay [2]; // left, right delays (msec)
34
-		float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
35
-		pan_vol_t side_chans[2]; // left and right side channel volume and pan
36
-	};
37
-	config_t &config() { return this->config_; }
38
-
39
-	// Limits of delay (msec)
40
-	int min_delay() const;
41
-	int max_delay() const;
42
-
43
-	// Per-channel configuration. Two or more channels with matching parameters are
44
-	// optimized to internally use the same buffer.
45
-	struct chan_config_t : pan_vol_t
46
-	{
47
-		// (inherited from pan_vol_t)
48
-		//float vol; // these only affect center channel
49
-		//float pan;
50
-		bool surround; // if true, negates left volume to put sound in back
51
-		bool echo; // false = channel doesn't have any echo
52
-	};
53
-	chan_config_t &chan_config(int i) { return this->chans[i + extra_chans].cfg; }
54
-
55
-	// Apply any changes made to config() and chan_config()
56
-	virtual void apply_config();
57
-
58
-	~Effects_Buffer();
59
-	blargg_err_t set_sample_rate(long samples_per_sec, int msec = blip_default_length);
60
-	blargg_err_t set_channel_count(int, const int * = nullptr);
61
-	void clock_rate(long);
62
-	void bass_freq(int);
63
-	void clear();
64
-	channel_t channel(int);
65
-	void end_frame(blip_time_t);
66
-	long read_samples(blip_sample_t *, long);
67
-	long samples_avail() const { return (this->bufs[0]->samples_avail() - this->mixer.samples_read) * 2; }
68
-	enum { stereo = 2 };
69
-	typedef int32_t fixed_t;
70
-protected:
71
-	enum { extra_chans = stereo * stereo };
72
-private:
73
-	config_t config_;
74
-	long clock_rate_;
75
-	int bass_freq_;
76
-
77
-	int32_t echo_size;
78
-
79
-	struct chan_t
80
-	{
81
-		fixed_t vol [stereo];
82
-		chan_config_t cfg;
83
-		channel_t channel;
84
-	};
85
-	std::vector<chan_t> chans;
86
-
87
-	struct buf_t : Tracked_Blip_Buffer
88
-	{
89
-		fixed_t vol[stereo];
90
-		bool echo;
91
-	};
92
-	std::vector<std::unique_ptr<buf_t>> bufs;
93
-	int bufs_size;
94
-	int bufs_max; // bufs_size <= bufs_max, to limit memory usage
95
-	Stereo_Mixer mixer;
96
-
97
-	struct
98
-	{
99
-		long delay[stereo];
100
-		fixed_t treble;
101
-		fixed_t feedback;
102
-		fixed_t low_pass[stereo];
103
-	} s;
104
-
105
-	std::vector<fixed_t> echo;
106
-	int32_t echo_pos;
107
-
108
-	bool no_effects;
109
-	bool no_echo;
110
-
111
-	void assign_buffers();
112
-	void clear_echo();
113
-	void mix_effects(blip_sample_t *out, int pair_count);
114
-	blargg_err_t new_bufs(int size);
115
-	void delete_bufs();
116
-};
117
-
118
-// Simpler interface and lower memory usage
119
-class Simple_Effects_Buffer : public Effects_Buffer
120
-{
121
-public:
122
-	struct config_t
123
-	{
124
-		bool enabled; // false = disable all effects
125
-		float echo; // 0.0 = none, 1.0 = lots
126
-		float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
127
-		bool surround; // true = put some channels in back
128
-	};
129
-	config_t &config() { return this->config_; }
130
-
131
-	// Apply any changes made to config()
132
-	void apply_config();
133
-
134
-public:
135
-	Simple_Effects_Buffer();
136
-private:
137
-	config_t config_;
138
-	void chan_config(); // hide
139
-};
140
-
141
-#endif
Browse code

[GSF] Massive code cleanup.

(As an aside, blargg's code style makes me go blarg myself.)

Naram Qashat authored on 2013/05/14 01:07:18
Showing 1 changed files
... ...
@@ -4,15 +4,17 @@
4 4
 #ifndef EFFECTS_BUFFER_H
5 5
 #define EFFECTS_BUFFER_H
6 6
 
7
+#include <vector>
7 8
 #include "Multi_Buffer.h"
8 9
 
9 10
 // See Simple_Effects_Buffer (below) for a simpler interface
10 11
 
11
-class Effects_Buffer : public Multi_Buffer {
12
+class Effects_Buffer : public Multi_Buffer
13
+{
12 14
 public:
13 15
 	// To reduce memory usage, fewer buffers can be used (with a best-fit
14 16
 	// approach if there are too few), and maximum echo delay can be reduced
15
-	Effects_Buffer( int max_bufs = 32, long echo_size = 24 * 1024L );
17
+	Effects_Buffer(int max_bufs = 32, long echo_size = 24 * 1024L);
16 18
 
17 19
 	struct pan_vol_t
18 20
 	{
... ...
@@ -27,12 +29,12 @@ public:
27 29
 
28 30
 		// Current sound is echoed at adjustable left/right delay,
29 31
 		// with reduced treble and volume (feedback).
30
-		float treble;   // 1.0 = full treble, 0.1 = very little, 0.0 = silent
31
-		int delay [2];  // left, right delays (msec)
32
+		float treble; // 1.0 = full treble, 0.1 = very little, 0.0 = silent
33
+		int delay [2]; // left, right delays (msec)
32 34
 		float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
33
-		pan_vol_t side_chans [2]; // left and right side channel volume and pan
35
+		pan_vol_t side_chans[2]; // left and right side channel volume and pan
34 36
 	};
35
-	config_t& config() { return config_; }
37
+	config_t &config() { return this->config_; }
36 38
 
37 39
 	// Limits of delay (msec)
38 40
 	int min_delay() const;
... ...
@@ -43,29 +45,28 @@ public:
43 45
 	struct chan_config_t : pan_vol_t
44 46
 	{
45 47
 		// (inherited from pan_vol_t)
46
-		//float vol;        // these only affect center channel
48
+		//float vol; // these only affect center channel
47 49
 		//float pan;
48
-		bool surround;  // if true, negates left volume to put sound in back
49
-		bool echo;      // false = channel doesn't have any echo
50
+		bool surround; // if true, negates left volume to put sound in back
51
+		bool echo; // false = channel doesn't have any echo
50 52
 	};
51
-	chan_config_t& chan_config( int i ) { return chans [i + extra_chans].cfg; }
53
+	chan_config_t &chan_config(int i) { return this->chans[i + extra_chans].cfg; }
52 54
 
53 55
 	// Apply any changes made to config() and chan_config()
54 56
 	virtual void apply_config();
55 57
 
56
-public:
57 58
 	~Effects_Buffer();
58
-	blargg_err_t set_sample_rate( long samples_per_sec, int msec = blip_default_length );
59
-	blargg_err_t set_channel_count( int, int const* = 0 );
60
-	void clock_rate( long );
61
-	void bass_freq( int );
59
+	blargg_err_t set_sample_rate(long samples_per_sec, int msec = blip_default_length);
60
+	blargg_err_t set_channel_count(int, const int * = nullptr);
61
+	void clock_rate(long);
62
+	void bass_freq(int);
62 63
 	void clear();
63
-	channel_t channel( int );
64
-	void end_frame( blip_time_t );
65
-	long read_samples( blip_sample_t*, long );
66
-	long samples_avail() const { return (bufs [0].samples_avail() - mixer.samples_read) * 2; }
64
+	channel_t channel(int);
65
+	void end_frame(blip_time_t);
66
+	long read_samples(blip_sample_t *, long);
67
+	long samples_avail() const { return (this->bufs[0]->samples_avail() - this->mixer.samples_read) * 2; }
67 68
 	enum { stereo = 2 };
68
-	typedef blargg_long fixed_t;
69
+	typedef int32_t fixed_t;
69 70
 protected:
70 71
 	enum { extra_chans = stereo * stereo };
71 72
 private:
... ...
@@ -73,7 +74,7 @@ private:
73 74
 	long clock_rate_;
74 75
 	int bass_freq_;
75 76
 
76
-	blargg_long echo_size;
77
+	int32_t echo_size;
77 78
 
78 79
 	struct chan_t
79 80
 	{
... ...
@@ -81,54 +82,51 @@ private:
81 82
 		chan_config_t cfg;
82 83
 		channel_t channel;
83 84
 	};
84
-	blargg_vector<chan_t> chans;
85
+	std::vector<chan_t> chans;
85 86
 
86 87
 	struct buf_t : Tracked_Blip_Buffer
87 88
 	{
88
-		fixed_t vol [stereo];
89
+		fixed_t vol[stereo];
89 90
 		bool echo;
90
-
91
-		void* operator new ( size_t, void* p ) { return p; }
92
-		void operator delete ( void* ) { }
93
-
94
-		~buf_t() { }
95 91
 	};
96
-	buf_t* bufs;
92
+	std::vector<std::unique_ptr<buf_t>> bufs;
97 93
 	int bufs_size;
98 94
 	int bufs_max; // bufs_size <= bufs_max, to limit memory usage
99 95
 	Stereo_Mixer mixer;
100 96
 
101
-	struct {
102
-		long delay [stereo];
97
+	struct
98
+	{
99
+		long delay[stereo];
103 100
 		fixed_t treble;
104 101
 		fixed_t feedback;
105
-		fixed_t low_pass [stereo];
102
+		fixed_t low_pass[stereo];
106 103
 	} s;
107 104
 
108
-	blargg_vector<fixed_t> echo;
109
-	blargg_long echo_pos;
105
+	std::vector<fixed_t> echo;
106
+	int32_t echo_pos;
110 107
 
111 108
 	bool no_effects;
112 109
 	bool no_echo;
113 110
 
114 111
 	void assign_buffers();
115 112
 	void clear_echo();
116
-	void mix_effects( blip_sample_t* out, int pair_count );
117
-	blargg_err_t new_bufs( int size );
113
+	void mix_effects(blip_sample_t *out, int pair_count);
114
+	blargg_err_t new_bufs(int size);
118 115
 	void delete_bufs();
119 116
 };
120 117
 
121 118
 // Simpler interface and lower memory usage
122
-class Simple_Effects_Buffer : public Effects_Buffer {
119
+class Simple_Effects_Buffer : public Effects_Buffer
120
+{
123 121
 public:
124 122
 	struct config_t
125 123
 	{
126
-		bool enabled;   // false = disable all effects
127
-		float echo;     // 0.0 = none, 1.0 = lots
128
-		float stereo;   // 0.0 = channels in center, 1.0 = channels on left/right
129
-		bool surround;  // true = put some channels in back
124
+		bool enabled; // false = disable all effects
125
+		float echo; // 0.0 = none, 1.0 = lots
126
+		float stereo; // 0.0 = channels in center, 1.0 = channels on left/right
127
+		bool surround; // true = put some channels in back
130 128
 	};
131
-	config_t& config() { return config_; }
129
+	config_t &config() { return this->config_; }
132 130
 
133 131
 	// Apply any changes made to config()
134 132
 	void apply_config();
Browse code

Import actual code.

Naram Qashat authored on 2013/03/26 02:41:19
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,143 @@
1
+// Multi-channel effects buffer with echo and individual panning for each channel
2
+
3
+// Game_Music_Emu $vers
4
+#ifndef EFFECTS_BUFFER_H
5
+#define EFFECTS_BUFFER_H
6
+
7
+#include "Multi_Buffer.h"
8
+
9
+// See Simple_Effects_Buffer (below) for a simpler interface
10
+
11
+class Effects_Buffer : public Multi_Buffer {
12
+public:
13
+	// To reduce memory usage, fewer buffers can be used (with a best-fit
14
+	// approach if there are too few), and maximum echo delay can be reduced
15
+	Effects_Buffer( int max_bufs = 32, long echo_size = 24 * 1024L );
16
+
17
+	struct pan_vol_t
18
+	{
19
+		float vol; // 0.0 = silent, 0.5 = half volume, 1.0 = normal
20
+		float pan; // -1.0 = left, 0.0 = center, +1.0 = right
21
+	};
22
+
23
+	// Global configuration
24
+	struct config_t
25
+	{
26
+		bool enabled; // false = disable all effects
27
+
28
+		// Current sound is echoed at adjustable left/right delay,
29
+		// with reduced treble and volume (feedback).
30
+		float treble;   // 1.0 = full treble, 0.1 = very little, 0.0 = silent
31
+		int delay [2];  // left, right delays (msec)
32
+		float feedback; // 0.0 = no echo, 0.5 = each echo half previous, 1.0 = cacophony
33
+		pan_vol_t side_chans [2]; // left and right side channel volume and pan
34
+	};
35
+	config_t& config() { return config_; }
36
+
37
+	// Limits of delay (msec)
38
+	int min_delay() const;
39
+	int max_delay() const;
40
+
41
+	// Per-channel configuration. Two or more channels with matching parameters are
42
+	// optimized to internally use the same buffer.
43
+	struct chan_config_t : pan_vol_t
44
+	{
45
+		// (inherited from pan_vol_t)
46
+		//float vol;        // these only affect center channel
47
+		//float pan;
48
+		bool surround;  // if true, negates left volume to put sound in back
49
+		bool echo;      // false = channel doesn't have any echo
50
+	};
51
+	chan_config_t& chan_config( int i ) { return chans [i + extra_chans].cfg; }
52
+
53
+	// Apply any changes made to config() and chan_config()
54
+	virtual void apply_config();
55
+
56
+public:
57
+	~Effects_Buffer();
58
+	blargg_err_t set_sample_rate( long samples_per_sec, int msec = blip_default_length );
59
+	blargg_err_t set_channel_count( int, int const* = 0 );
60
+	void clock_rate( long );
61
+	void bass_freq( int );
62
+	void clear();
63
+	channel_t channel( int );
64
+	void end_frame( blip_time_t );
65
+	long read_samples( blip_sample_t*, long );
66
+	long samples_avail() const { return (bufs [0].samples_avail() - mixer.samples_read) * 2; }
67
+	enum { stereo = 2 };
68
+	typedef blargg_long fixed_t;
69
+protected:
70
+	enum { extra_chans = stereo * stereo };
71
+private:
72
+	config_t config_;
73
+	long clock_rate_;
74
+	int bass_freq_;
75
+
76
+	blargg_long echo_size;
77
+
78
+	struct chan_t
79
+	{
80
+		fixed_t vol [stereo];
81
+		chan_config_t cfg;
82
+		channel_t channel;
83
+	};
84
+	blargg_vector<chan_t> chans;
85
+
86
+	struct buf_t : Tracked_Blip_Buffer
87
+	{
88
+		fixed_t vol [stereo];
89
+		bool echo;
90
+
91
+		void* operator new ( size_t, void* p ) { return p; }
92
+		void operator delete ( void* ) { }
93
+
94
+		~buf_t() { }
95
+	};
96
+	buf_t* bufs;
97
+	int bufs_size;
98
+	int bufs_max; // bufs_size <= bufs_max, to limit memory usage
99
+	Stereo_Mixer mixer;
100
+
101
+	struct {
102
+		long delay [stereo];
103
+		fixed_t treble;
104
+		fixed_t feedback;
105
+		fixed_t low_pass [stereo];
106
+	} s;
107
+
108
+	blargg_vector<fixed_t> echo;
109
+	blargg_long echo_pos;
110
+
111
+	bool no_effects;
112
+	bool no_echo;
113
+
114
+	void assign_buffers();
115
+	void clear_echo();
116
+	void mix_effects( blip_sample_t* out, int pair_count );
117
+	blargg_err_t new_bufs( int size );
118
+	void delete_bufs();
119
+};
120
+
121
+// Simpler interface and lower memory usage
122
+class Simple_Effects_Buffer : public Effects_Buffer {
123
+public:
124
+	struct config_t
125
+	{
126
+		bool enabled;   // false = disable all effects
127
+		float echo;     // 0.0 = none, 1.0 = lots
128
+		float stereo;   // 0.0 = channels in center, 1.0 = channels on left/right
129
+		bool surround;  // true = put some channels in back
130
+	};
131
+	config_t& config() { return config_; }
132
+
133
+	// Apply any changes made to config()
134
+	void apply_config();
135
+
136
+public:
137
+	Simple_Effects_Buffer();
138
+private:
139
+	config_t config_;
140
+	void chan_config(); // hide
141
+};
142
+
143
+#endif