MCP: start up event loop (thread) so that we can do timeouts and metering; start...
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Apr 2012 23:14:36 +0000 (23:14 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 8 Apr 2012 23:14:36 +0000 (23:14 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11840 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/controls.cc
libs/surfaces/mackie/controls.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_midi_builder.cc
libs/surfaces/mackie/mackie_midi_builder.h
libs/surfaces/mackie/surface.cc
libs/surfaces/mackie/surface.h

index f37bf8e92d0bd7e01cf6c80d6371fbc9d752590f..f59f57b8e03b1779437d2ad8ff5f15e52d85e94b 100644 (file)
@@ -293,3 +293,13 @@ Jog::factory (Surface& surface, int id, int ordinal, const char* name, Group& gr
        group.add (*j);
        return j;
 }
+
+Control*
+Meter::factory (Surface& surface, int id, int ordinal, const char* name, Group& group)
+{
+       Meter* m = new Meter (id, ordinal, name, group);
+       surface.meters[id] = m;
+       surface.controls.push_back (m);
+       group.add (*m);
+       return m;
+}
index c3b307effc5f8411c31950ee51599dba7b2dc081..7f756ae2fd3f7b7bd442a5c171e6aa3b9d31a984 100644 (file)
@@ -150,7 +150,8 @@ public:
                type_led_ring, 
                type_fader = 0xe0, 
                type_button = 0x90, 
-               type_pot = 0xb0 
+               type_pot = 0xb0,
+               type_meter = 0xd0
        };
 
        enum base_id_t {
@@ -163,6 +164,7 @@ public:
                mute_button_base_id = 0x10,
                solo_button_base_id = 0x08,
                recenable_button_base_id = 0x0,
+               meter_base_id = 0xd0,
        };
        
        Control (int id, int ordinal, std::string name, Group& group);
@@ -300,6 +302,17 @@ public:
        static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
 };
 
+class Meter : public Control
+{
+public:
+       Meter (int id, int ordinal, std::string name, Group & group)
+               : Control  (id, ordinal, name, group) {}
+       
+       virtual type_t type() const { return type_meter; }
+
+       static Control* factory (Surface&, int id, int ordinal, const char*, Group&);
+};
+
 }
 
 #endif /* __mackie_controls_h__ */
index 0065be4d12ddfa0f35200492d3e650e71a4ecd53..e8b5025196a57d5785029f5fe97c0ad0c3dc65ac 100644 (file)
@@ -351,13 +351,17 @@ MackieControlProtocol::set_active (bool yn)
        if (yn == _active) {
                return 0;
        }
-       
+
        try
        {
                // the reason for the locking and unlocking is that
                // glibmm can't do a condition wait on a RecMutex
                if (yn) {
                        // TODO what happens if this fails half way?
+
+                       // start an event loop
+
+                       BaseUI::run ();
                        
                        // create MackiePorts
                        {
@@ -390,6 +394,7 @@ MackieControlProtocol::set_active (bool yn)
                        // must come after _active = true otherwise it won't run
                        update_surface();
                } else {
+                       BaseUI::quit ();
                        close();
                        _active = false;
                }
@@ -1039,7 +1044,7 @@ MackieControlProtocol::format_bbt_timecode (framepos_t now_frame)
        os << setw(2) << setfill('0') << bbt_time.beats;
 
        // figure out subdivisions per beat
-       const Meter & meter = session->tempo_map().meter_at (now_frame);
+       const ARDOUR::Meter & meter = session->tempo_map().meter_at (now_frame);
        int subdiv = 2;
        if (meter.note_divisor() == 8 && (meter.divisions_per_bar() == 12.0 || meter.divisions_per_bar() == 9.0 || meter.divisions_per_bar() == 6.0)) {
                subdiv = 3;
index 7cafbd2ebb43a54f16d67ef768455fca70bebafe..59d97408216c0fd1b562532113a9ae94865dc491 100644 (file)
@@ -21,6 +21,7 @@
 #include <sstream>
 #include <iomanip>
 #include <algorithm>
+#include <cmath>
 
 #include "pbd/compose.h"
 
@@ -108,6 +109,15 @@ 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);
+}
+
 MidiByteArray MackieMidiBuilder::zero_strip( SurfacePort & port, const Strip & strip )
 {
        Group::Controls::const_iterator it = strip.controls().begin();
index b5fc9f73c95b7feada8b7b936be7fd5f00282261..4f408e14a863665a609d2a6be0bdc7402a1cd62f 100644 (file)
@@ -62,6 +62,8 @@ public:
        MidiByteArray build_led( const Button & button, LedState ls );
        
        MidiByteArray build_fader( const Fader & fader, float pos );
+
+       MidiByteArray build_meter (const Meter& meter, float val);
        
        /// return bytes that will reset all controls to their zero positions
        /// And blank the display for the strip. Pass SurfacePort so we know which sysex header to use.
index 7322050d6a61716241b9efac74db24edc712508b..8493ac926bd9d075c61ea55fb7a3ed8170b3a7c2 100644 (file)
@@ -155,6 +155,7 @@ static StripControlDefinition mackie_strip_controls[] = {
        { "select", Control::select_button_base_id, Button::factory, },
        { "vselect", Control::vselect_button_base_id, Button::factory, },
        { "fader_touch", Control::fader_touch_button_base_id, Button::factory, },
+       { "meter", 0, Meter::factory, },
        { "", 0, Button::factory, }
 };
 
index 67da8fa33a8f5c4ac67dd89be4b68c03bf1227ff..ab5e0edf90a070a797458bd676946714594bde0c 100644 (file)
@@ -63,6 +63,7 @@ public:
        std::map<int,Pot*> pots;
        std::map<int,Button*> buttons;
        std::map<int,Led*> leds;
+       std::map<int,Meter*> meters;
 
        /// no strip controls in here because they usually
        /// have the same names.