-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathYmFilters.h
127 lines (112 loc) · 2.68 KB
/
YmFilters.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/**
* \file YmFilters.h
* \brief libstsound Audio Filter declaration file
*/
/*
* libstsound is an AY-3-8192, YM2149 and clone PSG emulator
* Copyright (C) 2008-2011 CPCSDK crew ( http://github.com/cpcsdk/ )
* Based on ST-Sound
* Copyright (C) 1995-1999 Arnaud Carre ( http://leonard.oxg.free.fr )
*/
#ifndef __FILTER_H_
#define __FILTER_H_
#include "YmTypes.h"
static const ymint DC_ADJUST_BUFFERLEN = 512;
/**
* \class Filter
* \brief Interface class for implementing audio filter
*/
class Filter
{
public:
Filter();
virtual void AddSample(ymint sample) = 0;
virtual ymint GetResult() = 0;
virtual void Reset() = 0;
};
/**
* \class SimpleLowPassFilter
* \brief A very simple FIR 3-tap low pass filter.
*/
class SimpleLowPassFilter: public Filter
{
public:
SimpleLowPassFilter();
void AddSample(ymint sample);
ymint GetResult();
void Reset();
private:
ymint delay_line[3]; // Delay lines for low pass filtering. 3 samples.
};
/**
* \class DCRemover
* \brief Removing of DC component
* Implement has a simple average FIR DC_ADJUST_BUFFERLEN-tap high pass filter.
*/
class DCRemover: public Filter
{
public:
DCRemover();
void AddSample(ymint sample);
ymint GetResult();
void Reset();
private:
ymint buffer[DC_ADJUST_BUFFERLEN];
ymint pos;
ymint sum;
#ifndef YM_SIMPLIFIED_FILTER
bool full;
#endif
};
#if 0
class FIRFilter: public Filter
{
public:
FIRFilter();
FIRFilter(ymint N = 512, ymint delay = 0, ymint *coef);
~FIRFilter();
void AddSample(ymint sample);
ymint GetResult();
void Reset();
privte:
ymint N; // N-tap
ymint delay;
ymint pos;
ymint *buffer;
ymint *delay_line;
ymfloat *coef;
ymfloat coef_sum;
}
#endif // Unfinished
typedef struct _stereoSample
{
ymint r;
ymint l;
} stereoSample;
/**
* \class FilterStereo
* \brief Interface class for implementing audio filter who don't use stereo as two indepandant channels
*/
class FilterStereo
{
public:
FilterStereo();
virtual void AddSample(stereoSample sample) = 0;
virtual stereoSample GetResult() = 0;
virtual void Reset() = 0;
};
/**
* \class SimpleStereoEffectReducer
* \brief A simple reducer of stereo effect, very usefull for headphone...
*/
class SimpleStereoEffectReducer: public FilterStereo
{
public:
SimpleStereoEffectReducer();
void AddSample(stereoSample sample);
stereoSample GetResult();
void Reset();
private:
stereoSample buffer;
};
#endif /* #ifndef __FILTER_H_ */