MCP: possible support for metering (really)
git-svn-id: svn://localhost/ardour2/branches/3.0@11843 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 );
|
||||
|
||||
default:
|
||||
ostringstream os;
|
||||
os << "Unknown control type " << control << " in Strip::zero_control";
|
||||
throw MackieControlException( os.str() );
|
||||
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() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user