/*
- 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
{
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 */
enabled = true;
gain = target / peak;
}
+ return enabled ? gain : 1.0;
}
/** Allocates a buffer for using with const ProcessContexts
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);
}