summaryrefslogtreecommitdiff
path: root/libs/audiographer
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2016-02-16 15:09:31 +0100
committerRobin Gareus <robin@gareus.org>2016-02-16 15:09:31 +0100
commit240daf95f5377464d775a7a49e7981310f22204b (patch)
treede153ad11747b687516274dbc728070506ba1eab /libs/audiographer
parenta664fb703e2cc30196231f2614178e834fe804ba (diff)
re-bin analysis results to take silence striping into account.
Diffstat (limited to 'libs/audiographer')
-rw-r--r--libs/audiographer/src/general/analyser.cc26
1 files changed, 24 insertions, 2 deletions
diff --git a/libs/audiographer/src/general/analyser.cc b/libs/audiographer/src/general/analyser.cc
index ec47b13b32..b6a3e1bbde 100644
--- a/libs/audiographer/src/general/analyser.cc
+++ b/libs/audiographer/src/general/analyser.cc
@@ -242,11 +242,33 @@ ARDOUR::ExportAnalysisPtr
Analyser::result ()
{
DEBUG_TRACE (PBD::DEBUG::ExportAnalysis, string_compose ("Processed %1 / %2 samples\n", _pos, _n_samples));
- if (_pos == 0 || ::llabs (_pos -_n_samples) > 1) {
- printf("NO ANAL\n");
+ if (_pos == 0 || _pos > _n_samples + 1) {
return ARDOUR::ExportAnalysisPtr ();
}
+ if (_pos + 1 < _n_samples) {
+ // crude re-bin (silence stripped version)
+ const size_t peaks = sizeof (_result.peaks) / sizeof (ARDOUR::PeakData::PeakDatum) / 4;
+ for (framecnt_t b = peaks - 1; b > 0; --b) {
+ for (unsigned int c = 0; c < _result.n_channels; ++c) {
+ const framecnt_t sb = b * _pos / _n_samples;
+ _result.peaks[c][b].min = _result.peaks[c][sb].min;
+ _result.peaks[c][b].max = _result.peaks[c][sb].max;
+ }
+ }
+
+ const size_t swh = sizeof (_result.spectrum) / sizeof (float);
+ const size_t height = sizeof (_result.spectrum[0]) / sizeof (float);
+ const size_t width = swh / height;
+ for (framecnt_t b = width - 1; b > 0; --b) {
+ // TODO round down to prev _fft_data_size bin
+ const framecnt_t sb = b * _pos / _n_samples;
+ for (unsigned int y = 0; y < height; ++y) {
+ _result.spectrum[b][y] = _result.spectrum[sb][y];
+ }
+ }
+ }
+
if (_ebur128_plugin) {
Vamp::Plugin::FeatureSet features = _ebur128_plugin->getRemainingFeatures ();
if (!features.empty () && features.size () == 3) {