1 // ------------------------------------------------------------------------
3 // Copyright (C) 2010-2011 Fons Adriaensen <fons@linuxaudio.org>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 // ------------------------------------------------------------------------
22 #ifndef __EBU_R128_PROC_H
23 #define __EBU_R128_PROC_H
33 friend class Ebu_r128_proc;
35 void reset (void) { _z1 = _z2 = _z3 = _z4 = 0; }
37 float _z1, _z2, _z3, _z4;
46 ~Ebu_r128_hist (void);
48 friend class Ebu_r128_proc;
52 void addpoint (float v);
53 float integrate (int ind);
54 void calc_integ (float *vi, float *th);
55 void calc_range (float *v0, float *v1, float *th);
61 static float _bin_power [100];
71 ~Ebu_r128_proc (void);
73 void init (int nchan, float fsamp);
75 void process (int nfram, float *input []);
76 void integr_reset (void);
77 void integr_pause (void) { _integr = false; }
78 void integr_start (void) { _integr = true; }
80 float loudness_M (void) const { return _loudness_M; }
81 float maxloudn_M (void) const { return _maxloudn_M; }
82 float loudness_S (void) const { return _loudness_S; }
83 float maxloudn_S (void) const { return _maxloudn_S; }
84 float integrated (void) const { return _integrated; }
85 float integ_thr (void) const { return _integ_thr; }
86 float range_min (void) const { return _range_min; }
87 float range_max (void) const { return _range_max; }
88 float range_thr (void) const { return _range_thr; }
90 const int *histogram_M (void) const { return _hist_M._histc; }
91 const int *histogram_S (void) const { return _hist_S._histc; }
92 int hist_M_count (void) const { return _hist_M._count; }
93 int hist_S_count (void) const { return _hist_S._count; }
97 float addfrags (int nfrag);
98 void detect_init (float fsamp);
99 void detect_reset (void);
100 float detect_process (int nfram);
102 bool _integr; // Integration on/off.
103 int _nchan; // Number of channels, 2 or 5.
104 float _fsamp; // Sample rate.
105 int _fragm; // Fragmenst size, 1/20 second.
106 int _frcnt; // Number of samples remaining in current fragment.
107 float _frpwr; // Power accumulated for current fragment.
108 float _power [64]; // Array of fragment powers.
109 int _wrind; // Write index into _frpwr
110 int _div1; // M period counter, 200 ms;
111 int _div2; // S period counter, 1s;
122 // Filter coefficients and states.
127 Ebu_r128_fst _fst [MAXCH];
128 Ebu_r128_hist _hist_M;
129 Ebu_r128_hist _hist_S;
131 // Default channel gains.
132 static float _chan_gain [5];