X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fsurfaces%2Fpush2%2Ftrack_mix.cc;h=5c0b111ef9e5c42de02daf32138ac99f45af51c4;hb=ea8d089e3c1374da1cb693928bce01e5e722d1eb;hp=72f2954d0968752d98b49b8ede5eb5c7df576a28;hpb=7a0e2ceec003e598ca8987315b4d01bc2013511b;p=ardour.git diff --git a/libs/surfaces/push2/track_mix.cc b/libs/surfaces/push2/track_mix.cc index 72f2954d09..5c0b111ef9 100644 --- a/libs/surfaces/push2/track_mix.cc +++ b/libs/surfaces/push2/track_mix.cc @@ -29,8 +29,9 @@ #include "pbd/enumwriter.h" #include "midi++/parser.h" -#include "timecode/time.h" -#include "timecode/bbt_time.h" + +#include "temporal/time.h" +#include "temporal/bbt_time.h" #include "ardour/async_midi_port.h" #include "ardour/audioengine.h" @@ -50,18 +51,25 @@ #include "gtkmm2ext/gui_thread.h" #include "gtkmm2ext/rgb_macros.h" +#include "canvas/box.h" #include "canvas/line.h" +#include "canvas/meter.h" #include "canvas/rectangle.h" #include "canvas/text.h" +#include "canvas/types.h" #include "canvas.h" #include "knob.h" +#include "level_meter.h" #include "menu.h" -#include "meter.h" #include "push2.h" #include "track_mix.h" #include "utils.h" +#ifdef __APPLE__ +#define Rect ArdourCanvas::Rect +#endif + using namespace ARDOUR; using namespace std; using namespace PBD; @@ -69,12 +77,12 @@ using namespace Glib; using namespace ArdourSurface; using namespace ArdourCanvas; -TrackMixLayout::TrackMixLayout (Push2& p, Session& s) - : Push2Layout (p, s) +TrackMixLayout::TrackMixLayout (Push2& p, Session & s, std::string const & name) + : Push2Layout (p, s, name) { Pango::FontDescription fd ("Sans 10"); - bg = new Rectangle (this); + bg = new ArdourCanvas::Rectangle (this); bg->set (Rect (0, 0, display_width(), display_height())); bg->set_fill_color (p2.get_color (Push2::DarkBackground)); @@ -140,10 +148,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 Meter (this, 24, 32, Meter::Horizontal, 200); - 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)); - ControlProtocol::StripableSelectionChanged.connect (selection_connection, invalidator (*this), boost::bind (&TrackMixLayout::selection_changed, this), &p2); + 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)); } TrackMixLayout::~TrackMixLayout () @@ -153,20 +170,9 @@ TrackMixLayout::~TrackMixLayout () } } -void -TrackMixLayout::selection_changed () -{ - boost::shared_ptr s = ControlProtocol::first_selected_stripable(); - if (s) { - set_stripable (s); - } -} - void TrackMixLayout::show () { - selection_changed (); - Push2::ButtonID lower_buttons[] = { Push2::Lower1, Push2::Lower2, Push2::Lower3, Push2::Lower4, Push2::Lower5, Push2::Lower6, Push2::Lower7, Push2::Lower8 }; @@ -177,17 +183,19 @@ TrackMixLayout::show () p2.write (b->state_msg()); } + show_state (); + Container::show (); } void TrackMixLayout::hide () { - set_stripable (boost::shared_ptr()); + } void -TrackMixLayout::render (ArdourCanvas::Rect const & area, Cairo::RefPtr context) const +TrackMixLayout::render (Rect const & area, Cairo::RefPtr context) const { Container::render (area, context); } @@ -208,23 +216,31 @@ TrackMixLayout::button_lower (uint32_t n) switch (n) { case 0: - stripable->mute_control()->set_value (!stripable->mute_control()->get_value(), PBD::Controllable::UseGroup); + if (stripable->mute_control()) { + stripable->mute_control()->set_value (!stripable->mute_control()->get_value(), PBD::Controllable::UseGroup); + } break; case 1: - stripable->solo_control()->set_value (!stripable->solo_control()->get_value(), PBD::Controllable::UseGroup); + if (stripable->solo_control()) { + stripable->solo_control()->set_value (!stripable->solo_control()->get_value(), PBD::Controllable::UseGroup); + } break; case 2: - stripable->rec_enable_control()->set_value (!stripable->rec_enable_control()->get_value(), PBD::Controllable::UseGroup); + if (stripable->rec_enable_control()) { + stripable->rec_enable_control()->set_value (!stripable->rec_enable_control()->get_value(), PBD::Controllable::UseGroup); + } break; case 3: - mc = stripable->monitoring_control()->monitoring_choice(); - switch (mc) { - case MonitorInput: - stripable->monitoring_control()->set_value (MonitorAuto, PBD::Controllable::UseGroup); - break; - default: - stripable->monitoring_control()->set_value (MonitorInput, PBD::Controllable::UseGroup); - break; + if (stripable->monitor_control()) { + mc = stripable->monitoring_control()->monitoring_choice(); + switch (mc) { + case MonitorInput: + stripable->monitoring_control()->set_value (MonitorAuto, PBD::Controllable::UseGroup); + break; + default: + stripable->monitoring_control()->set_value (MonitorInput, PBD::Controllable::UseGroup); + break; + } } break; case 4: @@ -239,10 +255,14 @@ TrackMixLayout::button_lower (uint32_t n) } break; case 5: - stripable->solo_isolate_control()->set_value (!stripable->solo_isolate_control()->get_value(), PBD::Controllable::UseGroup); + if (stripable->solo_isolate_control()) { + stripable->solo_isolate_control()->set_value (!stripable->solo_isolate_control()->get_value(), PBD::Controllable::UseGroup); + } break; case 6: - stripable->solo_safe_control()->set_value (!stripable->solo_safe_control()->get_value(), PBD::Controllable::UseGroup); + if (stripable->solo_safe_control()) { + stripable->solo_safe_control()->set_value (!stripable->solo_safe_control()->get_value(), PBD::Controllable::UseGroup); + } break; case 7: /* nothing here */ @@ -265,17 +285,16 @@ TrackMixLayout::button_right () void TrackMixLayout::simple_control_change (boost::shared_ptr 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 { @@ -286,23 +305,61 @@ TrackMixLayout::simple_control_change (boost::shared_ptr 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 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 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 @@ -380,6 +437,28 @@ TrackMixLayout::monitoring_change () p2.write (b2->state_msg()); } +void +TrackMixLayout::show_state () +{ + if (!parent()) { + return; + } + + if (stripable) { + name_changed (); + color_changed (); + solo_mute_change (); + rec_enable_change (); + solo_iso_change (); + solo_safe_change (); + monitoring_change (); + + meter->set_meter (stripable->peak_meter ().get()); + } else { + meter->set_meter (0); + } +} + void TrackMixLayout::set_stripable (boost::shared_ptr s) { @@ -394,8 +473,8 @@ TrackMixLayout::set_stripable (boost::shared_ptr 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); @@ -417,16 +496,9 @@ TrackMixLayout::set_stripable (boost::shared_ptr s) knobs[5]->set_controllable (boost::shared_ptr()); knobs[6]->set_controllable (boost::shared_ptr()); knobs[7]->set_controllable (boost::shared_ptr()); - - name_changed (); - color_changed (); - solo_change (); - mute_change (); - rec_enable_change (); - solo_iso_change (); - solo_safe_change (); - monitoring_change (); } + + show_state (); } void @@ -440,10 +512,16 @@ void TrackMixLayout::name_changed () { if (stripable) { - /* poor-man's right justification */ - char buf[96]; - snprintf (buf, sizeof (buf), "%*s", (int) sizeof (buf) - 1, stripable->name().c_str()); - name_text->set (buf); + + name_text->set (stripable->name()); + + /* right justify */ + + Duple pos; + pos.y = name_text->position().y; + pos.x = display_width() - 10 - name_text->width(); + + name_text->set_position (pos); } } @@ -454,7 +532,7 @@ TrackMixLayout::color_changed () return; } - Color rgba = stripable->presentation_info().color(); + Gtkmm2ext::Color rgba = stripable->presentation_info().color(); selection_color = p2.get_color_index (rgba); name_text->set_color (rgba); @@ -493,9 +571,9 @@ TrackMixLayout::strip_vpot_touch (int n, bool touching) boost::shared_ptr ac = knobs[n]->controllable(); if (ac) { if (touching) { - ac->start_touch (session.audible_frame()); + ac->start_touch (session.audible_sample()); } else { - ac->stop_touch (true, session.audible_frame()); + ac->stop_touch (session.audible_sample()); } } } @@ -507,12 +585,57 @@ TrackMixLayout::update_meters () return; } - boost::shared_ptr peak_meter = stripable->peak_meter (); + meter->update_meters (); +} - if (!peak_meter) { - return; +void +TrackMixLayout::update_clocks () +{ + samplepos_t pos = session.audible_sample(); + bool negative = false; + + if (pos < 0) { + pos = -pos; + negative = true; + } + + char buf[16]; + Timecode::BBT_Time BBT = session.tempo_map().bbt_at_sample (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); + + samplecnt_t left; + int hrs; + int mins; + int secs; + int millisecs; + + const double sample_rate = session.sample_rate (); + + left = pos; + hrs = (int) floor (left / (sample_rate * 60.0f * 60.0f)); + left -= (samplecnt_t) floor (hrs * sample_rate * 60.0f * 60.0f); + mins = (int) floor (left / (sample_rate * 60.0f)); + left -= (samplecnt_t) floor (mins * sample_rate * 60.0f); + secs = (int) floor (left / (float) sample_rate); + left -= (samplecnt_t) floor ((double)(secs * sample_rate)); + millisecs = floor (left * 1000.0 / (float) sample_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); } - const float mpeak = peak_meter->meter_level (0, MeterPeak); - meter->set (DSP::log_meter (mpeak)); + minsec_text->set (buf); }