+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
#include "pbd/convert.h"
#include "pbd/error.h"
#include "pbd/locale_guard.h"
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;
}
}
XMLNode&
MonitorProcessor::state (bool full)
{
- LocaleGuard lg (X_("POSIX"));
+ LocaleGuard lg (X_("C"));
XMLNode& node (Processor::state (full));
char buf[64];
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) {
- Amp::apply_gain (*b, nframes, _channels[chn]->current_gain, target_gain);
- _channels[chn]->current_gain = target_gain;
+ _channels[chn]->current_gain = Amp::apply_gain (*b, _session.nominal_frame_rate(), nframes, _channels[chn]->current_gain, target_gain);
}
++chn;
/* chn is now the number of channels, use as a scaling factor when mixing
*/
- gain_t scale = 1.0/chn;
+ gain_t scale = 1.f / (float)chn;
BufferSet::audio_iterator b = bufs.audio_begin();
AudioBuffer& ab (*b);
Sample* buf = ab.data();
}
bool
-MonitorProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& out) const
+MonitorProcessor::can_support_io_configuration (const ChanCount& in, ChanCount& out)
{
out = in;
return true;
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))
+ , polarity_ptr (new MPControl<gain_t> (1.0, string_compose (_("polarity control"), chn), PBD::Controllable::Toggle, -1, 1))
, soloed_ptr (new MPControl<bool> (false, string_compose (_("solo control"), chn), PBD::Controllable::Toggle))
, cut_control (cut_ptr)