Initial Gain Coefficient tweaks
1) Disambiguate 1.0 to GAIN_COEFF_UNITY, and 0.0 to GAIN_COEFF_ZERO 2) Add GAIN_COEFF_SMALL which replaces SMALL_SIGNAL (-140dB) 3) GAIN_COEFF_SMALL can used to avoid interpolating towards -inf on a db scale 4) GAIN_COEFF_SMALL is used to detect very small (denormal?) gains and memset to zero
This commit is contained in:
parent
187ddb3bad
commit
46f97e8d92
@ -30,6 +30,7 @@
|
||||
#include "ardour/automation_list.h"
|
||||
#include "evoral/Curve.hpp"
|
||||
#include "ardour/crossfade.h"
|
||||
#include "ardour/dB.h"
|
||||
#include "ardour/session.h"
|
||||
#include "ardour/auditioner.h"
|
||||
#include "ardour/audioplaylist.h"
|
||||
@ -884,87 +885,86 @@ CrossfadeEditor::build_presets ()
|
||||
/* FADE IN */
|
||||
|
||||
p = new Preset ("Linear (-6dB)", "fadein-linear");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0.000000, 0.000000));
|
||||
p->push_back (PresetPoint (0.000000, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.166667, 0.166366));
|
||||
p->push_back (PresetPoint (0.333333, 0.332853));
|
||||
p->push_back (PresetPoint (0.500000, 0.499459));
|
||||
p->push_back (PresetPoint (0.666667, 0.666186));
|
||||
p->push_back (PresetPoint (0.833333, 0.833033));
|
||||
p->push_back (PresetPoint (1.000000, 1.000000));
|
||||
p->push_back (PresetPoint (1.000000, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("S(1)-curve", "fadein-S1");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.1, 0.01));
|
||||
p->push_back (PresetPoint (0.2, 0.03));
|
||||
p->push_back (PresetPoint (0.8, 0.97));
|
||||
p->push_back (PresetPoint (0.9, 0.99));
|
||||
p->push_back (PresetPoint (1, 1));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("S(2)-curve", "fadein-S2");
|
||||
p->push_back (PresetPoint (0.0, 0.0));
|
||||
p->push_back (PresetPoint (0.0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.055, 0.222));
|
||||
p->push_back (PresetPoint (0.163, 0.35));
|
||||
p->push_back (PresetPoint (0.837, 0.678));
|
||||
p->push_back (PresetPoint (0.945, 0.783));
|
||||
p->push_back (PresetPoint (1.0, 1.0));
|
||||
p->push_back (PresetPoint (1.0, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Constant power (-3dB)", "fadein-constant-power");
|
||||
|
||||
p->push_back (PresetPoint (0.000000, 0.000000));
|
||||
p->push_back (PresetPoint (0.000000, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.166667, 0.282192));
|
||||
p->push_back (PresetPoint (0.333333, 0.518174));
|
||||
p->push_back (PresetPoint (0.500000, 0.707946));
|
||||
p->push_back (PresetPoint (0.666667, 0.851507));
|
||||
p->push_back (PresetPoint (0.833333, 0.948859));
|
||||
p->push_back (PresetPoint (1.000000, 1.000000));
|
||||
p->push_back (PresetPoint (1.000000, GAIN_COEFF_UNITY));
|
||||
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
if (!Profile->get_sae()) {
|
||||
|
||||
p = new Preset ("Short cut", "fadein-short-cut");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.389401, 0.0333333));
|
||||
p->push_back (PresetPoint (0.629032, 0.0861111));
|
||||
p->push_back (PresetPoint (0.829493, 0.233333));
|
||||
p->push_back (PresetPoint (0.9447, 0.483333));
|
||||
p->push_back (PresetPoint (0.976959, 0.697222));
|
||||
p->push_back (PresetPoint (1, 1));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Slow cut", "fadein-slow-cut");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.304147, 0.0694444));
|
||||
p->push_back (PresetPoint (0.529954, 0.152778));
|
||||
p->push_back (PresetPoint (0.725806, 0.333333));
|
||||
p->push_back (PresetPoint (0.847926, 0.558333));
|
||||
p->push_back (PresetPoint (0.919355, 0.730556));
|
||||
p->push_back (PresetPoint (1, 1));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Fast cut", "fadein-fast-cut");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.0737327, 0.308333));
|
||||
p->push_back (PresetPoint (0.246544, 0.658333));
|
||||
p->push_back (PresetPoint (0.470046, 0.886111));
|
||||
p->push_back (PresetPoint (0.652074, 0.972222));
|
||||
p->push_back (PresetPoint (0.771889, 0.988889));
|
||||
p->push_back (PresetPoint (1, 1));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Long cut", "fadein-long-cut");
|
||||
p->push_back (PresetPoint (0, 0));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_SMALL));
|
||||
p->push_back (PresetPoint (0.0207373, 0.197222));
|
||||
p->push_back (PresetPoint (0.0645161, 0.525));
|
||||
p->push_back (PresetPoint (0.152074, 0.802778));
|
||||
p->push_back (PresetPoint (0.276498, 0.919444));
|
||||
p->push_back (PresetPoint (0.481567, 0.980556));
|
||||
p->push_back (PresetPoint (0.767281, 1));
|
||||
p->push_back (PresetPoint (1, 1));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_UNITY));
|
||||
fade_in_presets->push_back (p);
|
||||
}
|
||||
|
||||
@ -972,85 +972,84 @@ CrossfadeEditor::build_presets ()
|
||||
|
||||
// p = new Preset ("regout.xpm");
|
||||
p = new Preset ("Linear (-6dB cut)", "fadeout-linear");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0.000000, 1.000000));
|
||||
p->push_back (PresetPoint (0.000000, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.166667, 0.833033));
|
||||
p->push_back (PresetPoint (0.333333, 0.666186));
|
||||
p->push_back (PresetPoint (0.500000, 0.499459));
|
||||
p->push_back (PresetPoint (0.666667, 0.332853));
|
||||
p->push_back (PresetPoint (0.833333, 0.166366));
|
||||
p->push_back (PresetPoint (1.000000, 0.000000));
|
||||
p->push_back (PresetPoint (1.000000, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
p = new Preset ("S(1)-Curve", "fadeout-S1");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.1, 0.99));
|
||||
p->push_back (PresetPoint (0.2, 0.97));
|
||||
p->push_back (PresetPoint (0.8, 0.03));
|
||||
p->push_back (PresetPoint (0.9, 0.01));
|
||||
p->push_back (PresetPoint (1, 0));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
p = new Preset ("S(2)-Curve", "fadeout-S2");
|
||||
p->push_back (PresetPoint (0.0, 1.0));
|
||||
p->push_back (PresetPoint (0.0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.163, 0.678));
|
||||
p->push_back (PresetPoint (0.055, 0.783));
|
||||
p->push_back (PresetPoint (0.837, 0.35));
|
||||
p->push_back (PresetPoint (0.945, 0.222));
|
||||
p->push_back (PresetPoint (1.0, 0.0));
|
||||
p->push_back (PresetPoint (1.0, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
// p = new Preset ("linout.xpm");
|
||||
p = new Preset ("Constant power (-3dB cut)", "fadeout-constant-power");
|
||||
p->push_back (PresetPoint (0.000000, 1.000000));
|
||||
p->push_back (PresetPoint (0.000000, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.166667, 0.948859));
|
||||
p->push_back (PresetPoint (0.333333, 0.851507));
|
||||
p->push_back (PresetPoint (0.500000, 0.707946));
|
||||
p->push_back (PresetPoint (0.666667, 0.518174));
|
||||
p->push_back (PresetPoint (0.833333, 0.282192));
|
||||
p->push_back (PresetPoint (1.000000, 0.000000));
|
||||
p->push_back (PresetPoint (1.000000, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
if (!Profile->get_sae()) {
|
||||
// p = new Preset ("hiout.xpm");
|
||||
p = new Preset ("Short cut", "fadeout-short-cut");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0.305556, 1));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.305556, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.548611, 0.991736));
|
||||
p->push_back (PresetPoint (0.759259, 0.931129));
|
||||
p->push_back (PresetPoint (0.918981, 0.68595));
|
||||
p->push_back (PresetPoint (0.976852, 0.22865));
|
||||
p->push_back (PresetPoint (1, 0));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Slow cut", "fadeout-slow-cut");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.228111, 0.988889));
|
||||
p->push_back (PresetPoint (0.347926, 0.972222));
|
||||
p->push_back (PresetPoint (0.529954, 0.886111));
|
||||
p->push_back (PresetPoint (0.753456, 0.658333));
|
||||
p->push_back (PresetPoint (0.9262673, 0.308333));
|
||||
p->push_back (PresetPoint (1, 0));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
p = new Preset ("Fast cut", "fadeout-fast-cut");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.080645, 0.730556));
|
||||
p->push_back (PresetPoint (0.277778, 0.289256));
|
||||
p->push_back (PresetPoint (0.470046, 0.152778));
|
||||
p->push_back (PresetPoint (0.695853, 0.0694444));
|
||||
p->push_back (PresetPoint (1, 0));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
// p = new Preset ("loout.xpm");
|
||||
p = new Preset ("Long cut", "fadeout-long-cut");
|
||||
p->push_back (PresetPoint (0, 1));
|
||||
p->push_back (PresetPoint (0, GAIN_COEFF_UNITY));
|
||||
p->push_back (PresetPoint (0.023041, 0.697222));
|
||||
p->push_back (PresetPoint (0.0553, 0.483333));
|
||||
p->push_back (PresetPoint (0.170507, 0.233333));
|
||||
p->push_back (PresetPoint (0.370968, 0.0861111));
|
||||
p->push_back (PresetPoint (0.610599, 0.0333333));
|
||||
p->push_back (PresetPoint (1, 0));
|
||||
p->push_back (PresetPoint (1, GAIN_COEFF_SMALL));
|
||||
fade_out_presets->push_back (p);
|
||||
|
||||
}
|
||||
|
@ -265,11 +265,11 @@ GainMeterBase::setup_gain_adjustment ()
|
||||
|
||||
if (_amp->output_streams().n_midi() <= _amp->output_streams().n_audio()) {
|
||||
_data_type = DataType::AUDIO;
|
||||
gain_adjustment.set_lower (0.0);
|
||||
gain_adjustment.set_upper (1.0);
|
||||
gain_adjustment.set_lower (GAIN_COEFF_ZERO);
|
||||
gain_adjustment.set_upper (GAIN_COEFF_UNITY);
|
||||
gain_adjustment.set_step_increment (dB_coeff_step(Config->get_max_gain()) / 10.0);
|
||||
gain_adjustment.set_page_increment (dB_coeff_step(Config->get_max_gain()));
|
||||
gain_slider->set_default_value (gain_to_slider_position (1));
|
||||
gain_slider->set_default_value (gain_to_slider_position (GAIN_COEFF_UNITY));
|
||||
} else {
|
||||
_data_type = DataType::MIDI;
|
||||
gain_adjustment.set_lower (0.0);
|
||||
@ -544,7 +544,7 @@ GainMeterBase::gain_adjusted ()
|
||||
void
|
||||
GainMeterBase::effective_gain_display ()
|
||||
{
|
||||
float value = 0.0;
|
||||
float value = GAIN_COEFF_ZERO;
|
||||
|
||||
switch (_data_type) {
|
||||
case DataType::AUDIO:
|
||||
|
@ -40,7 +40,7 @@ Amp::Amp (Session& s)
|
||||
: Processor(s, "Amp")
|
||||
, _apply_gain(true)
|
||||
, _apply_gain_automation(false)
|
||||
, _current_gain(1.0)
|
||||
, _current_gain(GAIN_COEFF_UNITY)
|
||||
, _current_automation_frame (INT64_MAX)
|
||||
, _gain_automation_buffer(0)
|
||||
{
|
||||
@ -115,7 +115,7 @@ Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/,
|
||||
|
||||
_current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, dg);
|
||||
|
||||
} else if (_current_gain != 1.0f) {
|
||||
} else if (_current_gain != GAIN_COEFF_UNITY) {
|
||||
|
||||
/* gain has not changed, but its non-unity
|
||||
*/
|
||||
@ -221,11 +221,11 @@ Amp::declick (BufferSet& bufs, framecnt_t nframes, int dir)
|
||||
if (dir < 0) {
|
||||
/* fade out: remove more and more of delta from initial */
|
||||
delta = -1.0;
|
||||
initial = 1.0;
|
||||
initial = GAIN_COEFF_UNITY;
|
||||
} else {
|
||||
/* fade in: add more and more of delta from initial */
|
||||
delta = 1.0;
|
||||
initial = 0.0;
|
||||
initial = GAIN_COEFF_ZERO;
|
||||
}
|
||||
|
||||
/* Audio Gain */
|
||||
@ -275,15 +275,15 @@ Amp::apply_gain (AudioBuffer& buf, framecnt_t sample_rate, framecnt_t nframes, g
|
||||
lpf += a * (target - lpf);
|
||||
}
|
||||
|
||||
if (lpf < 1e-10) return 0;
|
||||
if (fabsf(lpf - 1.0) < 1e-10) return 1.0;
|
||||
if (lpf < 1e-10) return 0; // TODO use GAIN_COEFF_TINY or _DENORMAL
|
||||
if (fabsf(lpf - GAIN_COEFF_UNITY) < 1e-10) return GAIN_COEFF_UNITY;
|
||||
return lpf;
|
||||
}
|
||||
|
||||
void
|
||||
Amp::apply_simple_gain (BufferSet& bufs, framecnt_t nframes, gain_t target)
|
||||
{
|
||||
if (target == 0.0) {
|
||||
if (target < GAIN_COEFF_SMALL) {
|
||||
|
||||
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
|
||||
MidiBuffer& mb (*i);
|
||||
@ -300,7 +300,7 @@ Amp::apply_simple_gain (BufferSet& bufs, framecnt_t nframes, gain_t target)
|
||||
memset (i->data(), 0, sizeof (Sample) * nframes);
|
||||
}
|
||||
|
||||
} else if (target != 1.0) {
|
||||
} else if (target != GAIN_COEFF_UNITY) {
|
||||
|
||||
for (BufferSet::midi_iterator i = bufs.midi_begin(); i != bufs.midi_end(); ++i) {
|
||||
MidiBuffer& mb (*i);
|
||||
@ -322,9 +322,9 @@ Amp::apply_simple_gain (BufferSet& bufs, framecnt_t nframes, gain_t target)
|
||||
void
|
||||
Amp::apply_simple_gain (AudioBuffer& buf, framecnt_t nframes, gain_t target)
|
||||
{
|
||||
if (target == 0.0) {
|
||||
if (target < GAIN_COEFF_SMALL) {
|
||||
memset (buf.data(), 0, sizeof (Sample) * nframes);
|
||||
} else if (target != 1.0) {
|
||||
} else if (target != GAIN_COEFF_UNITY) {
|
||||
apply_gain_to_buffer (buf.data(), nframes, target);
|
||||
}
|
||||
}
|
||||
@ -334,7 +334,7 @@ Amp::inc_gain (gain_t factor, void *src)
|
||||
{
|
||||
float desired_gain = _gain_control->user_double();
|
||||
|
||||
if (desired_gain == 0.0f) {
|
||||
if (desired_gain < GAIN_COEFF_SMALL) {
|
||||
set_gain (0.000001f + (0.000001f * factor), src);
|
||||
} else {
|
||||
set_gain (desired_gain + (desired_gain * factor), src);
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#include "pbd/fastlog.h"
|
||||
|
||||
#define GAIN_COEFF_ZERO 0.0
|
||||
#define GAIN_COEFF_SMALL 0.0000001 //-140dB
|
||||
#define GAIN_COEFF_UNITY 1.0
|
||||
|
||||
static inline float dB_to_coefficient (float dB) {
|
||||
return dB > -318.8f ? pow (10.0f, dB * 0.05f) : 0.0f;
|
||||
}
|
||||
|
@ -603,7 +603,7 @@ AudioTrack::freeze_me (InterThreadInfo& itt)
|
||||
|
||||
/* reset stuff that has already been accounted for in the freeze process */
|
||||
|
||||
set_gain (1.0, this);
|
||||
set_gain (GAIN_COEFF_UNITY, this);
|
||||
_amp->gain_control()->set_automation_state (Off);
|
||||
/* XXX need to use _main_outs _panner->set_automation_state (Off); */
|
||||
|
||||
|
@ -283,7 +283,7 @@ AudioEngine::process_callback (pframes_t nframes)
|
||||
|
||||
/* fade out over 1 second */
|
||||
session_removal_countdown = sample_rate()/2;
|
||||
session_removal_gain = 1.0;
|
||||
session_removal_gain = GAIN_COEFF_UNITY;
|
||||
session_removal_gain_step = 1.0/session_removal_countdown;
|
||||
|
||||
} else if (session_removal_countdown > 0) {
|
||||
|
@ -72,8 +72,6 @@ namespace ARDOUR {
|
||||
}
|
||||
}
|
||||
|
||||
static const double VERY_SMALL_SIGNAL = 0.0000001; //-140dB
|
||||
|
||||
/* Curve manipulations */
|
||||
|
||||
static void
|
||||
@ -106,14 +104,14 @@ generate_db_fade (boost::shared_ptr<Evoral::ControlList> dst, double len, int nu
|
||||
//generate a fade-out curve by successively applying a gain drop
|
||||
float fade_speed = dB_to_coefficient(dB_drop / (float) num_steps);
|
||||
for (int i = 1; i < (num_steps-1); i++) {
|
||||
float coeff = 1.0;
|
||||
float coeff = GAIN_COEFF_UNITY;
|
||||
for (int j = 0; j < i; j++) {
|
||||
coeff *= fade_speed;
|
||||
}
|
||||
dst->fast_simple_add (len*(double)i/(double)num_steps, coeff);
|
||||
}
|
||||
|
||||
dst->fast_simple_add (len, VERY_SMALL_SIGNAL);
|
||||
dst->fast_simple_add (len, GAIN_COEFF_SMALL);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -791,8 +789,8 @@ AudioRegion::state ()
|
||||
// so, if they are both at 1.0f, that means the default region.
|
||||
|
||||
if (_envelope->size() == 2 &&
|
||||
_envelope->front()->value == 1.0f &&
|
||||
_envelope->back()->value==1.0f) {
|
||||
_envelope->front()->value == GAIN_COEFF_UNITY &&
|
||||
_envelope->back()->value==GAIN_COEFF_UNITY) {
|
||||
if (_envelope->front()->when == 0 && _envelope->back()->when == _length) {
|
||||
default_env = true;
|
||||
}
|
||||
@ -1026,8 +1024,8 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
|
||||
|
||||
switch (shape) {
|
||||
case FadeLinear:
|
||||
_fade_in->fast_simple_add (0.0, VERY_SMALL_SIGNAL);
|
||||
_fade_in->fast_simple_add (len, 1.0);
|
||||
_fade_in->fast_simple_add (0.0, GAIN_COEFF_SMALL);
|
||||
_fade_in->fast_simple_add (len, GAIN_COEFF_UNITY);
|
||||
reverse_curve (_inverse_fade_in.val(), _fade_in.val());
|
||||
break;
|
||||
|
||||
@ -1048,12 +1046,12 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
|
||||
break;
|
||||
|
||||
case FadeConstantPower:
|
||||
_fade_in->fast_simple_add (0.0, VERY_SMALL_SIGNAL);
|
||||
_fade_in->fast_simple_add (0.0, GAIN_COEFF_SMALL);
|
||||
for (int i = 1; i < num_steps; ++i) {
|
||||
const float dist = i / (num_steps + 1.f);
|
||||
_fade_in->fast_simple_add (len * dist, sin (dist * M_PI / 2.0));
|
||||
}
|
||||
_fade_in->fast_simple_add (len, 1.0);
|
||||
_fade_in->fast_simple_add (len, GAIN_COEFF_UNITY);
|
||||
reverse_curve (_inverse_fade_in.val(), _fade_in.val());
|
||||
break;
|
||||
|
||||
@ -1065,9 +1063,9 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len)
|
||||
const double breakpoint = 0.7; //linear for first 70%
|
||||
for (int i = 2; i < 9; ++i) {
|
||||
const float coeff = (1.f - breakpoint) * powf (0.5, i);
|
||||
_fade_in->fast_simple_add (len * (breakpoint + ((1.0 - breakpoint) * (double)i / 9.0)), coeff);
|
||||
_fade_in->fast_simple_add (len * (breakpoint + ((GAIN_COEFF_UNITY - breakpoint) * (double)i / 9.0)), coeff);
|
||||
}
|
||||
_fade_in->fast_simple_add (len, VERY_SMALL_SIGNAL);
|
||||
_fade_in->fast_simple_add (len, GAIN_COEFF_SMALL);
|
||||
reverse_curve (c3, _fade_in.val());
|
||||
_fade_in->copy_events (*c3);
|
||||
reverse_curve (_inverse_fade_in.val(), _fade_in.val());
|
||||
@ -1108,8 +1106,8 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
|
||||
|
||||
switch (shape) {
|
||||
case FadeLinear:
|
||||
_fade_out->fast_simple_add (0.0, 1.0);
|
||||
_fade_out->fast_simple_add (len, VERY_SMALL_SIGNAL);
|
||||
_fade_out->fast_simple_add (0.0, GAIN_COEFF_UNITY);
|
||||
_fade_out->fast_simple_add (len, GAIN_COEFF_SMALL);
|
||||
reverse_curve (_inverse_fade_out.val(), _fade_out.val());
|
||||
break;
|
||||
|
||||
@ -1128,12 +1126,12 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
|
||||
case FadeConstantPower:
|
||||
//constant-power fades use a sin/cos relationship
|
||||
//the cutoff is abrupt but it has the benefit of being symmetrical
|
||||
_fade_out->fast_simple_add (0.0, 1.0);
|
||||
_fade_out->fast_simple_add (0.0, GAIN_COEFF_UNITY);
|
||||
for (int i = 1; i < num_steps; ++i) {
|
||||
const float dist = i / (num_steps + 1.f);
|
||||
_fade_out->fast_simple_add (len * dist, cos (dist * M_PI / 2.0));
|
||||
}
|
||||
_fade_out->fast_simple_add (len, VERY_SMALL_SIGNAL);
|
||||
_fade_out->fast_simple_add (len, GAIN_COEFF_SMALL);
|
||||
reverse_curve (_inverse_fade_out.val(), _fade_out.val());
|
||||
break;
|
||||
|
||||
@ -1145,9 +1143,9 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len)
|
||||
const double breakpoint = 0.7; //linear for first 70%
|
||||
for (int i = 2; i < 9; ++i) {
|
||||
const float coeff = (1.f - breakpoint) * powf (0.5, i);
|
||||
_fade_out->fast_simple_add (len * (breakpoint + ((1.0 - breakpoint) * (double)i / 9.0)), coeff);
|
||||
_fade_out->fast_simple_add (len * (breakpoint + ((GAIN_COEFF_UNITY - breakpoint) * (double)i / 9.0)), coeff);
|
||||
}
|
||||
_fade_out->fast_simple_add (len, VERY_SMALL_SIGNAL);
|
||||
_fade_out->fast_simple_add (len, GAIN_COEFF_SMALL);
|
||||
reverse_curve (_inverse_fade_out.val(), _fade_out.val());
|
||||
break;
|
||||
}
|
||||
@ -1266,8 +1264,8 @@ AudioRegion::set_default_envelope ()
|
||||
{
|
||||
_envelope->freeze ();
|
||||
_envelope->clear ();
|
||||
_envelope->fast_simple_add (0, 1.0f);
|
||||
_envelope->fast_simple_add (_length, 1.0f);
|
||||
_envelope->fast_simple_add (0, GAIN_COEFF_UNITY);
|
||||
_envelope->fast_simple_add (_length, GAIN_COEFF_UNITY);
|
||||
_envelope->thaw ();
|
||||
}
|
||||
|
||||
@ -1447,14 +1445,14 @@ AudioRegion::normalize (float max_amplitude, float target_dB)
|
||||
{
|
||||
gain_t target = dB_to_coefficient (target_dB);
|
||||
|
||||
if (target == 1.0f) {
|
||||
if (target == GAIN_COEFF_UNITY) {
|
||||
/* do not normalize to precisely 1.0 (0 dBFS), to avoid making it appear
|
||||
that we may have clipped.
|
||||
*/
|
||||
target -= FLT_EPSILON;
|
||||
}
|
||||
|
||||
if (max_amplitude == 0.0f) {
|
||||
if (max_amplitude < GAIN_COEFF_SMALL) {
|
||||
/* don't even try */
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<IO> io, boost::shared_ptr<Pann
|
||||
: IOProcessor(s, boost::shared_ptr<IO>(), (role_requires_output_ports (r) ? io : boost::shared_ptr<IO>()), name)
|
||||
, _role (r)
|
||||
, _output_buffers (new BufferSet())
|
||||
, _current_gain (1.0)
|
||||
, _current_gain (GAIN_COEFF_UNITY)
|
||||
, _no_outs_cuz_we_no_monitor (false)
|
||||
, _mute_master (mm)
|
||||
, _no_panner_reset (false)
|
||||
@ -76,7 +76,7 @@ Delivery::Delivery (Session& s, boost::shared_ptr<Pannable> pannable, boost::sha
|
||||
: IOProcessor(s, false, (role_requires_output_ports (r) ? true : false), name, "", DataType::AUDIO, (r == Send))
|
||||
, _role (r)
|
||||
, _output_buffers (new BufferSet())
|
||||
, _current_gain (1.0)
|
||||
, _current_gain (GAIN_COEFF_UNITY)
|
||||
, _no_outs_cuz_we_no_monitor (false)
|
||||
, _mute_master (mm)
|
||||
, _no_panner_reset (false)
|
||||
@ -264,7 +264,7 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf
|
||||
|
||||
_current_gain = Amp::apply_gain (bufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain);
|
||||
|
||||
} else if (tgain == 0.0) {
|
||||
} else if (tgain < GAIN_COEFF_SMALL) {
|
||||
|
||||
/* we were quiet last time, and we're still supposed to be quiet.
|
||||
Silence the outputs, and make sure the buffers are quiet too,
|
||||
@ -273,11 +273,11 @@ Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pf
|
||||
_output->silence (nframes);
|
||||
if (result_required) {
|
||||
bufs.set_count (output_buffers().count ());
|
||||
Amp::apply_simple_gain (bufs, nframes, 0.0);
|
||||
Amp::apply_simple_gain (bufs, nframes, GAIN_COEFF_ZERO);
|
||||
}
|
||||
goto out;
|
||||
|
||||
} else if (tgain != 1.0) {
|
||||
} else if (tgain != GAIN_COEFF_UNITY) {
|
||||
|
||||
/* target gain has not changed, but is not unity */
|
||||
Amp::apply_simple_gain (bufs, nframes, tgain);
|
||||
@ -498,7 +498,7 @@ Delivery::target_gain ()
|
||||
/* if we've been requested to deactivate, our target gain is zero */
|
||||
|
||||
if (!_pending_active) {
|
||||
return 0.0;
|
||||
return GAIN_COEFF_ZERO;
|
||||
}
|
||||
|
||||
/* if we've been told not to output because its a monitoring situation and
|
||||
@ -506,7 +506,7 @@ Delivery::target_gain ()
|
||||
*/
|
||||
|
||||
if (_no_outs_cuz_we_no_monitor) {
|
||||
return 0.0;
|
||||
return GAIN_COEFF_ZERO;
|
||||
}
|
||||
|
||||
MuteMaster::MutePoint mp = MuteMaster::Main; // stupid gcc uninit warning
|
||||
@ -538,7 +538,7 @@ Delivery::target_gain ()
|
||||
it gets its signal from the master out.
|
||||
*/
|
||||
|
||||
desired_gain = 0.0;
|
||||
desired_gain = GAIN_COEFF_ZERO;
|
||||
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ ExportFormatSpecification::ExportFormatSpecification (Session & s)
|
||||
, _silence_end (s)
|
||||
|
||||
, _normalize (false)
|
||||
, _normalize_target (1.0)
|
||||
, _normalize_target (GAIN_COEFF_UNITY)
|
||||
, _with_toc (false)
|
||||
, _with_cue (false)
|
||||
, _with_mp4chaps (false)
|
||||
|
@ -74,10 +74,10 @@ InternalSend::init_gain ()
|
||||
{
|
||||
if (_role == Listen) {
|
||||
/* send to monitor bus is always at unity */
|
||||
_amp->set_gain (1.0, this);
|
||||
_amp->set_gain (GAIN_COEFF_UNITY, this);
|
||||
} else {
|
||||
/* aux sends start at -inf dB */
|
||||
_amp->set_gain (0, this);
|
||||
_amp->set_gain (GAIN_COEFF_ZERO, this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,16 +196,16 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
|
||||
|
||||
_current_gain = Amp::apply_gain (mixbufs, _session.nominal_frame_rate(), nframes, _current_gain, tgain);
|
||||
|
||||
} else if (tgain == 0.0) {
|
||||
} else if (tgain == GAIN_COEFF_ZERO) {
|
||||
|
||||
/* we were quiet last time, and we're still supposed to be quiet.
|
||||
*/
|
||||
|
||||
_meter->reset ();
|
||||
Amp::apply_simple_gain (mixbufs, nframes, 0.0);
|
||||
Amp::apply_simple_gain (mixbufs, nframes, GAIN_COEFF_ZERO);
|
||||
goto out;
|
||||
|
||||
} else if (tgain != 1.0) {
|
||||
} else if (tgain != GAIN_COEFF_UNITY) {
|
||||
|
||||
/* target gain has not changed, but is not zero or unity */
|
||||
Amp::apply_simple_gain (mixbufs, nframes, tgain);
|
||||
@ -220,7 +220,7 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
|
||||
/* consider metering */
|
||||
|
||||
if (_metering) {
|
||||
if (_amp->gain_control()->get_value() == 0) {
|
||||
if (_amp->gain_control()->get_value() == GAIN_COEFF_ZERO) {
|
||||
_meter->reset();
|
||||
} else {
|
||||
_meter->run (mixbufs, start_frame, end_frame, nframes, true);
|
||||
|
@ -182,9 +182,9 @@ MonitorProcessor::set_state (const XMLNode& node, int version)
|
||||
|
||||
if ((prop = (*i)->property ("cut")) != 0) {
|
||||
if (string_is_affirmative (prop->value())){
|
||||
cr.cut = 0.0f;
|
||||
cr.cut = GAIN_COEFF_ZERO;
|
||||
} else {
|
||||
cr.cut = 1.0f;
|
||||
cr.cut = GAIN_COEFF_UNITY;
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,8 +256,8 @@ MonitorProcessor::state (bool full)
|
||||
snprintf (buf, sizeof (buf), "%u", chn);
|
||||
chn_node->add_property ("id", buf);
|
||||
|
||||
chn_node->add_property (X_("cut"), (*x)->cut == 1.0f ? "no" : "yes");
|
||||
chn_node->add_property (X_("invert"), (*x)->polarity == 1.0f ? "no" : "yes");
|
||||
chn_node->add_property (X_("cut"), (*x)->cut == GAIN_COEFF_UNITY ? "no" : "yes");
|
||||
chn_node->add_property (X_("invert"), (*x)->polarity == GAIN_COEFF_UNITY ? "no" : "yes");
|
||||
chn_node->add_property (X_("dim"), (*x)->dim ? "yes" : "no");
|
||||
chn_node->add_property (X_("solo"), (*x)->soloed ? "yes" : "no");
|
||||
|
||||
@ -273,21 +273,21 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
|
||||
uint32_t chn = 0;
|
||||
gain_t target_gain;
|
||||
gain_t dim_level_this_time = _dim_level;
|
||||
gain_t global_cut = (_cut_all ? 0.0f : 1.0f);
|
||||
gain_t global_dim = (_dim_all ? dim_level_this_time : 1.0);
|
||||
gain_t global_cut = (_cut_all ? GAIN_COEFF_ZERO : GAIN_COEFF_UNITY);
|
||||
gain_t global_dim = (_dim_all ? dim_level_this_time : GAIN_COEFF_UNITY);
|
||||
gain_t solo_boost;
|
||||
|
||||
if (_session.listening() || _session.soloing()) {
|
||||
solo_boost = _solo_boost_level;
|
||||
} else {
|
||||
solo_boost = 1.0;
|
||||
solo_boost = GAIN_COEFF_UNITY;
|
||||
}
|
||||
|
||||
for (BufferSet::audio_iterator b = bufs.audio_begin(); b != bufs.audio_end(); ++b) {
|
||||
|
||||
/* don't double-scale by both track dim and global dim coefficients */
|
||||
|
||||
gain_t dim_level = (global_dim == 1.0 ? (_channels[chn]->dim ? dim_level_this_time : 1.0) : 1.0);
|
||||
gain_t dim_level = (global_dim == GAIN_COEFF_UNITY ? (_channels[chn]->dim ? dim_level_this_time : GAIN_COEFF_UNITY) : GAIN_COEFF_UNITY);
|
||||
|
||||
if (_channels[chn]->soloed) {
|
||||
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
|
||||
@ -295,11 +295,11 @@ MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /
|
||||
if (solo_cnt == 0) {
|
||||
target_gain = _channels[chn]->polarity * _channels[chn]->cut * dim_level * global_cut * global_dim * solo_boost;
|
||||
} else {
|
||||
target_gain = 0.0;
|
||||
target_gain = GAIN_COEFF_ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
if (target_gain != _channels[chn]->current_gain || target_gain != 1.0f) {
|
||||
if (target_gain != _channels[chn]->current_gain || target_gain != GAIN_COEFF_UNITY) {
|
||||
|
||||
_channels[chn]->current_gain = Amp::apply_gain (*b, _session.nominal_frame_rate(), nframes, _channels[chn]->current_gain, target_gain);
|
||||
}
|
||||
@ -380,9 +380,9 @@ void
|
||||
MonitorProcessor::set_cut (uint32_t chn, bool yn)
|
||||
{
|
||||
if (yn) {
|
||||
_channels[chn]->cut = 0.0f;
|
||||
_channels[chn]->cut = GAIN_COEFF_ZERO;
|
||||
} else {
|
||||
_channels[chn]->cut = 1.0f;
|
||||
_channels[chn]->cut = GAIN_COEFF_UNITY;
|
||||
}
|
||||
}
|
||||
|
||||
@ -443,7 +443,7 @@ MonitorProcessor::inverted (uint32_t chn) const
|
||||
bool
|
||||
MonitorProcessor::cut (uint32_t chn) const
|
||||
{
|
||||
return _channels[chn]->cut == 0.0f;
|
||||
return _channels[chn]->cut == GAIN_COEFF_ZERO;
|
||||
}
|
||||
|
||||
bool
|
||||
@ -507,7 +507,7 @@ MonitorProcessor::channel_solo_control (uint32_t chn) const
|
||||
}
|
||||
|
||||
MonitorProcessor::ChannelRecord::ChannelRecord (uint32_t chn)
|
||||
: current_gain (1.0)
|
||||
: current_gain (GAIN_COEFF_UNITY)
|
||||
, cut_ptr (new MPControl<gain_t> (1.0, string_compose (_("cut control %1"), chn), PBD::Controllable::GainLike))
|
||||
, dim_ptr (new MPControl<bool> (false, string_compose (_("dim control"), chn), PBD::Controllable::Toggle))
|
||||
, polarity_ptr (new MPControl<gain_t> (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle, -1, 1))
|
||||
|
@ -90,26 +90,26 @@ MuteMaster::mute_gain_at (MutePoint mp) const
|
||||
|
||||
if (Config->get_solo_mute_override()) {
|
||||
if (_soloed) {
|
||||
gain = 1.0;
|
||||
gain = GAIN_COEFF_UNITY;
|
||||
} else if (muted_by_self_at (mp)) {
|
||||
gain = 0.0;
|
||||
gain = GAIN_COEFF_ZERO;
|
||||
} else {
|
||||
if (muted_by_others_at (mp)) {
|
||||
gain = Config->get_solo_mute_gain ();
|
||||
} else {
|
||||
gain = 1.0;
|
||||
gain = GAIN_COEFF_UNITY;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (muted_by_self_at (mp)) {
|
||||
gain = 0.0;
|
||||
gain = GAIN_COEFF_ZERO;
|
||||
} else if (_soloed) {
|
||||
gain = 1.0;
|
||||
gain = GAIN_COEFF_UNITY;
|
||||
} else {
|
||||
if (muted_by_others_at (mp)) {
|
||||
gain = Config->get_solo_mute_gain ();
|
||||
} else {
|
||||
gain = 1.0;
|
||||
gain = GAIN_COEFF_UNITY;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -284,13 +284,13 @@ PannerShell::distribute_no_automation (BufferSet& inbufs, BufferSet& outbufs, pf
|
||||
|
||||
AudioBuffer& dst = outbufs.get_audio(0);
|
||||
|
||||
if (gain_coeff == 0.0f) {
|
||||
if (gain_coeff == GAIN_COEFF_ZERO) {
|
||||
|
||||
/* gain was zero, so make it silent */
|
||||
|
||||
dst.silence (nframes);
|
||||
|
||||
} else if (gain_coeff == 1.0f){
|
||||
} else if (gain_coeff == GAIN_COEFF_UNITY){
|
||||
|
||||
/* mix all input buffers into the output */
|
||||
|
||||
@ -386,7 +386,7 @@ PannerShell::run (BufferSet& inbufs, BufferSet& outbufs, framepos_t start_frame,
|
||||
if (!(as & Play || ((as & Touch) && !_panner->touching()))) {
|
||||
|
||||
// Speed quietning
|
||||
gain_t gain_coeff = 1.0;
|
||||
gain_t gain_coeff = GAIN_COEFF_UNITY;
|
||||
|
||||
if (fabsf(_session.transport_speed()) > 1.5f && Config->get_quieten_at_speed ()) {
|
||||
gain_coeff = speed_quietning;
|
||||
|
@ -3457,9 +3457,9 @@ Route::SoloControllable::get_value () const
|
||||
}
|
||||
|
||||
if (Config->get_solo_control_is_listen_control()) {
|
||||
return r->listening_via_monitor() ? 1.0f : 0.0f;
|
||||
return r->listening_via_monitor() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
|
||||
} else {
|
||||
return r->self_soloed() ? 1.0f : 0.0f;
|
||||
return r->self_soloed() ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3521,7 +3521,7 @@ Route::MuteControllable::get_value () const
|
||||
|
||||
// Not playing back automation, get the actual route mute value
|
||||
boost::shared_ptr<Route> r = _route.lock ();
|
||||
return (r && r->muted()) ? 1.0 : 0.0;
|
||||
return (r && r->muted()) ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2775,7 +2775,7 @@ Session::globally_set_send_gains_to_zero (boost::shared_ptr<Route> dest)
|
||||
|
||||
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
||||
if ((s = (*i)->internal_send_for (dest)) != 0) {
|
||||
s->amp()->gain_control()->set_value (0.0);
|
||||
s->amp()->gain_control()->set_value (GAIN_COEFF_ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2788,7 +2788,7 @@ Session::globally_set_send_gains_to_unity (boost::shared_ptr<Route> dest)
|
||||
|
||||
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
|
||||
if ((s = (*i)->internal_send_for (dest)) != 0) {
|
||||
s->amp()->gain_control()->set_value (1.0);
|
||||
s->amp()->gain_control()->set_value (GAIN_COEFF_UNITY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user