diff options
author | Robin Gareus <robin@gareus.org> | 2016-02-15 15:46:49 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-02-15 15:46:49 +0100 |
commit | e6ea35c3de0c234a99443a05a131540dd821487c (patch) | |
tree | 5cc035799079d8c4860b855449b61e23836b7a9e /libs/audiographer | |
parent | b9efb2ae21b785ef7273af22df1a8fcad168227f (diff) |
Add normalization gain factor to Export Analysis
Diffstat (limited to 'libs/audiographer')
-rw-r--r-- | libs/audiographer/audiographer/general/analyser.h | 7 | ||||
-rw-r--r-- | libs/audiographer/audiographer/general/normalizer.h | 2 | ||||
-rw-r--r-- | libs/audiographer/src/general/analyser.cc | 7 | ||||
-rw-r--r-- | libs/audiographer/src/general/normalizer.cc | 3 |
4 files changed, 14 insertions, 5 deletions
diff --git a/libs/audiographer/audiographer/general/analyser.h b/libs/audiographer/audiographer/general/analyser.h index e79e4107dc..e8ca534954 100644 --- a/libs/audiographer/audiographer/general/analyser.h +++ b/libs/audiographer/audiographer/general/analyser.h @@ -41,8 +41,15 @@ class LIBAUDIOGRAPHER_API Analyser : public ListedSource<float>, public Sink<flo void process (ProcessContext<float> const & c); ARDOUR::ExportAnalysisPtr result (); + void set_normalization_gain (float gain) { + _result.normalized = true; + _result.norm_gain_factor = gain; + } + using Sink<float>::process; + static const float fft_range_db; + private: float fft_power_at_bin (const uint32_t b, const float norm) const; diff --git a/libs/audiographer/audiographer/general/normalizer.h b/libs/audiographer/audiographer/general/normalizer.h index 025131022e..e5f73a0f08 100644 --- a/libs/audiographer/audiographer/general/normalizer.h +++ b/libs/audiographer/audiographer/general/normalizer.h @@ -21,7 +21,7 @@ public: ~Normalizer(); /// Sets the peak found in the material to be normalized \see PeakReader \n RT safe - void set_peak (float peak); + float set_peak (float peak); /** Allocates a buffer for using with const ProcessContexts * This function does not need to be called if diff --git a/libs/audiographer/src/general/analyser.cc b/libs/audiographer/src/general/analyser.cc index d969095b08..c27d7dae08 100644 --- a/libs/audiographer/src/general/analyser.cc +++ b/libs/audiographer/src/general/analyser.cc @@ -21,6 +21,8 @@ using namespace AudioGrapher; +const float Analyser::fft_range_db (80); // dB + Analyser::Analyser (float sample_rate, unsigned int channels, framecnt_t bufsize, framecnt_t n_samples) : _ebur128_plugin (0) , _dbtp_plugin (0) @@ -196,12 +198,11 @@ Analyser::process (ProcessContext<float> const & c) const framecnt_t x0 = _pos / _fpp; framecnt_t x1 = (_pos + n_samples) / _fpp; if (x0 == x1) x1 = x0 + 1; - const float range = 80; // dB for (uint32_t i = 0; i < _fft_data_size - 1; ++i) { const float level = fft_power_at_bin (i, i); - if (level < -range) continue; - const float pk = level > 0.0 ? 1.0 : (range + level) / range; + if (level < -fft_range_db) continue; + const float pk = level > 0.0 ? 1.0 : (fft_range_db + level) / fft_range_db; #if 0 // linear const uint32_t y0 = floor (i * (float) height / _fft_data_size); uint32_t y1 = ceil ((i + 1.0) * (float) height / _fft_data_size); diff --git a/libs/audiographer/src/general/normalizer.cc b/libs/audiographer/src/general/normalizer.cc index d241d71892..a10382031a 100644 --- a/libs/audiographer/src/general/normalizer.cc +++ b/libs/audiographer/src/general/normalizer.cc @@ -37,7 +37,7 @@ Normalizer::~Normalizer() } /// Sets the peak found in the material to be normalized \see PeakReader \n RT safe -void Normalizer::set_peak (float peak) +float Normalizer::set_peak (float peak) { if (peak == 0.0f || peak == target) { /* don't even try */ @@ -46,6 +46,7 @@ void Normalizer::set_peak (float peak) enabled = true; gain = target / peak; } + return enabled ? gain : 1.0; } /** Allocates a buffer for using with const ProcessContexts |