Remove muting behaviour from the Amp processor. Fix some small

bugs with delivery muting.  The upshot being that muting now definitely
happens in a channel's deliveries, and not really in the channel strip
at all.  When the channel is muted, those deliveries described by
the MuteMaster settings are muted.  Should fix #3141.



git-svn-id: svn://localhost/ardour2/branches/3.0@7115 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington
2010-05-17 23:28:13 +00:00
parent 6d9c1201cc
commit f35dc8b35d
10 changed files with 63 additions and 76 deletions

View File

@@ -29,19 +29,17 @@
#include "ardour/configuration.h"
#include "ardour/io.h"
#include "ardour/midi_buffer.h"
#include "ardour/mute_master.h"
#include "ardour/session.h"
#include "i18n.h"
using namespace ARDOUR;
Amp::Amp(Session& s, boost::shared_ptr<MuteMaster> mm)
Amp::Amp (Session& s)
: Processor(s, "Amp")
, _apply_gain(true)
, _apply_gain_automation(false)
, _current_gain(1.0)
, _mute_master (mm)
{
boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(GainAutomation)));
_gain_control = boost::shared_ptr<GainControl>( new GainControl(X_("gaincontrol"), s, this, Evoral::Parameter(GainAutomation), gl ));
@@ -74,75 +72,28 @@ Amp::configure_io (ChanCount in, ChanCount out)
void
Amp::run (BufferSet& bufs, sframes_t /*start_frame*/, sframes_t /*end_frame*/, nframes_t nframes, bool)
{
gain_t mute_gain;
if (!_active && !_pending_active) {
return;
}
if (_mute_master) {
mute_gain = _mute_master->mute_gain_at (MuteMaster::PreFader);
} else {
mute_gain = 1.0;
}
if (_apply_gain) {
if (_apply_gain_automation) {
gain_t* gab = _session.gain_automation_buffer ();
if (mute_gain == 0.0) {
/* absolute mute */
if (_current_gain == 0.0) {
/* already silent */
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
i->clear ();
}
} else {
/* cut to silence */
Amp::apply_gain (bufs, nframes, _current_gain, 0.0);
_current_gain = 0.0;
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
Sample* const sp = i->data();
for (nframes_t nx = 0; nx < nframes; ++nx) {
sp[nx] *= gab[nx];
}
} else if (mute_gain != 1.0) {
/* mute dimming */
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
Sample* const sp = i->data();
for (nframes_t nx = 0; nx < nframes; ++nx) {
sp[nx] *= gab[nx] * mute_gain;
}
}
_current_gain = gab[nframes-1] * mute_gain;
} else {
/* no mute */
for (BufferSet::audio_iterator i = bufs.audio_begin(); i != bufs.audio_end(); ++i) {
Sample* const sp = i->data();
for (nframes_t nx = 0; nx < nframes; ++nx) {
sp[nx] *= gab[nx];
}
}
_current_gain = gab[nframes-1];
}
_current_gain = gab[nframes-1];
} else { /* manual (scalar) gain */
gain_t dg = _gain_control->user_float() * mute_gain;
gain_t const dg = _gain_control->user_float();
if (_current_gain != dg) {

View File

@@ -28,14 +28,13 @@ namespace ARDOUR {
class BufferSet;
class IO;
class MuteMaster;
/** Applies a declick operation to all audio inputs, passing the same number of
* audio outputs, and passing through any other types unchanged.
*/
class Amp : public Processor {
public:
Amp(Session& s, boost::shared_ptr<MuteMaster> m);
Amp(Session& s);
std::string display_name() const;
@@ -101,7 +100,6 @@ private:
float _current_gain;
boost::shared_ptr<GainControl> _gain_control;
boost::shared_ptr<MuteMaster> _mute_master;
};

View File

@@ -34,11 +34,12 @@ class Session;
class MuteMaster : public SessionHandleRef, public PBD::Stateful
{
public:
/** deliveries to mute when the channel is "muted" */
enum MutePoint {
PreFader = 0x1,
PostFader = 0x2,
Listen = 0x4,
Main = 0x8
PreFader = 0x1, ///< mute all pre-fader sends
PostFader = 0x2, ///< mute all post-fader sends
Listen = 0x4, ///< mute listen out
Main = 0x8 ///< mute main out
};
static const MutePoint AllPoints;

View File

@@ -97,6 +97,8 @@ class Processor : public SessionObject, public AutomatableControls, public Laten
void *get_gui () const { return _gui; }
void set_gui (void *p) { _gui = p; }
void set_pre_fader (bool);
PBD::Signal0<void> ActiveChanged;
PBD::Signal2<void,ChanCount,ChanCount> ConfigurationChanged;
@@ -108,7 +110,8 @@ protected:
ChanCount _configured_input;
ChanCount _configured_output;
void* _gui; /* generic, we don't know or care what this is */
bool _display_to_user;
bool _display_to_user;
bool _pre_fader;
private:
int set_state_2X (const XMLNode&, int version);

View File

@@ -123,7 +123,7 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
void inc_gain (gain_t delta, void *src);
void set_mute_points (MuteMaster::MutePoint);
MuteMaster::MutePoint mute_points() const { return _mute_points; }
MuteMaster::MutePoint mute_points () const;
bool muted () const;
void set_mute (bool yn, void* src);
@@ -423,7 +423,6 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
boost::shared_ptr<SoloControllable> _solo_control;
boost::shared_ptr<MuteControllable> _mute_control;
boost::shared_ptr<MuteMaster> _mute_master;
MuteMaster::MutePoint _mute_points;
std::string _comment;
bool _have_internal_generator;
@@ -477,6 +476,8 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
void set_self_solo (bool yn);
void set_mute_master_solo ();
void set_processor_positions ();
};
} // namespace ARDOUR

View File

@@ -495,12 +495,14 @@ Delivery::target_gain ()
case Send:
case Insert:
case Aux:
/* XXX FIX ME this is wrong, we need per-delivery muting */
mp = MuteMaster::PreFader;
if (_pre_fader) {
mp = MuteMaster::PreFader;
} else {
mp = MuteMaster::PostFader;
}
break;
}
// cerr << name() << ' ';
desired_gain = _mute_master->mute_gain_at (mp);
if (_role == Listen && _session.monitor_out() && !_session.listening()) {

View File

@@ -68,6 +68,7 @@ Processor::Processor(Session& session, const string& name)
, _configured(false)
, _gui(0)
, _display_to_user (true)
, _pre_fader (false)
{
}
@@ -263,3 +264,8 @@ Processor::set_display_to_user (bool yn)
_display_to_user = yn;
}
void
Processor::set_pre_fader (bool p)
{
_pre_fader = p;
}

View File

@@ -30,6 +30,7 @@
#include "ardour/port.h"
#include "ardour/return.h"
#include "ardour/session.h"
#include "ardour/mute_master.h"
#include "i18n.h"
@@ -43,7 +44,7 @@ Return::Return (Session& s, bool internal)
{
/* never muted */
_amp.reset (new Amp (_session, boost::shared_ptr<MuteMaster>()));
_amp.reset (new Amp (_session));
_meter.reset (new PeakMeter (_session));
}

View File

@@ -90,7 +90,6 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, _solo_control (new SoloControllable (X_("solo"), *this))
, _mute_control (new MuteControllable (X_("mute"), *this))
, _mute_master (new MuteMaster (sess, name))
, _mute_points (MuteMaster::AllPoints)
, _have_internal_generator (false)
, _solo_safe (false)
, _default_type (default_type)
@@ -122,7 +121,7 @@ Route::init ()
/* add amp processor */
_amp.reset (new Amp (_session, _mute_master));
_amp.reset (new Amp (_session));
add_processor (_amp, PostFader);
/* add standard processors: meter, main outs, monitor out */
@@ -746,8 +745,7 @@ Route::solo_isolated () const
void
Route::set_mute_points (MuteMaster::MutePoint mp)
{
_mute_points = mp;
_mute_master->set_mute_points (MuteMaster::AllPoints);
_mute_master->set_mute_points (mp);
mute_points_changed (); /* EMIT SIGNAL */
if (_mute_master->muted()) {
@@ -891,6 +889,7 @@ Route::add_processor (boost::shared_ptr<Processor> processor, ProcessorList::ite
}
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
return 0;
}
@@ -1035,6 +1034,7 @@ Route::add_processors (const ProcessorList& others, ProcessorList::iterator iter
}
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
return 0;
}
@@ -1235,6 +1235,7 @@ Route::clear_processors (Placement p)
processor_max_streams.reset();
_have_internal_generator = false;
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
if (!already_deleting) {
_session.clear_deletion_in_progress();
@@ -1326,6 +1327,7 @@ Route::remove_processor (boost::shared_ptr<Processor> processor, ProcessorStream
processor->drop_references ();
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
return 0;
}
@@ -1417,6 +1419,7 @@ Route::remove_processors (const ProcessorList& to_be_deleted, ProcessorStreams*
}
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
return 0;
}
@@ -1662,6 +1665,7 @@ Route::reorder_processors (const ProcessorList& new_order, ProcessorStreams* err
if (true) {
processors_changed (RouteProcessorChange ()); /* EMIT SIGNAL */
set_processor_positions ();
}
return 0;
@@ -2309,6 +2313,7 @@ Route::set_processor_state (const XMLNode& node)
}
processors_changed (RouteProcessorChange ());
set_processor_positions ();
}
void
@@ -3353,3 +3358,22 @@ Route::has_io_processor_named (const string& name)
return false;
}
MuteMaster::MutePoint
Route::mute_points () const
{
return _mute_master->mute_points ();
}
void
Route::set_processor_positions ()
{
Glib::RWLock::ReaderLock lm (_processor_lock);
bool had_amp = false;
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
(*i)->set_pre_fader (!had_amp);
if (boost::dynamic_pointer_cast<Amp> (*i)) {
had_amp = true;
}
}
}

View File

@@ -42,7 +42,7 @@ Send::Send (Session& s, boost::shared_ptr<MuteMaster> mm, Role r)
: Delivery (s, mm, string_compose (_("send %1"), (_bitslot = s.next_send_id()) + 1), r)
, _metering (false)
{
_amp.reset (new Amp (_session, _mute_master));
_amp.reset (new Amp (_session));
_meter.reset (new PeakMeter (_session));
}