Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
20 
21 #include <cstring>
22 #include <map>
23 #include <memory>
24 #include <set>
25 #include <vector>
26 
27 
28 #include "ardour/types.h"
29 
30 namespace ARDOUR
31 {
33 public:
34  ExportAnalysis (size_t w = 800, size_t b = 200)
35  : width (w)
36  , peak (0)
37  , truepeak (0)
38  , loudness_range (0)
40  , max_loudness_short (0)
42  , loudness_hist_max (0)
43  , have_loudness (false)
44  , have_lufs_graph (false)
45  , have_dbtp (false)
46  , norm_gain_factor (1.0)
47  , normalized (false)
48  , n_channels (1)
49  , n_samples (0)
50  {
51  b = std::max<size_t> (100, b);
52  width = std::max<size_t> (800, width);
53 
54  peaks.resize (2);
55  peaks[0].resize (width);
56  peaks[1].resize (width);
57  spectrum.resize (width);
58 
59  for (size_t i = 0; i < width; ++i) {
60  spectrum[i].resize (b);
61  }
62 
63  lgraph_i = new float[width];
64  lgraph_s = new float[width];
65  lgraph_m = new float[width];
66  limiter_pk = new float[width]();
67 
68  for (size_t i = 0; i < width; ++i) {
69  /* d compare to ebu_r128_proc.cc */
70  lgraph_i[i] = -200;
71  lgraph_s[i] = -200;
72  lgraph_m[i] = -200;
73  }
74  }
75 
77  : width (other.width)
78  , peak (other.peak)
79  , truepeak (other.truepeak)
87  , have_dbtp (other.have_dbtp)
89  , normalized (other.normalized)
90  , n_channels (other.n_channels)
91  , n_samples (other.n_samples)
92  , peaks (other.peaks)
93  , spectrum (other.spectrum)
94  {
95  lgraph_i = new float[width];
96  lgraph_s = new float[width];
97  lgraph_m = new float[width];
98  limiter_pk = new float[width];
99 
100  truepeakpos[0] = other.truepeakpos[0];
101  truepeakpos[1] = other.truepeakpos[1];
102 
103  memcpy (loudness_hist, other.loudness_hist, sizeof (float) * width);
104  memcpy (lgraph_i, other.lgraph_i, sizeof (float) * width);
105  memcpy (lgraph_s, other.lgraph_s, sizeof (float) * width);
106  memcpy (lgraph_m, other.lgraph_m, sizeof (float) * width);
107  memcpy (limiter_pk, other.limiter_pk, sizeof (float) * width);
108  memcpy (freq, other.freq, sizeof (freq));
109  }
110 
112  {
113  delete[] lgraph_i;
114  delete[] lgraph_s;
115  delete[] lgraph_m;
116  delete[] limiter_pk;
117  }
118 
119  size_t width;
120  float peak;
121  float truepeak;
126  int loudness_hist[540];
130  bool have_dbtp;
133 
134  uint32_t n_channels;
135  uint32_t n_samples;
136  uint32_t freq[6]; // y-pos, 50, 100, 500, 1k, 5k, 10k [Hz]
137 
138  std::vector<std::vector<PeakData> > peaks;
139  std::vector<std::vector<float> > spectrum;
140 
141  float* lgraph_i;
142  float* lgraph_s;
143  float* lgraph_m;
144  float* limiter_pk;
145 
146  std::set<samplecnt_t> truepeakpos[2]; // bins with >= -1dBTB
147 };
148 
149 typedef std::shared_ptr<ExportAnalysis> ExportAnalysisPtr;
150 typedef std::map<std::string, ExportAnalysisPtr> AnalysisResults;
151 
152 } // namespace ARDOUR
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]