13
0

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
This commit is contained in:
Paul Davis 2010-01-04 18:15:29 +00:00
parent 18c5d24951
commit 11792ed95d
7 changed files with 52 additions and 59 deletions

View File

@ -21,14 +21,14 @@
#define __ardour_mute_master_h__ #define __ardour_mute_master_h__
#include "evoral/Parameter.hpp" #include "evoral/Parameter.hpp"
#include "ardour/automation_control.h" #include "pbd/signals.h"
#include "ardour/automation_list.h" #include "pbd/stateful.h"
namespace ARDOUR { namespace ARDOUR {
class Session; class Session;
class MuteMaster : public AutomationControl class MuteMaster : public PBD::Stateful
{ {
public: public:
enum MutePoint { enum MutePoint {
@ -57,20 +57,12 @@ class MuteMaster : public AutomationControl
void mute_at (MutePoint); void mute_at (MutePoint);
void unmute_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; PBD::Signal0<void> MutePointChanged;
XMLNode& get_state(); XMLNode& get_state();
int set_state(const XMLNode&, int version); int set_state(const XMLNode&, int version);
private: private:
AutomationList* _automation;
MutePoint _mute_point; MutePoint _mute_point;
}; };

View File

@ -284,12 +284,20 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
Route& route; 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 { boost::shared_ptr<AutomationControl> solo_control() const {
return _solo_control; return _solo_control;
} }
boost::shared_ptr<AutomationControl> mute_control() const { boost::shared_ptr<AutomationControl> mute_control() const {
return _mute_master; return _mute_control;
} }
boost::shared_ptr<MuteMaster> mute_master() const { boost::shared_ptr<MuteMaster> mute_master() const {
@ -372,6 +380,7 @@ class Route : public SessionObject, public AutomatableControls, public RouteGrou
bool _declickable : 1; bool _declickable : 1;
boost::shared_ptr<SoloControllable> _solo_control; boost::shared_ptr<SoloControllable> _solo_control;
boost::shared_ptr<MuteControllable> _mute_control;
boost::shared_ptr<MuteMaster> _mute_master; boost::shared_ptr<MuteMaster> _mute_master;
MuteMaster::MutePoint _mute_points; MuteMaster::MutePoint _mute_points;

View File

@ -19,7 +19,9 @@
*/ */
#include "pbd/enumwriter.h" #include "pbd/enumwriter.h"
#include "pbd/xml++.h"
#include "ardour/types.h"
#include "ardour/mute_master.h" #include "ardour/mute_master.h"
#include "ardour/rc_configuration.h" #include "ardour/rc_configuration.h"
@ -33,13 +35,8 @@ const MuteMaster::MutePoint MuteMaster::AllPoints = MutePoint (MuteMaster::PreFa
MuteMaster::Main); MuteMaster::Main);
MuteMaster::MuteMaster (Session& s, const std::string& name) 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 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 gain_t
MuteMaster::mute_gain_at (MutePoint mp) const 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 int
MuteMaster::set_state (const XMLNode& node, int /*version*/) MuteMaster::set_state (const XMLNode& node, int /*version*/)
{ {

View File

@ -72,6 +72,7 @@ Route::Route (Session& sess, string name, Flag flg, DataType default_type)
, AutomatableControls (sess) , AutomatableControls (sess)
, _flags (flg) , _flags (flg)
, _solo_control (new SoloControllable (X_("solo"), *this)) , _solo_control (new SoloControllable (X_("solo"), *this))
, _mute_control (new MuteControllable (X_("mute"), *this))
, _mute_master (new MuteMaster (sess, name)) , _mute_master (new MuteMaster (sess, name))
, _default_type (default_type) , _default_type (default_type)
@ -102,6 +103,7 @@ Route::Route (Session& sess, const XMLNode& node, DataType default_type)
: SessionObject (sess, "toBeReset") : SessionObject (sess, "toBeReset")
, AutomatableControls (sess) , AutomatableControls (sess)
, _solo_control (new SoloControllable (X_("solo"), *this)) , _solo_control (new SoloControllable (X_("solo"), *this))
, _mute_control (new MuteControllable (X_("mute"), *this))
, _mute_master (new MuteMaster (sess, "toBeReset")) , _mute_master (new MuteMaster (sess, "toBeReset"))
, _default_type (default_type) , _default_type (default_type)
{ {
@ -142,10 +144,10 @@ Route::init ()
/* add standard controls */ /* add standard controls */
_solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle)); _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 (_solo_control);
add_control (_mute_master); add_control (_mute_control);
/* input and output objects */ /* 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 void
Route::set_block_size (nframes_t nframes) Route::set_block_size (nframes_t nframes)
{ {

View File

@ -96,7 +96,7 @@ Session::pre_export ()
} }
int int
Session::start_audio_export (nframes_t position, bool realtime) Session::start_audio_export (nframes_t position, bool /* realtime */)
{ {
if (!_exporting) { if (!_exporting) {
pre_export (); pre_export ();

View File

@ -704,15 +704,12 @@ GenericMidiControlProtocol::create_binding (const XMLNode& node)
mc->bind_midi (channel, ev, detail); mc->bind_midi (channel, ev, detail);
cerr << "New MC with URI " << uri << " on channel " << (int) channel << " detail = " << (int) detail << endl;
return mc; return mc;
} }
void void
GenericMidiControlProtocol::reset_controllables () GenericMidiControlProtocol::reset_controllables ()
{ {
cerr << "GM::RC\n";
Glib::Mutex::Lock lm2 (controllables_lock); Glib::Mutex::Lock lm2 (controllables_lock);
for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) { for (MIDIControllables::iterator iter = controllables.begin(); iter != controllables.end(); ++iter) {
@ -817,10 +814,8 @@ GenericMidiControlProtocol::create_function (const XMLNode& node)
return 0; return 0;
} }
cerr << "New MF with function = " << prop->value() << " on channel " << (int) channel << " detail = " << (int) detail << endl;
mf->bind_midi (channel, ev, detail); mf->bind_midi (channel, ev, detail);
return mf; return mf;
} }

View File

@ -185,7 +185,7 @@ MIDIControllable::midi_sense_note_off (Parser &p, EventTwoBytes *tb)
} }
void void
MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /* is_on */) MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool is_on)
{ {
if (!controllable) { if (!controllable) {
return; return;
@ -197,10 +197,6 @@ MIDIControllable::midi_sense_note (Parser &, EventTwoBytes *msg, bool /* is_on *
} else { } else {
if (control_additional == msg->note_number) { 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); controllable->set_value (controllable->get_value() > 0.5f ? 0.0f : 1.0f);
} }
} }