diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-09 00:03:58 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-09 00:03:58 +0000 |
commit | 7ab25511b541190ae2d9b1dc957507effa59cb35 (patch) | |
tree | 3eb5b9367285da290a066b99a1e191843abf5039 /libs | |
parent | 89aed48f92a673f5bd3f5129602fcff9ecbed103 (diff) |
MCP: possible support for metering (really)
git-svn-id: svn://localhost/ardour2/branches/3.0@11843 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/surfaces/mackie/controls.cc | 9 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.cc | 48 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_control_protocol.h | 4 | ||||
-rw-r--r-- | libs/surfaces/mackie/mackie_midi_builder.cc | 36 |
4 files changed, 79 insertions, 18 deletions
diff --git a/libs/surfaces/mackie/controls.cc b/libs/surfaces/mackie/controls.cc index 42bcc3a09b..d3d63efb85 100644 --- a/libs/surfaces/mackie/controls.cc +++ b/libs/surfaces/mackie/controls.cc @@ -184,6 +184,15 @@ Strip::fader_touch() return *_fader_touch; } +Meter& +Strip::meter() +{ + if (_meter == 0) { + throw MackieControlException ("meter is null"); + } + return *_meter; +} + /** @return true if the control is in use, or false otherwise. Buttons are `in use' when they are held down. Faders with touch support are `in use' when they are being touched. diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index e8b5025196..5e8a3b4557 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -44,6 +44,7 @@ #include "ardour/debug.h" #include "ardour/location.h" #include "ardour/midi_ui.h" +#include "ardour/meter.h" #include "ardour/panner.h" #include "ardour/panner_shell.h" #include "ardour/route.h" @@ -393,6 +394,13 @@ MackieControlProtocol::set_active (bool yn) // send current control positions to surface // must come after _active = true otherwise it won't run update_surface(); + + Glib::RefPtr<Glib::TimeoutSource> meter_timeout = Glib::TimeoutSource::create (25); + + meter_connection = meter_timeout->connect (sigc::mem_fun (*this, &MackieControlProtocol::meter_update)); + + meter_timeout->attach (main_loop()->get_context()); + } else { BaseUI::quit (); close(); @@ -409,6 +417,46 @@ MackieControlProtocol::set_active (bool yn) return 0; } +bool +MackieControlProtocol::meter_update () +{ + for (std::vector<RouteSignal*>::iterator r = route_signals.begin(); r != route_signals.end(); ++r) { + float dB; + + dB = const_cast<PeakMeter&> ((*r)->route()->peak_meter()).peak_power (0); + Mackie::Meter& m = (*r)->strip().meter(); + + float def = 0.0f; /* Meter deflection %age */ + + if (dB < -70.0f) { + def = 0.0f; + } else if (dB < -60.0f) { + def = (dB + 70.0f) * 0.25f; + } else if (dB < -50.0f) { + def = (dB + 60.0f) * 0.5f + 2.5f; + } else if (dB < -40.0f) { + def = (dB + 50.0f) * 0.75f + 7.5f; + } else if (dB < -30.0f) { + def = (dB + 40.0f) * 1.5f + 15.0f; + } else if (dB < -20.0f) { + def = (dB + 30.0f) * 2.0f + 30.0f; + } else if (dB < 6.0f) { + def = (dB + 20.0f) * 2.5f + 50.0f; + } else { + def = 115.0f; + } + + /* 115 is the deflection %age that would be + when dB=6.0. this is an arbitrary + endpoint for our scaling. + */ + + (*r)->port().write (builder.build_meter (m, def/115.0)); + } + + return true; // call it again +} + bool MackieControlProtocol::handle_strip_button (SurfacePort & port, Control & control, ButtonState bs, boost::shared_ptr<Route> route) { diff --git a/libs/surfaces/mackie/mackie_control_protocol.h b/libs/surfaces/mackie/mackie_control_protocol.h index 1df583d15b..88e664b8e3 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.h +++ b/libs/surfaces/mackie/mackie_control_protocol.h @@ -316,7 +316,9 @@ class MackieControlProtocol void port_connected_or_disconnected (std::string, std::string, bool); bool control_in_use_timeout (Mackie::SurfacePort*, Mackie::Control *, Mackie::Control *); - + bool meter_update(); + sigc::connection meter_connection; + boost::shared_ptr<Mackie::RouteSignal> master_route_signal; static const char * default_port_name; diff --git a/libs/surfaces/mackie/mackie_midi_builder.cc b/libs/surfaces/mackie/mackie_midi_builder.cc index 59d9740821..b50d50bb01 100644 --- a/libs/surfaces/mackie/mackie_midi_builder.cc +++ b/libs/surfaces/mackie/mackie_midi_builder.cc @@ -112,7 +112,7 @@ MidiByteArray MackieMidiBuilder::build_fader( const Fader & fader, float pos ) MidiByteArray MackieMidiBuilder::build_meter (const Meter & meter, float val) { MIDI::byte segment = lrintf (val*16.0); - + return MidiByteArray (2, 0xD0, (meter.raw_id()<<3) | segment); @@ -142,27 +142,29 @@ MidiByteArray MackieMidiBuilder::zero_strip( SurfacePort & port, const Strip & s MidiByteArray MackieMidiBuilder::zero_control( const Control & control ) { - switch( control.type() ) - { - case Control::type_button: - return build_led( (Button&)control, off ); + switch( control.type() ) { + case Control::type_button: + return build_led( (Button&)control, off ); + + case Control::type_led: + return build_led( (Led&)control, off ); - case Control::type_led: - return build_led( (Led&)control, off ); + case Control::type_fader: + return build_fader( (Fader&)control, 0.0 ); - case Control::type_fader: - return build_fader( (Fader&)control, 0.0 ); + case Control::type_pot: + return build_led_ring( dynamic_cast<const Pot&>( control ), off ); - case Control::type_pot: - return build_led_ring( dynamic_cast<const Pot&>( control ), off ); + case Control::type_led_ring: + return build_led_ring( dynamic_cast<const LedRing&>( control ), off ); - case Control::type_led_ring: - return build_led_ring( dynamic_cast<const LedRing&>( control ), off ); + case Control::type_meter: + return build_meter (dynamic_cast<const Meter&>(control), 0.0); - default: - ostringstream os; - os << "Unknown control type " << control << " in Strip::zero_control"; - throw MackieControlException( os.str() ); + default: + ostringstream os; + os << "Unknown control type " << control << " in Strip::zero_control"; + throw MackieControlException( os.str() ); } } |