MCP: Patch from Rodrigo that:

* implements Metering on/off through Button::Read as per Seablade's suggestion. I choose this button as it's the "Show meters" button in Traktion;
    * removes redundant code from Meter::update_transport_rolling();
    * renames Meter::update_transport_rolling() to Meter::notify_metering_state_changed();
    * renamed Surface::notify_transport_state_changed() to Surface::notify_metering_state_changed();
    * renamed Strip::notify_transport_state_changed() to Strip::notify_metering_state_changed();
    * created MackieControlProtocol::notify_metering_state_changed() and made MackieControlProtocol::notify_transport_state_changed() use it;
    * implemented turning off of timecode display and two char display in Surface::zero_all ();
    * implemented master fader zeroing in Surface::zero_all ();
    * calling Surfaces->zero_all() at MackieControlProtocol destructor;
    * implemented restore of 2nd LCD line content after metering being active.



git-svn-id: svn://localhost/ardour2/branches/3.0@12520 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-06-01 12:56:20 +00:00
parent bc3aea6f93
commit ba5e71b50f
9 changed files with 80 additions and 73 deletions

View file

@ -107,6 +107,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
, _modifier_state (0)
, _ipmidi_base (MIDI::IPMIDIPort::lowest_ipmidi_port_default)
, needs_ipmidi_restart (false)
, _metering_active (true)
{
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");
@ -124,6 +125,10 @@ MackieControlProtocol::~MackieControlProtocol()
{
DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::~MackieControlProtocol\n");
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->zero_all ();
}
drop_connections ();
tear_down_gui ();
@ -881,13 +886,19 @@ MackieControlProtocol::notify_transport_state_changed()
update_global_button (Button::Rewind, session->transport_speed() < 0.0);
update_global_button (Button::Ffwd, session->transport_speed() > 1.0);
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->notify_transport_state_changed ();
}
notify_metering_state_changed ();
_transport_previously_rolling = session->transport_rolling();
}
void
MackieControlProtocol::notify_metering_state_changed()
{
for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
(*s)->notify_metering_state_changed ();
}
}
void
MackieControlProtocol::notify_record_state_changed ()
{

View file

@ -128,6 +128,7 @@ class MackieControlProtocol
bool flip_mode () const { return _flip_mode; }
ViewMode view_mode () const { return _view_mode; }
bool zoom_mode () const { return _zoom_mode; }
bool metering_active () const { return _metering_active; }
void set_view_mode (ViewMode);
void set_flip_mode (bool);
@ -164,6 +165,7 @@ class MackieControlProtocol
void notify_record_state_changed();
void notify_transport_state_changed();
void notify_loop_state_changed();
void notify_metering_state_changed();
// mainly to pick up punch-in and punch-out
void notify_parameter_changed(std::string const &);
void notify_solo_active_changed(bool);
@ -286,6 +288,7 @@ class MackieControlProtocol
ButtonMap button_map;
int16_t _ipmidi_base;
bool needs_ipmidi_restart;
bool _metering_active;
ARDOUR::RouteNotificationList _last_selected_routes;

View file

@ -1009,12 +1009,14 @@ MackieControlProtocol::snapshot_release (Mackie::Button&)
Mackie::LedState
MackieControlProtocol::read_press (Mackie::Button&)
{
return none;
_metering_active = !_metering_active;
notify_metering_state_changed ();
return _metering_active;
}
Mackie::LedState
MackieControlProtocol::read_release (Mackie::Button&)
{
return none;
return _metering_active;
}
Mackie::LedState
MackieControlProtocol::write_press (Mackie::Button&)

View file

@ -22,7 +22,6 @@
#include "pbd/compose.h"
#include "ardour/debug.h"
#include "mackie_control_protocol.h"
#include "meter.h"
#include "surface.h"
#include "surface_port.h"
@ -42,54 +41,26 @@ Meter::factory (Surface& surface, int id, const char* name, Group& group)
}
void
Meter::update_transport_rolling(Surface& surface)
Meter::notify_metering_state_changed(Surface& surface, bool transport_is_rolling, bool metering_active)
{
bool transport_is_rolling = (surface.mcp().get_transport_speed () != 0.0f);
if (_transport_is_rolling == transport_is_rolling) {
return;
}
if (transport_is_rolling) {
MidiByteArray enable_msg;
MidiByteArray msg;
// sysex header
enable_msg << surface.sysex_hdr();
msg << surface.sysex_hdr();
// code for Channel Meter Enable Message
enable_msg << 0x20;
msg << 0x20;
// Channel identification
enable_msg << id();
msg << id();
// Enabling level meter on LCD, peak hold display on horizontal meter and signal LED
enable_msg << 0x07;
// Enable (0x07) / Disable (0x00) level meter on LCD, peak hold display on horizontal meter and signal LED
msg << ((transport_is_rolling && metering_active) ? 0x07 : 0x00);
// sysex trailer
enable_msg << MIDI::eox;
msg << MIDI::eox;
surface.write (enable_msg);
} else {
MidiByteArray disable_msg;
// sysex header
disable_msg << surface.sysex_hdr();
// code for Channel Meter Enable Message
disable_msg << 0x20;
// Channel identification
disable_msg << id();
// Disabling level meter on LCD, peak hold display on horizontal meter and signal LED
disable_msg << 0x00;
// sysex trailer
disable_msg << MIDI::eox;
surface.write (disable_msg);
}
_transport_is_rolling = transport_is_rolling;
surface.write (msg);
}
void
@ -99,10 +70,6 @@ Meter::send_update (Surface& surface, float dB)
// DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Meter ID %1 dB %2\n", id(), dB));
if (!_transport_is_rolling) {
return;
}
if (dB < -70.0f) {
def = 0.0f;
} else if (dB < -60.0f) {

View file

@ -40,11 +40,10 @@ public:
static Control* factory (Surface&, int id, const char*, Group&);
void update_transport_rolling(Surface& surface);
void notify_metering_state_changed(Surface& surface, bool transport_is_rolling, bool metering_active);
private:
bool overload_on;
bool _transport_is_rolling;
};
}

View file

@ -73,6 +73,8 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::
, _index (index)
, _surface (&s)
, _controls_locked (false)
, _transport_is_rolling (false)
, _metering_active (true)
, _reset_display_at (0)
, _last_gain_position_written (-1.0)
, _last_pan_azi_position_written (-1.0)
@ -690,7 +692,7 @@ Strip::update_automation ()
void
Strip::update_meter ()
{
if (_meter) {
if (_meter && _transport_is_rolling && _metering_active) {
float dB = const_cast<PeakMeter&> (_route->peak_meter()).peak_power (0);
_meter->send_update (*_surface, dB);
}
@ -1068,9 +1070,26 @@ Strip::reset_saved_values ()
}
void
Strip::notify_transport_state_changed()
Strip::notify_metering_state_changed()
{
if (_meter) {
_meter->update_transport_rolling (*_surface);
if (!_route || !_meter) {
return;
}
bool transport_is_rolling = (_surface->mcp().get_transport_speed () != 0.0f);
bool metering_active = _surface->mcp().metering_active ();
if ((_transport_is_rolling == transport_is_rolling) && (_metering_active == metering_active)) {
return;
}
_meter->notify_metering_state_changed (*_surface, transport_is_rolling, metering_active);
if (!transport_is_rolling || !metering_active) {
notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name));
notify_panner_azi_changed (true);
}
_transport_is_rolling = transport_is_rolling;
_metering_active = metering_active;
}

View file

@ -84,7 +84,7 @@ public:
void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
void notify_transport_state_changed();
void notify_metering_state_changed();
private:
Button* _solo;
@ -99,6 +99,8 @@ private:
int _index;
Surface* _surface;
bool _controls_locked;
bool _transport_is_rolling;
bool _metering_active;
uint64_t _reset_display_at;
boost::shared_ptr<ARDOUR::Route> _route;
PBD::ScopedConnectionList route_connections;

View file

@ -573,7 +573,17 @@ Surface::nth_strip (uint32_t n) const
void
Surface::zero_all ()
{
// TODO turn off Timecode displays
if (_mcp.device_info().has_timecode_display ()) {
display_timecode (string (10, '0'), string (10, ' '));
}
if (_mcp.device_info().has_two_character_display()) {
show_two_char_display (string (2, ' '), string (2, '.'));
}
if (_mcp.device_info().has_master_fader ()) {
_port->write (_master_fader->zero ());
}
// zero all strips
for (Strips::iterator it = strips.begin(); it != strips.end(); ++it) {
@ -601,12 +611,6 @@ Surface::zero_controls ()
}
}
if (_number == 0 && _mcp.device_info().has_two_character_display()) {
// any hardware-specific stuff
// clear 2-char display
show_two_char_display (" ");
}
// and the led ring for the master strip
blank_jog_ring ();
}
@ -847,9 +851,9 @@ Surface::route_is_locked_to_strip (boost::shared_ptr<Route> r) const
}
void
Surface::notify_transport_state_changed()
Surface::notify_metering_state_changed()
{
for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
(*s)->notify_transport_state_changed ();
(*s)->notify_metering_state_changed ();
}
}

View file

@ -146,7 +146,7 @@ public:
void next_jog_mode ();
void set_jog_mode (Mackie::JogWheel::Mode);
void notify_transport_state_changed();
void notify_metering_state_changed();
protected: