push2: many improvements to track mix and mix layouts
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 25 Sep 2016 23:29:30 +0000 (18:29 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:32 +0000 (14:59 -0500)
Including meters and clocks

libs/surfaces/push2/layout.h
libs/surfaces/push2/mix.cc
libs/surfaces/push2/mix.h
libs/surfaces/push2/push2.cc
libs/surfaces/push2/track_mix.cc
libs/surfaces/push2/track_mix.h

index eb0a467e35d8bb5a9c32ea534e92e115e715ba20..e655a6de8f6e5df2eb867be087b6ead01249542e 100644 (file)
@@ -69,6 +69,7 @@ class Push2Layout : public sigc::trackable, public ArdourCanvas::Container
        virtual void strip_vpot_touch (int, bool) = 0;
 
        virtual void update_meters () {}
+       virtual void update_clocks () {}
 
   protected:
        Push2& p2;
index c61ee45008b3fb1bbae77f74b1bf9b03681be53b..847586f0e5d34d6e4e281ecc53505e8e65ca835c 100644 (file)
@@ -51,8 +51,9 @@
 #include "gtkmm2ext/gui_thread.h"
 
 #include "canvas.h"
-#include "mix.h"
 #include "knob.h"
+#include "level_meter.h"
+#include "mix.h"
 #include "push2.h"
 #include "utils.h"
 
@@ -83,6 +84,7 @@ MixLayout::MixLayout (Push2& p, Session& s)
        upper_line->set_outline_color (p2.get_color (Push2::LightBackground));
 
        Pango::FontDescription fd2 ("Sans 10");
+
        for (int n = 0; n < 8; ++n) {
 
                /* background for text labels for knob function */
@@ -133,11 +135,10 @@ MixLayout::MixLayout (Push2& p, Session& s)
                t->set (txt);
                upper_text.push_back (t);
 
-               /* knobs */
+               /* GainMeters */
 
-               knobs[n] = new Push2Knob (p2, this);
-               knobs[n]->set_position (Duple (60 + (n*Push2Canvas::inter_button_spacing()), 95));
-               knobs[n]->set_radius (25);
+               gain_meter[n] = new GainMeter (this, p2);
+               gain_meter[n]->set_position (Duple (40 + (n * Push2Canvas::inter_button_spacing()), 95));
 
                /* stripable names */
 
@@ -259,95 +260,110 @@ MixLayout::show_vpot_mode ()
        case Volume:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->gain_control());
+                               gain_meter[s]->knob->set_controllable (stripable[s]->gain_control());
+                               boost::shared_ptr<PeakMeter> pm = stripable[s]->peak_meter(); 
+                               if (pm) {
+                                       gain_meter[s]->meter->set_meter (pm.get());
+                               } else {
+                                       gain_meter[s]->meter->set_meter (0);
+                               }
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->meter->set_meter (0);
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->show ();
                }
                n = 0;
                break;
        case PanAzimuth:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->pan_azimuth_control());
-                               knobs[s]->add_flag (Push2Knob::ArcToZero);
+                               gain_meter[s]->knob->set_controllable (stripable[s]->pan_azimuth_control());
+                               gain_meter[s]->knob->add_flag (Push2Knob::ArcToZero);
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
+                       gain_meter[s]->meter->hide ();
                }
                n = 1;
                break;
        case PanWidth:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->pan_width_control());
+                               gain_meter[s]->knob->set_controllable (stripable[s]->pan_width_control());
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 2;
                break;
        case Send1:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->send_level_controllable (0));
+                               gain_meter[s]->knob->set_controllable (stripable[s]->send_level_controllable (0));
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 3;
                break;
        case Send2:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->send_level_controllable (1));
+                               gain_meter[s]->knob->set_controllable (stripable[s]->send_level_controllable (1));
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 4;
                break;
        case Send3:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->send_level_controllable (2));
+                               gain_meter[s]->knob->set_controllable (stripable[s]->send_level_controllable (2));
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 5;
                break;
        case Send4:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->send_level_controllable (3));
+                               gain_meter[s]->knob->set_controllable (stripable[s]->send_level_controllable (3));
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 6;
                break;
        case Send5:
                for (int s = 0; s < 8; ++s) {
                        if (stripable[s]) {
-                               knobs[s]->set_controllable (stripable[s]->send_level_controllable (4));
+                               gain_meter[s]->knob->set_controllable (stripable[s]->send_level_controllable (4));
                        } else {
-                               knobs[s]->set_controllable (boost::shared_ptr<AutomationControl>());
+                               gain_meter[s]->knob->set_controllable (boost::shared_ptr<AutomationControl>());
 
                        }
-                       knobs[s]->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->knob->remove_flag (Push2Knob::ArcToZero);
+                       gain_meter[s]->meter->hide ();
                }
                n = 7;
                break;
@@ -398,7 +414,7 @@ MixLayout::button_lower (uint32_t n)
 void
 MixLayout::strip_vpot (int n, int delta)
 {
-       boost::shared_ptr<Controllable> ac = knobs[n]->controllable();
+       boost::shared_ptr<Controllable> ac = gain_meter[n]->knob->controllable();
 
        if (ac) {
                ac->set_value (ac->interface_to_internal (
@@ -566,9 +582,9 @@ MixLayout::switch_bank (uint32_t base)
 
                        solo_mute_changed (n);
 
-                       knobs[n]->set_text_color (stripable[n]->presentation_info().color());
-                       knobs[n]->set_arc_start_color (stripable[n]->presentation_info().color());
-                       knobs[n]->set_arc_end_color (stripable[n]->presentation_info().color());
+                       gain_meter[n]->knob->set_text_color (stripable[n]->presentation_info().color());
+                       gain_meter[n]->knob->set_arc_start_color (stripable[n]->presentation_info().color());
+                       gain_meter[n]->knob->set_arc_end_color (stripable[n]->presentation_info().color());
                }
 
 
@@ -732,3 +748,26 @@ MixLayout::button_up ()
 {
        p2.scroll_up_1_track ();
 }
+
+void
+MixLayout::update_meters ()
+{
+       if (vpot_mode != Volume) {
+               return;
+       }
+
+       for (uint32_t n = 0; n < 8; ++n) {
+               gain_meter[n]->meter->update_meters ();
+       }
+}
+
+MixLayout::GainMeter::GainMeter (Item* parent, Push2& p2)
+       : Container (parent)
+{
+       knob = new Push2Knob (p2, this);
+       knob->set_radius (25);
+       /* leave position at (0,0) */
+
+       meter = new LevelMeter (p2, this, 90, ArdourCanvas::Meter::Vertical);
+       meter->set_position (Duple (40, -60));
+}
index fdad06bf29ea5a03ca4d046d4bf87c4561ea8721..836709d9295b69966dbad5937d029c1e5869d836 100644 (file)
@@ -35,6 +35,7 @@ namespace ArdourCanvas {
 namespace ArdourSurface {
 
 class Push2Knob;
+class LevelMeter;
 
 class MixLayout : public Push2Layout
 {
@@ -59,6 +60,8 @@ class MixLayout : public Push2Layout
        void strip_vpot (int, int);
        void strip_vpot_touch (int, bool);
 
+       void update_meters ();
+
   private:
        ArdourCanvas::Rectangle* bg;
        ArdourCanvas::Line* upper_line;
@@ -66,7 +69,15 @@ class MixLayout : public Push2Layout
        std::vector<ArdourCanvas::Text*> lower_text;
        std::vector<ArdourCanvas::Rectangle*> upper_backgrounds;
        std::vector<ArdourCanvas::Rectangle*> lower_backgrounds;
-       Push2Knob* knobs[8];
+
+       struct GainMeter : public ArdourCanvas::Container {
+               GainMeter (Item* parent, Push2&);
+
+               Push2Knob* knob;
+               LevelMeter* meter;
+       };
+
+       GainMeter* gain_meter[8];
 
        /* stripables */
 
index 339eadd500f2d361c7872d27a0674f348c21e05c..3fb5b6c372dbc8efbcee7686f5e68d3193082226 100644 (file)
@@ -480,7 +480,10 @@ Push2::vblank ()
                }
        }
 
-       track_mix_layout->update_meters ();
+       if (_current_layout) {
+               _current_layout->update_meters ();
+               _current_layout->update_clocks ();
+       }
 
        _canvas->vblank();
 
index 6bfd3c5f0478d096752b53299e0053bc2f251c56..67602a809aa11618a97325d929a0206fc845d1a4 100644 (file)
@@ -142,8 +142,19 @@ TrackMixLayout::TrackMixLayout (Push2& p, Session& s)
        name_text->set_font_description (fd);
        name_text->set_position (Duple (10 + (4*Push2Canvas::inter_button_spacing()), 2));
 
-       meter = new LevelMeter (p2, this, 200, ArdourCanvas::Meter::Horizontal);
-       meter->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 50));
+       meter = new LevelMeter (p2, this, 300, ArdourCanvas::Meter::Horizontal);
+       meter->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 30));
+
+       Pango::FontDescription fd2 ("Sans 18");
+       bbt_text = new Text (this);
+       bbt_text->set_font_description (fd2);
+       bbt_text->set_color (p2.get_color (Push2::LightBackground));
+       bbt_text->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 60));
+
+       minsec_text = new Text (this);
+       minsec_text->set_font_description (fd2);
+       minsec_text->set_color (p2.get_color (Push2::LightBackground));
+       minsec_text->set_position (Duple (10 + (4 * Push2Canvas::inter_button_spacing()), 90));
 
        ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2);
 }
@@ -158,6 +169,10 @@ TrackMixLayout::~TrackMixLayout ()
 void
 TrackMixLayout::selection_changed ()
 {
+       if (!parent()) {
+               return;
+       }
+
        boost::shared_ptr<Stripable> s = ControlProtocol::first_selected_stripable();
        if (s) {
                set_stripable (s);
@@ -267,17 +282,16 @@ TrackMixLayout::button_right ()
 void
 TrackMixLayout::simple_control_change (boost::shared_ptr<AutomationControl> ac, Push2::ButtonID bid)
 {
-       if (!ac) {
+       if (!ac || !parent()) {
                return;
        }
 
        Push2::Button* b = p2.button_by_id (bid);
 
-       if (!bid) {
+       if (!b) {
                return;
        }
 
-
        if (ac->get_value()) {
                b->set_color (selection_color);
        } else {
@@ -288,23 +302,61 @@ TrackMixLayout::simple_control_change (boost::shared_ptr<AutomationControl> ac,
 }
 
 void
-TrackMixLayout::solo_change ()
+TrackMixLayout::solo_mute_change ()
 {
        if (!stripable) {
                return;
        }
 
-       simple_control_change (stripable->solo_control(), Push2::Lower2);
-}
+       Push2::Button* b = p2.button_by_id (Push2::Lower2);
+
+       if (b) {
+               boost::shared_ptr<SoloControl> sc = stripable->solo_control();
+
+               if (sc) {
+                       if (sc->soloed_by_self_or_masters()) {
+                               b->set_color (selection_color);
+                               b->set_state (Push2::LED::OneShot24th);
+                       } else if (sc->soloed_by_others_upstream() || sc->soloed_by_others_downstream()) {
+                               b->set_color (selection_color);
+                               b->set_state (Push2::LED::Blinking8th);
+                       } else {
+                               b->set_color (Push2::LED::DarkGray);
+                               b->set_state (Push2::LED::OneShot24th);
+                       }
+               } else {
+                       b->set_color (Push2::LED::DarkGray);
+                       b->set_state (Push2::LED::OneShot24th);
+               }
 
-void
-TrackMixLayout::mute_change ()
-{
-       if (!stripable) {
-               return;
+               p2.write (b->state_msg());
+       }
+
+       b = p2.button_by_id (Push2::Lower1);
+
+       if (b) {
+               boost::shared_ptr<MuteControl> mc = stripable->mute_control();
+
+               if (mc) {
+                       if (mc->muted_by_self_or_masters()) {
+                               b->set_color (selection_color);
+                               b->set_state (Push2::LED::OneShot24th);
+                       } else if (mc->muted_by_others_soloing()) {
+                               b->set_color (selection_color);
+                               b->set_state (Push2::LED::Blinking8th);
+                       } else {
+                               b->set_color (Push2::LED::DarkGray);
+                               b->set_state (Push2::LED::OneShot24th);
+                       }
+
+               } else {
+                       b->set_color (Push2::LED::DarkGray);
+                       b->set_state (Push2::LED::OneShot24th);
+               }
+
+               p2.write (b->state_msg());
        }
 
-       simple_control_change (stripable->mute_control(), Push2::Lower1);
 }
 
 void
@@ -396,8 +448,8 @@ TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
                stripable->PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
                stripable->presentation_info().PropertyChanged.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::stripable_property_change, this, _1), &p2);
 
-               stripable->solo_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::solo_change, this), &p2);
-               stripable->mute_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::mute_change, this), &p2);
+               stripable->solo_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::solo_mute_change, this), &p2);
+               stripable->mute_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::solo_mute_change, this), &p2);
                stripable->solo_isolate_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::solo_iso_change, this), &p2);
                stripable->solo_safe_control()->Changed.connect (stripable_connections, invalidator (*this), boost::bind (&TrackMixLayout::solo_safe_change, this), &p2);
 
@@ -422,8 +474,7 @@ TrackMixLayout::set_stripable (boost::shared_ptr<Stripable> s)
 
                name_changed ();
                color_changed ();
-               solo_change ();
-               mute_change ();
+               solo_mute_change ();
                rec_enable_change ();
                solo_iso_change ();
                solo_safe_change ();
@@ -447,7 +498,7 @@ TrackMixLayout::name_changed ()
 {
        if (stripable) {
                /* poor-man's right justification */
-               char buf[96];
+               char buf[92];
                snprintf (buf, sizeof (buf), "%*s", (int) sizeof (buf) - 1, stripable->name().c_str());
                name_text->set (buf);
        }
@@ -515,3 +566,55 @@ TrackMixLayout::update_meters ()
 
        meter->update_meters ();
 }
+
+void
+TrackMixLayout::update_clocks ()
+{
+       framepos_t pos = session.audible_frame();
+       bool negative = false;
+
+       if (pos < 0) {
+               pos = -pos;
+               negative = true;
+       }
+
+       char buf[16];
+       Timecode::BBT_Time BBT = session.tempo_map().bbt_at_frame (pos);
+
+#define BBT_BAR_CHAR "|"
+
+       if (negative) {
+               snprintf (buf, sizeof (buf), "-%03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
+                         BBT.bars, BBT.beats, BBT.ticks);
+       } else {
+               snprintf (buf, sizeof (buf), " %03" PRIu32 BBT_BAR_CHAR "%02" PRIu32 BBT_BAR_CHAR "%04" PRIu32,
+                         BBT.bars, BBT.beats, BBT.ticks);
+       }
+
+       bbt_text->set (buf);
+
+       framecnt_t left;
+       int hrs;
+       int mins;
+       int secs;
+       int millisecs;
+
+       const double frame_rate = session.frame_rate ();
+
+       left = pos;
+       hrs = (int) floor (left / (frame_rate * 60.0f * 60.0f));
+       left -= (framecnt_t) floor (hrs * frame_rate * 60.0f * 60.0f);
+       mins = (int) floor (left / (frame_rate * 60.0f));
+       left -= (framecnt_t) floor (mins * frame_rate * 60.0f);
+       secs = (int) floor (left / (float) frame_rate);
+       left -= (framecnt_t) floor ((double)(secs * frame_rate));
+       millisecs = floor (left * 1000.0 / (float) frame_rate);
+
+       if (negative) {
+               snprintf (buf, sizeof (buf), "-%02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
+       } else {
+               snprintf (buf, sizeof (buf), " %02" PRId32 ":%02" PRId32 ":%02" PRId32 ".%03" PRId32, hrs, mins, secs, millisecs);
+       }
+
+       minsec_text->set (buf);
+}
index 8ba95344b0a296cff40c5e0f6a0c3bee2f130a68..417c394f95d848b05e4641d287ccbf03aa232755 100644 (file)
@@ -61,6 +61,7 @@ class TrackMixLayout : public Push2Layout
        void strip_vpot_touch (int, bool);
 
        void update_meters ();
+       void update_clocks ();
 
    private:
        boost::shared_ptr<ARDOUR::Stripable> stripable;
@@ -71,6 +72,8 @@ class TrackMixLayout : public Push2Layout
        std::vector<ArdourCanvas::Text*> upper_text;
        std::vector<ArdourCanvas::Text*> lower_text;
        ArdourCanvas::Text* name_text;
+       ArdourCanvas::Text* bbt_text;
+       ArdourCanvas::Text* minsec_text;
        uint8_t selection_color;
 
        Push2Knob* knobs[8];
@@ -86,8 +89,7 @@ class TrackMixLayout : public Push2Layout
        void name_changed ();
        void color_changed ();
 
-       void solo_change ();
-       void mute_change ();
+       void solo_mute_change ();
        void rec_enable_change ();
        void solo_iso_change ();
        void solo_safe_change ();