if Mackie device profile name is empty, use a default name that makes sense and that...
[ardour.git] / libs / surfaces / mackie / meter.cc
index 82aef2bef8d3f611a24976bdfe55dbbc1f99aece..27171aff16da500f873e0fea9457bf8a2a269281 100644 (file)
@@ -27,8 +27,9 @@
 #include "surface_port.h"
 #include "control_group.h"
 
-using namespace Mackie;
 using namespace PBD;
+using namespace ArdourSurface;
+using namespace Mackie;
 
 Control*
 Meter::factory (Surface& surface, int id, const char* name, Group& group)
@@ -40,13 +41,36 @@ Meter::factory (Surface& surface, int id, const char* name, Group& group)
        return m;
 }
 
+void
+Meter::notify_metering_state_changed(Surface& surface, bool transport_is_rolling, bool metering_active)
+{
+       MidiByteArray msg;
+
+       // sysex header
+       msg << surface.sysex_hdr();
+
+       // code for Channel Meter Enable Message
+       msg << 0x20;
+
+       // Channel identification
+       msg << id();
+
+       // 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
+       msg << MIDI::eox;
+
+       surface.write (msg);
+}
+
 void
 Meter::send_update (Surface& surface, float dB)
 {
        float def = 0.0f; /* Meter deflection %age */
 
        // DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Meter ID %1 dB %2\n", id(), dB));
-       
+
        if (dB < -70.0f) {
                def = 0.0f;
        } else if (dB < -60.0f) {
@@ -64,19 +88,19 @@ Meter::send_update (Surface& surface, float dB)
        } else {
                def = 115.0f;
        }
-       
+
        /* 115 is the deflection %age that would be
           when dB=6.0. this is an arbitrary
           endpoint for our scaling.
        */
 
        MidiByteArray msg;
-       
+
        if (def > 100.0f) {
                if (!overload_on) {
                        overload_on = true;
                        surface.write (MidiByteArray (2, 0xd0, (id() << 4) | 0xe));
-                       
+
                }
        } else {
                if (overload_on) {
@@ -84,15 +108,12 @@ Meter::send_update (Surface& surface, float dB)
                        surface.write (MidiByteArray (2, 0xd0, (id() << 4) | 0xf));
                }
        }
-       
+
        /* we can use up to 13 segments */
 
        int segment = lrintf ((def/115.0) * 13.0);
-       
-       if (last_segment_value_sent != segment) {
-               last_segment_value_sent = segment;
-               surface.write (MidiByteArray (2, 0xD0, (id()<<4) | segment));
-       }
+
+       surface.write (MidiByteArray (2, 0xd0, (id()<<4) | segment));
 }
 
 MidiByteArray