provide a real and usable MuteControllable for Routes (so that MIDI can use it)
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jan 2010 18:15:29 +0000 (18:15 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 4 Jan 2010 18:15:29 +0000 (18:15 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6445 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/mute_master.h
libs/ardour/ardour/route.h
libs/ardour/mute_master.cc
libs/ardour/route.cc
libs/ardour/session_export.cc
libs/surfaces/generic_midi/generic_midi_control_protocol.cc
libs/surfaces/generic_midi/midicontrollable.cc

index afc1037e42bbde37ea6a458c4893ea1d46435553..0e3c10b795b02e6a2250c3b59cdbcef84e02fecb 100644 (file)
 #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<void> MutePointChanged;
 
        XMLNode& get_state();
        int set_state(const XMLNode&, int version);
 
   private:
-       AutomationList* _automation;
        MutePoint _mute_point;
 };
 
index 22ca95d4ec03e1733298682f784c6af6f8603bfc..4157541229b9d8f08f43142113f18cd9513acbcd 100644 (file)
@@ -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<AutomationControl> solo_control() const {
                return _solo_control;
        }
 
        boost::shared_ptr<AutomationControl> mute_control() const {
-               return _mute_master;
+               return _mute_control;
        }
 
        boost::shared_ptr<MuteMaster> mute_master() const {
@@ -372,6 +380,7 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
        bool _declickable : 1;
 
        boost::shared_ptr<SoloControllable> _solo_control;
+       boost::shared_ptr<MuteControllable> _mute_control;
        boost::shared_ptr<MuteMaster> _mute_master;
        MuteMaster::MutePoint _mute_points;
 
index 1d0b2dda0690b23b725e1acca08890a4e33fa899..14411580fd5806256743ceaea4aa69d330db6c8f 100644 (file)
@@ -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<AutomationList>(), name)
-       , _mute_point (MutePoint (0))
+       : _mute_point (MutePoint (0))
 {
-       // default range for parameter is fine
-
-       _automation = new AutomationList (MuteAutomation);
-       set_list (boost::shared_ptr<AutomationList>(_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*/)
 {
index 3ae5e90b7b546b9c75fa0d68b22156a40808faf7..44b0acb50ab3b710c8d25cde480b66ed2d9cf19e 100644 (file)
@@ -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<AutomationList>(), name)
+       , route (r)
+{
+       boost::shared_ptr<AutomationList> 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<RouteList> 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)
 {
index 9a277f565510c07bb650951f54f48f53c010d6fe..ea215e6058c47ee28caefccbed30a1da1709d8cb 100644 (file)
@@ -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 ();
index c9cc8c76cdd20f9b05901dc60af7a27c6e880043..db29a4c70aab1c9b41689c6abb5974a762e30e9a 100644 (file)
@@ -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;
 }
 
index e5173c5345d1c8175c68237b74b57b3ccd785470..6087a857be2d682e86925f16c26ee7189b580e7e 100644 (file)
@@ -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);
                }
        }