From 11792ed95dc9b9435045f1830eb4cf298e6d475d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 4 Jan 2010 18:15:29 +0000 Subject: provide a real and usable MuteControllable for Routes (so that MIDI can use it) git-svn-id: svn://localhost/ardour2/branches/3.0@6445 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/mute_master.h | 14 ++------ libs/ardour/ardour/route.h | 11 ++++++- libs/ardour/mute_master.cc | 37 ++-------------------- libs/ardour/route.cc | 36 +++++++++++++++++++-- libs/ardour/session_export.cc | 2 +- .../generic_midi/generic_midi_control_protocol.cc | 5 --- libs/surfaces/generic_midi/midicontrollable.cc | 6 +--- 7 files changed, 52 insertions(+), 59 deletions(-) (limited to 'libs') diff --git a/libs/ardour/ardour/mute_master.h b/libs/ardour/ardour/mute_master.h index afc1037e42..0e3c10b795 100644 --- a/libs/ardour/ardour/mute_master.h +++ b/libs/ardour/ardour/mute_master.h @@ -21,14 +21,14 @@ #define __ardour_mute_master_h__ #include "evoral/Parameter.hpp" -#include "ardour/automation_control.h" -#include "ardour/automation_list.h" +#include "pbd/signals.h" +#include "pbd/stateful.h" namespace ARDOUR { class Session; -class MuteMaster : public AutomationControl +class MuteMaster : public PBD::Stateful { public: enum MutePoint { @@ -57,20 +57,12 @@ class MuteMaster : public AutomationControl void mute_at (MutePoint); void unmute_at (MutePoint); - void mute (bool yn); - - /* Controllable interface */ - - void set_value (float); /* note: float is used as a bitfield of MutePoints */ - float get_value () const; - PBD::Signal0 MutePointChanged; XMLNode& get_state(); int set_state(const XMLNode&, int version); private: - AutomationList* _automation; MutePoint _mute_point; }; diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 22ca95d4ec..4157541229 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -284,12 +284,20 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou Route& route; }; + struct MuteControllable : public AutomationControl { + MuteControllable (std::string name, Route&); + void set_value (float); + float get_value (void) const; + + Route& route; + }; + boost::shared_ptr solo_control() const { return _solo_control; } boost::shared_ptr mute_control() const { - return _mute_master; + return _mute_control; } boost::shared_ptr mute_master() const { @@ -372,6 +380,7 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou bool _declickable : 1; boost::shared_ptr _solo_control; + boost::shared_ptr _mute_control; boost::shared_ptr _mute_master; MuteMaster::MutePoint _mute_points; diff --git a/libs/ardour/mute_master.cc b/libs/ardour/mute_master.cc index 1d0b2dda06..14411580fd 100644 --- a/libs/ardour/mute_master.cc +++ b/libs/ardour/mute_master.cc @@ -19,7 +19,9 @@ */ #include "pbd/enumwriter.h" +#include "pbd/xml++.h" +#include "ardour/types.h" #include "ardour/mute_master.h" #include "ardour/rc_configuration.h" @@ -33,13 +35,8 @@ const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFa MuteMaster::Main); MuteMaster::MuteMaster (Session& s, const std::string& name) - : AutomationControl (s, Evoral::Parameter (MuteAutomation), boost::shared_ptr(), name) - , _mute_point (MutePoint (0)) + : _mute_point (MutePoint (0)) { - // default range for parameter is fine - - _automation = new AutomationList (MuteAutomation); - set_list (boost::shared_ptr(_automation)); } void @@ -69,18 +66,6 @@ MuteMaster::unmute_at (MutePoint mp) } } -void -MuteMaster::mute (bool yn) -{ - /* convenience wrapper around AutomationControl method */ - - if (yn) { - set_value ((float) 0xffff); - } else { - set_value (0.0f); - } -} - gain_t MuteMaster::mute_gain_at (MutePoint mp) const { @@ -91,22 +76,6 @@ MuteMaster::mute_gain_at (MutePoint mp) const } } -void -MuteMaster::set_value (float f) -{ - MutePoint old = _mute_point; - _mute_point = (MutePoint) (rint (f)); - if (old != _mute_point) { - MutePointChanged (); // EMIT SIGNAL - } -} - -float -MuteMaster::get_value () const -{ - return (float) _mute_point; -} - int MuteMaster::set_state (const XMLNode& node, int /*version*/) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 3ae5e90b7b..44b0acb50a 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -72,6 +72,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type) , AutomatableControls (sess) , _flags (flg) , _solo_control (new SoloControllable (X_("solo"), *this)) + , _mute_control (new MuteControllable (X_("mute"), *this)) , _mute_master (new MuteMaster (sess, name)) , _default_type (default_type) @@ -102,6 +103,7 @@ Route::Route (Session& sess, const XMLNode& node, DataType default_type) : SessionObject (sess, "toBeReset") , AutomatableControls (sess) , _solo_control (new SoloControllable (X_("solo"), *this)) + , _mute_control (new MuteControllable (X_("mute"), *this)) , _mute_master (new MuteMaster (sess, "toBeReset")) , _default_type (default_type) { @@ -142,10 +144,10 @@ Route::init () /* add standard controls */ _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); - _mute_master->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); + _mute_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); add_control (_solo_control); - add_control (_mute_master); + add_control (_mute_control); /* input and output objects */ @@ -2878,6 +2880,36 @@ Route::SoloControllable::get_value (void) const } } +Route::MuteControllable::MuteControllable (std::string name, Route& r) + : AutomationControl (r.session(), Evoral::Parameter (MuteAutomation), + boost::shared_ptr(), name) + , route (r) +{ + boost::shared_ptr gl(new AutomationList(Evoral::Parameter(MuteAutomation))); + set_list (gl); +} + +void +Route::MuteControllable::set_value (float val) +{ + bool bval = ((val >= 0.5f) ? true: false); +# if 0 + this is how it should be done + + boost::shared_ptr rl (new RouteList); + rl->push_back (route); + _session.set_mute (rl, bval); +#else + route.set_mute (bval, this); +#endif +} + +float +Route::MuteControllable::get_value (void) const +{ + return route.muted() ? 1.0f : 0.0f; +} + void Route::set_block_size (nframes_t nframes) { diff --git a/libs/ardour/session_export.cc b/libs/ardour/session_export.cc index 9a277f5655..ea215e6058 100644 --- a/libs/ardour/session_export.cc +++ b/libs/ardour/session_export.cc @@ -96,7 +96,7 @@ Session::pre_export () } int -Session::start_audio_export (nframes_t position, bool realtime) +Session::start_audio_export (nframes_t position, bool /* realtime */) { if (!_exporting) { pre_export (); diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index c9cc8c76cd..db29a4c70a 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -704,15 +704,12 @@ GenericMidiControlProtocol::create_binding (const XMLNode& node) mc->bind_midi (channel, ev, detail); - cerr << "New MC with URI " << uri << " on channel " << (int) channel << " detail = " << (int) detail << endl; - return mc; } void GenericMidiControlProtocol::reset_controllables () { - cerr << "GM::RC\n"; Glib::Mutex::Lock lm2 (controllables_lock); for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) { @@ -817,10 +814,8 @@ GenericMidiControlProtocol::create_function (const XMLNode& node) return 0; } - cerr << "New MF with function = " << prop->value() << " on channel " << (int) channel << " detail = " << (int) detail << endl; mf->bind_midi (channel, ev, detail); - return mf; } diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index e5173c5345..6087a857be 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -185,7 +185,7 @@ MIDIControllable::midi_sense_note_off (Parser &p, EventTwoBytes *tb) } void -MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /* is_on */) +MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool is_on) { if (!controllable) { return; @@ -197,10 +197,6 @@ MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /* is_on * } else { if (control_additional == msg->note_number) { - /* Note: parser handles the use of zero velocity to - mean note off. if we get called with is_on=true, then we - got a *real* note on. - */ controllable->set_value (controllable->get_value() > 0.5f ? 0.0f : 1.0f); } } -- cgit v1.2.3