Ardour  8.7-15-gadf511264b
export_analysis.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18 
19 #ifndef __ardour_export_analysis_h__
20 #define __ardour_export_analysis_h__
21 
22 #include <cstring>
23 #include <map>
24 #include <memory>
25 #include <set>
26 #include <vector>
27 
28 
29 #include "ardour/types.h"
30 
31 namespace ARDOUR
32 {
34 public:
35  ExportAnalysis (size_t w = 800, size_t b = 200)
36  : width (w)
37  , peak (0)
38  , truepeak (0)
39  , loudness_range (0)
41  , max_loudness_short (0)
43  , loudness_hist_max (0)
44  , have_loudness (false)
45  , have_lufs_graph (false)
46  , have_dbtp (false)
47  , norm_gain_factor (1.0)
48  , normalized (false)
49  , n_channels (1)
50  , n_samples (0)
51  {
52  b = std::max<size_t> (100, b);
53  width = std::max<size_t> (800, width);
54 
55  peaks.resize (2);
56  peaks[0].resize (width);
57  peaks[1].resize (width);
58  spectrum.resize (width);
59 
60  for (size_t i = 0; i < width; ++i) {
61  spectrum[i].resize (b);
62  }
63 
64  lgraph_i = new float[width];
65  lgraph_s = new float[width];
66  lgraph_m = new float[width];
67  limiter_pk = new float[width]();
68 
69  for (size_t i = 0; i < width; ++i) {
70  /* d compare to ebu_r128_proc.cc */
71  lgraph_i[i] = -200;
72  lgraph_s[i] = -200;
73  lgraph_m[i] = -200;
74  }
75  }
76 
78  : width (other.width)
79  , peak (other.peak)
80  , truepeak (other.truepeak)
88  , have_dbtp (other.have_dbtp)
90  , normalized (other.normalized)
91  , n_channels (other.n_channels)
92  , n_samples (other.n_samples)
93  , peaks (other.peaks)
94  , spectrum (other.spectrum)
95  {
96  lgraph_i = new float[width];
97  lgraph_s = new float[width];
98  lgraph_m = new float[width];
99  limiter_pk = new float[width];
100 
101  truepeakpos[0] = other.truepeakpos[0];
102  truepeakpos[1] = other.truepeakpos[1];
103 
104  memcpy (loudness_hist, other.loudness_hist, sizeof (float) * width);
105  memcpy (lgraph_i, other.lgraph_i, sizeof (float) * width);
106  memcpy (lgraph_s, other.lgraph_s, sizeof (float) * width);
107  memcpy (lgraph_m, other.lgraph_m, sizeof (float) * width);
108  memcpy (limiter_pk, other.limiter_pk, sizeof (float) * width);
109  memcpy (freq, other.freq, sizeof (freq));
110  }
111 
113  {
114  delete[] lgraph_i;
115  delete[] lgraph_s;
116  delete[] lgraph_m;
117  delete[] limiter_pk;
118  }
119 
120  size_t width;
121  float peak;
122  float truepeak;
127  int loudness_hist[540];
131  bool have_dbtp;
134 
135  uint32_t n_channels;
136  uint32_t n_samples;
137  uint32_t freq[6]; // y-pos, 50, 100, 500, 1k, 5k, 10k [Hz]
138 
139  std::vector<std::vector<PeakData> > peaks;
140  std::vector<std::vector<float> > spectrum;
141 
142  float* lgraph_i;
143  float* lgraph_s;
144  float* lgraph_m;
145  float* limiter_pk;
146 
147  std::set<samplecnt_t> truepeakpos[2]; // bins with >= -1dBTB
148 };
149 
150 typedef std::shared_ptr<ExportAnalysis> ExportAnalysisPtr;
151 typedef std::map<std::string, ExportAnalysisPtr> AnalysisResults;
152 
153 } // namespace ARDOUR
154 #endif
std::map< std::string, ExportAnalysisPtr > AnalysisResults
std::shared_ptr< ExportAnalysis > ExportAnalysisPtr
ExportAnalysis(const ExportAnalysis &other)
ExportAnalysis(size_t w=800, size_t b=200)
std::vector< std::vector< float > > spectrum
std::vector< std::vector< PeakData > > peaks
std::set< samplecnt_t > truepeakpos[2]