/
average_level_filtered.h
102 lines (72 loc) · 3.15 KB
/
average_level_filtered.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
/* ----------------------------------------------------------------------------
K-Meter
=======
Implementation of a K-System meter according to Bob Katz' specifications
Copyright (c) 2010-2018 Martin Zuther (http://www.mzuther.de/)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Thank you for using free software!
---------------------------------------------------------------------------- */
#ifndef __AVERAGE_LEVEL_FILTERED_H__
#define __AVERAGE_LEVEL_FILTERED_H__
class AverageLevelFiltered;
#include "FrutHeader.h"
#include "fftw_runner.h"
#include "plugin_processor.h"
class AverageLevelFiltered :
public FftwRunner
{
public:
static const int KMETER_MAXIMUM_FILTER_STAGES = 3;
AverageLevelFiltered(KmeterAudioProcessor *processor,
const int channels,
const int sampleRate,
const int bufferSize,
const int averageAlgorithm);
float getLevel(const int channel);
int getAlgorithm();
void setAlgorithm(const int averageAlgorithm);
void copyFromBuffer(frut::audio::RingBuffer &ringBuffer,
const unsigned int preDelay,
const int sampleRate);
void copyToBuffer(frut::audio::RingBuffer &destination,
const unsigned int sourceStartSample,
const unsigned int numSamples);
void copyToBuffer(AudioBuffer<float> &destination,
const int channel,
const int destStartSample,
const int numSamples);
private:
JUCE_LEAK_DETECTOR(AverageLevelFiltered);
void calculateFilterKernel();
void calculateFilterKernel_Rms();
void calculateFilterKernel_ItuBs1770();
void filterSamples_Rms(const int channel);
void filterSamples_ItuBs1770();
int sampleRate_;
Array<double> preFilterInputCoefficients_;
Array<double> preFilterOutputCoefficients_;
Array<double> weightingFilterInputCoefficients_;
Array<double> weightingFilterOutputCoefficients_;
AudioBuffer<float> previousSamplesPreFilterInput_;
AudioBuffer<float> previousSamplesPreFilterOutput_;
AudioBuffer<float> previousSamplesWeightingFilterInput_;
AudioBuffer<float> previousSamplesWeightingFilterOutput_;
AudioBuffer<float> previousSamplesOutputTemp_;
frut::dsp::Dither dither_;
KmeterAudioProcessor *processor_;
int averageAlgorithm_;
float peakToAverageCorrection_;
};
#endif // __AVERAGE_LEVEL_FILTERED_H__
// Local Variables:
// ispell-local-dictionary: "british"
// End: