Add normalization gain factor to Export Analysis
[ardour.git] / libs / audiographer / src / general / normalizer.cc
index 3cc849cb8da3656046404f540af57f2465068755..a10382031a520de6ec8cbb5065f2bf708c11856c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012 Paul Davis 
+    Copyright (C) 2012 Paul Davis
     Author: Sakari Bergen
 
     This program is free software; you can redistribute it and/or modify
@@ -30,14 +30,14 @@ Normalizer::Normalizer (float target_dB)
 {
        target = pow (10.0f, target_dB * 0.05f);
 }
-       
+
 Normalizer::~Normalizer()
 {
        delete [] buffer;
 }
 
 /// 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
@@ -66,12 +67,12 @@ void Normalizer::process (ProcessContext<float> const & c)
        if (throw_level (ThrowProcess) && c.frames() > buffer_size) {
                throw Exception (*this, "Too many frames given to process()");
        }
-       
+
        if (enabled) {
                memcpy (buffer, c.data(), c.frames() * sizeof(float));
                Routines::apply_gain_to_buffer (buffer, c.frames(), gain);
        }
-       
+
        ProcessContext<float> c_out (c, buffer);
        ListedSource<float>::output (c_out);
 }