#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"
/* 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);
}
// 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);
}
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);
void
GainMeterBase::effective_gain_display ()
{
- float value = 0.0;
+ float value = GAIN_COEFF_ZERO;
switch (_data_type) {
case DataType::AUDIO:
: 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)
{
_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
*/
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 */
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);
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);
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);
}
}
{
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);
#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;
}
/* 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); */
/* 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) {
}
}
-static const double VERY_SMALL_SIGNAL = 0.0000001; //-140dB
-
/* Curve manipulations */
static void
//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
// 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;
}
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;
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;
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());
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;
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;
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;
}
{
_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 ();
}
{
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;
}
: 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)
: 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)
_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,
_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);
/* 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
*/
if (_no_outs_cuz_we_no_monitor) {
- return 0.0;
+ return GAIN_COEFF_ZERO;
}
MuteMaster::MutePoint mp = MuteMaster::Main; // stupid gcc uninit warning
it gets its signal from the master out.
*/
- desired_gain = 0.0;
+ desired_gain = GAIN_COEFF_ZERO;
}
, _silence_end (s)
, _normalize (false)
- , _normalize_target (1.0)
+ , _normalize_target (GAIN_COEFF_UNITY)
, _with_toc (false)
, _with_cue (false)
, _with_mp4chaps (false)
{
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);
}
}
_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);
/* 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);
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;
}
}
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");
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;
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);
}
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;
}
}
bool
MonitorProcessor::cut (uint32_t chn) const
{
- return _channels[chn]->cut == 0.0f;
+ return _channels[chn]->cut == GAIN_COEFF_ZERO;
}
bool
}
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))
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;
}
}
}
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 */
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;
}
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;
}
}
// 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
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);
}
}
}
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);
}
}
}