diff options
-rw-r--r-- | ardour.rc.in | 1 | ||||
-rw-r--r-- | gtk2_ardour/SConscript | 1 | ||||
-rw-r--r-- | gtk2_ardour/ardour.menus | 1 | ||||
-rw-r--r-- | gtk2_ardour/ardour2_ui_default.conf | 4 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 1 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 6 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_options.cc | 6 | ||||
-rw-r--r-- | gtk2_ardour/canvas_vars.h | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor.h | 8 | ||||
-rw-r--r-- | gtk2_ardour/editor_actions.cc | 4 | ||||
-rw-r--r-- | gtk2_ardour/editor_audiotrack.cc | 67 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.cc | 15 | ||||
-rw-r--r-- | gtk2_ardour/gain_meter.h | 10 | ||||
-rw-r--r-- | gtk2_ardour/ladspa_pluginui.cc | 2 | ||||
-rw-r--r-- | gtk2_ardour/level_meter.cc | 223 | ||||
-rw-r--r-- | gtk2_ardour/level_meter.h | 109 | ||||
-rw-r--r-- | gtk2_ardour/route_time_axis.cc | 68 | ||||
-rw-r--r-- | gtk2_ardour/route_time_axis.h | 11 | ||||
-rw-r--r-- | gtk2_ardour/time_axis_view.cc | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/configuration_vars.h | 1 | ||||
-rw-r--r-- | libs/gtkmm2ext/fastmeter.cc | 96 | ||||
-rw-r--r-- | libs/gtkmm2ext/gtkmm2ext/fastmeter.h | 3 |
22 files changed, 586 insertions, 59 deletions
diff --git a/ardour.rc.in b/ardour.rc.in index 710bc21a21..bbc0f091ec 100644 --- a/ardour.rc.in +++ b/ardour.rc.in @@ -37,6 +37,7 @@ <Option name="destructive-xfade-msecs" value="20"/> <Option name="periodic-safety-backups" value="1"/> <Option name="periodic-safety-backup-interval" value="120"/> + <Option name="show-track-meters" value="1"/> </Config> <extra> <Keyboard edit-button="3" edit-modifier="4" delete-button="3" delete-modifier="1" snap-modifier="32"/> diff --git a/gtk2_ardour/SConscript b/gtk2_ardour/SConscript index 00d15d29f1..388a416143 100644 --- a/gtk2_ardour/SConscript +++ b/gtk2_ardour/SConscript @@ -174,6 +174,7 @@ keyboard.cc keyeditor.cc ladspa_pluginui.cc latency_gui.cc +level_meter.cc location_ui.cc main.cc marker.cc diff --git a/gtk2_ardour/ardour.menus b/gtk2_ardour/ardour.menus index 0c374bbd67..6bcc0d7898 100644 --- a/gtk2_ardour/ardour.menus +++ b/gtk2_ardour/ardour.menus @@ -385,6 +385,7 @@ <menuitem action='GainReduceFastTransport'/> <menuitem action='PrimaryClockDeltaEditCursor'/> <menuitem action='SecondaryClockDeltaEditCursor'/> + <menuitem action='ShowTrackMeters'/> <menuitem action='OnlyCopyImportedFiles'/> <separator/> </menu> diff --git a/gtk2_ardour/ardour2_ui_default.conf b/gtk2_ardour/ardour2_ui_default.conf index 2d2c0fb73c..43c6027563 100644 --- a/gtk2_ardour/ardour2_ui_default.conf +++ b/gtk2_ardour/ardour2_ui_default.conf @@ -83,6 +83,10 @@ <Option name="trim handle" value="1900ff44"/> <Option name="edit point" value="0000ffff"/> <Option name="play head" value="ff0000ff"/> + <Option name="MeterColorBase" value="0000ffff"/> + <Option name="MeterColorMid" value="73f9baff"/> + <Option name="MeterColorTop" value="00fd5dff"/> + <Option name="MeterColorClip" value="ff0000ff"/> <Option name="midi select rect outline" value="5555ffff"/> <Option name="midi select rect fill" value="8888ff88"/> <Option name="midi note outline min" value="22ff22b0"/> diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 74400396af..0cbc9935bf 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -723,6 +723,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI void toggle_RegionEquivalentsOverlap (); void toggle_PrimaryClockDeltaEditCursor (); void toggle_SecondaryClockDeltaEditCursor (); + void toggle_ShowTrackMeters (); void toggle_only_copy_imported_files (); void mtc_port_changed (); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 7f4a0a1e69..38aae959cf 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -418,8 +418,9 @@ ARDOUR_UI::install_actions () ActionManager::register_toggle_action (option_actions, X_("GainReduceFastTransport"), _("-12dB gain reduce ffwd/rewind"), mem_fun (*this, &ARDOUR_UI::toggle_GainReduceFastTransport)); ActionManager::register_toggle_action (option_actions, X_("LatchedRecordEnable"), _("Rec-enable stays engaged at stop"), mem_fun (*this, &ARDOUR_UI::toggle_LatchedRecordEnable)); ActionManager::register_toggle_action (option_actions, X_("RegionEquivalentsOverlap"), _("Region equivalents overlap"), mem_fun (*this, &ARDOUR_UI::toggle_RegionEquivalentsOverlap)); - ActionManager::register_toggle_action (option_actions, X_("PrimaryClockDeltaEditCursor"), _("Primary Clock delta to edit cursor"), mem_fun (*this, &ARDOUR_UI::toggle_PrimaryClockDeltaEditCursor)); - ActionManager::register_toggle_action (option_actions, X_("SecondaryClockDeltaEditCursor"), _("Secondary Clock delta to edit cursor"), mem_fun (*this, &ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor)); + ActionManager::register_toggle_action (option_actions, X_("PrimaryClockDeltaEditCursor"), _("Primary Clock delta to edit point"), mem_fun (*this, &ARDOUR_UI::toggle_PrimaryClockDeltaEditCursor)); + ActionManager::register_toggle_action (option_actions, X_("SecondaryClockDeltaEditCursor"), _("Secondary Clock delta to edit point"), mem_fun (*this, &ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor)); + ActionManager::register_toggle_action (option_actions, X_("ShowTrackMeters"), _("Display Editor Meters"), mem_fun (*this, &ARDOUR_UI::toggle_ShowTrackMeters)); ActionManager::register_toggle_action (option_actions, X_("OnlyCopyImportedFiles"), _("Always copy imported files"), mem_fun (*this, &ARDOUR_UI::toggle_only_copy_imported_files)); RadioAction::Group denormal_group; @@ -464,6 +465,7 @@ ARDOUR_UI::install_actions () act = ActionManager::register_toggle_action (option_actions, X_("DoNotRunPluginsWhileRecording"), _("Do not run plugins while recording"), mem_fun (*this, &ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording)); ActionManager::session_sensitive_actions.push_back (act); + act = ActionManager::register_toggle_action (option_actions, X_("LatchedSolo"), _("Latched solo"), mem_fun (*this, &ARDOUR_UI::toggle_LatchedSolo)); ActionManager::session_sensitive_actions.push_back (act); act = ActionManager::register_toggle_action (option_actions, X_("ShowSoloMutes"), _("Show solo muting"), mem_fun (*this, &ARDOUR_UI::toggle_ShowSoloMutes)); diff --git a/gtk2_ardour/ardour_ui_options.cc b/gtk2_ardour/ardour_ui_options.cc index b63d17266b..56c4ac649f 100644 --- a/gtk2_ardour/ardour_ui_options.cc +++ b/gtk2_ardour/ardour_ui_options.cc @@ -511,6 +511,12 @@ ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor() } void +ARDOUR_UI::toggle_ShowTrackMeters() +{ + ActionManager::toggle_config_state ("options", "ShowTrackMeters", &Configuration::set_show_track_meters, &Configuration::get_show_track_meters); +} + +void ARDOUR_UI::mtc_port_changed () { bool have_mtc; diff --git a/gtk2_ardour/canvas_vars.h b/gtk2_ardour/canvas_vars.h index c0822d8e9c..5c682c5aa1 100644 --- a/gtk2_ardour/canvas_vars.h +++ b/gtk2_ardour/canvas_vars.h @@ -80,6 +80,10 @@ CANVAS_VARIABLE(canvasvar_TrimHandleLocked, "trim handle locked") CANVAS_VARIABLE(canvasvar_TrimHandle, "trim handle") CANVAS_VARIABLE(canvasvar_EditPoint, "edit point") CANVAS_VARIABLE(canvasvar_PlayHead, "play head") +CANVAS_VARIABLE(canvasvar_MeterColorBase, "MeterColorBase") +CANVAS_VARIABLE(canvasvar_MeterColorMid, "MeterColorMid") +CANVAS_VARIABLE(canvasvar_MeterColorTop, "MeterColorTop") +CANVAS_VARIABLE(canvasvar_MeterColorClip, "MeterColorClip") CANVAS_VARIABLE(canvasvar_MidiSelectRectOutline, "midi select rect outline") CANVAS_VARIABLE(canvasvar_MidiSelectRectFill, "midi select rect fill") CANVAS_VARIABLE(canvasvar_MidiNoteOutlineMin, "midi note outline min") diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 2acf76fc6c..bd0f91ad21 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -2035,6 +2035,14 @@ class Editor : public PublicEditor RegionSelection tmp_regions; RegionSelection& get_regions_for_action (); + + sigc::connection fast_screen_update_connection; + gint start_updating (); + gint stop_updating (); + void toggle_meter_updating(); + void fast_update_strips (); + + bool meters_running; }; #endif /* __ardour_editor_h__ */ diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 5a0542f5d1..8b607f5080 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -1208,7 +1208,9 @@ Editor::parameter_changed (const char* parameter_name) } else if (PARAM_IS ("subframes-per-frame")) { update_subframes_per_frame (); update_just_smpte (); - } + } else if (PARAM_IS ("show-track-meters")) { + toggle_meter_updating(); + } #undef PARAM_IS } diff --git a/gtk2_ardour/editor_audiotrack.cc b/gtk2_ardour/editor_audiotrack.cc index 87fa8a06b8..43f63eed79 100644 --- a/gtk2_ardour/editor_audiotrack.cc +++ b/gtk2_ardour/editor_audiotrack.cc @@ -20,9 +20,11 @@ #include <ardour/location.h> #include <ardour/audio_diskstream.h> +#include "ardour_ui.h" #include "editor.h" #include "editing.h" #include "audio_time_axis.h" +#include "route_time_axis.h" #include "audio_region_view.h" #include "selection.h" @@ -91,3 +93,68 @@ Editor::set_show_waveforms_recording (bool yn) } } } + +gint +Editor::start_updating () +{ + RouteTimeAxisView* rtv; + + //cerr << "Editor::start_updating () called" << endl;//DEBUG + if (is_mapped() && session) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) { + rtv->reset_meter (); + } + } + } + + if (!meters_running) { + fast_screen_update_connection = ARDOUR_UI::SuperRapidScreenUpdate.connect (mem_fun(*this, &Editor::fast_update_strips)); + meters_running = true; + } + return 0; +} + +gint +Editor::stop_updating () +{ + RouteTimeAxisView* rtv; + + meters_running = false; + fast_screen_update_connection.disconnect(); + //cerr << "Editor::stop_updating () called" << endl;//DEBUG + if (is_mapped() && session) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) { + rtv->hide_meter (); + } + } + } + + return 0; +} + +void +Editor::toggle_meter_updating() +{ + if (Config->get_show_track_meters()) { + start_updating(); + } else { + stop_updating (); + } +} + +void +Editor::fast_update_strips () +{ + RouteTimeAxisView* rtv; + + if (is_mapped() && session) { + for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) { + if ((rtv = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) { + rtv->fast_update (); + } + } + } +} + diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 9b4823c90c..dae51935ec 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -77,7 +77,8 @@ GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s) // 0.781787 is the value needed for gain to be set to 0. gain_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1), gain_automation_style_button (""), - gain_automation_state_button ("") + gain_automation_state_button (""), + regular_meter_width(5) { if (slider == 0) { @@ -235,7 +236,7 @@ GainMeter::GainMeter (boost::shared_ptr<IO> io, Session& s) } void -GainMeter::set_width (Width w) +GainMeter::set_width (Width w, int len) { switch (w) { case Wide: @@ -247,7 +248,7 @@ GainMeter::set_width (Width w) } _width = w; - setup_meters (); + setup_meters (len); } Glib::RefPtr<Gdk::Pixmap> @@ -432,7 +433,7 @@ GainMeter::hide_all_meters () } void -GainMeter::setup_meters () +GainMeter::setup_meters (int len) { uint32_t nmeters = _io->n_outputs().n_total(); guint16 width; @@ -483,11 +484,11 @@ GainMeter::setup_meters () } for (int32_t n = nmeters-1; nmeters && n >= 0 ; --n) { - if (meters[n].width != width) { + if (meters[n].width != width || meters[n].length != len) { delete meters[n].meter; - meters[n].meter = new FastMeter ((uint32_t) floor (Config->get_meter_hold()), width, FastMeter::Vertical); + meters[n].meter = new FastMeter ((uint32_t) floor (Config->get_meter_hold()), width, FastMeter::Vertical, len); meters[n].width = width; - + meters[n].length = len; meters[n].meter->add_events (Gdk::BUTTON_RELEASE_MASK); meters[n].meter->signal_button_release_event().connect (bind (mem_fun(*this, &GainMeter::meter_button_release), n)); } diff --git a/gtk2_ardour/gain_meter.h b/gtk2_ardour/gain_meter.h index 3839221e73..969757313c 100644 --- a/gtk2_ardour/gain_meter.h +++ b/gtk2_ardour/gain_meter.h @@ -67,8 +67,8 @@ class GainMeter : public Gtk::VBox void effective_gain_display (); - void set_width (Width); - void setup_meters (); + void set_width (Width, int len=0); + void setup_meters (int len=0); int get_gm_width (); @@ -129,17 +129,19 @@ class GainMeter : public Gtk::VBox struct MeterInfo { Gtkmm2ext::FastMeter *meter; - gint16 width; + gint16 width; + int length; bool packed; MeterInfo() { meter = 0; width = 0; + length = 0; packed = false; } }; - static const guint16 regular_meter_width = 5; + guint16 regular_meter_width; static const guint16 thin_meter_width = 2; vector<MeterInfo> meters; float max_peak; diff --git a/gtk2_ardour/ladspa_pluginui.cc b/gtk2_ardour/ladspa_pluginui.cc index ad1f8fbc7e..f4123c7d8c 100644 --- a/gtk2_ardour/ladspa_pluginui.cc +++ b/gtk2_ardour/ladspa_pluginui.cc @@ -517,7 +517,7 @@ LadspaPluginUI::build_control_ui (guint32 port_index, boost::shared_ptr<Automati MeterInfo * info = new MeterInfo(port_index); control_ui->meterinfo = info; - info->meter = new FastMeter (5, 100, FastMeter::Vertical); + info->meter = new FastMeter (5, 5, FastMeter::Vertical); info->min_unbound = desc.min_unbound; info->max_unbound = desc.max_unbound; diff --git a/gtk2_ardour/level_meter.cc b/gtk2_ardour/level_meter.cc new file mode 100644 index 0000000000..f4f8e8952f --- /dev/null +++ b/gtk2_ardour/level_meter.cc @@ -0,0 +1,223 @@ +/* + Copyright (C) 2002 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include <limits.h> + +#include <ardour/io.h> +#include <ardour/route.h> +#include <ardour/route_group.h> +#include <ardour/session.h> +#include <ardour/session_route.h> +#include <ardour/dB.h> + +#include <gtkmm2ext/utils.h> +#include <gtkmm2ext/fastmeter.h> +#include <gtkmm2ext/stop_signal.h> +#include <gtkmm2ext/barcontroller.h> +#include <midi++/manager.h> +#include <pbd/fastlog.h> + +#include "ardour_ui.h" +#include "level_meter.h" +#include "utils.h" +#include "logmeter.h" +#include "gui_thread.h" +#include "keyboard.h" +#include "public_editor.h" + +#include <ardour/session.h> +#include <ardour/route.h> +#include <ardour/meter.h> + +#include "i18n.h" + +using namespace ARDOUR; +using namespace PBD; +using namespace Gtkmm2ext; +using namespace Gtk; +using namespace sigc; +using namespace std; + +//sigc::signal<void> LevelMeter::ResetAllPeakDisplays; +//sigc::signal<void,RouteGroup*> LevelMeter::ResetGroupPeakDisplays; + + +LevelMeter::LevelMeter (boost::shared_ptr<IO> io, Session& s) + : _io (io), + _session (s) + +{ + set_spacing (1); + Config->ParameterChanged.connect (mem_fun (*this, &LevelMeter::parameter_changed)); + UI::instance()->theme_changed.connect (mem_fun(*this, &LevelMeter::on_theme_changed)); + ColorsChanged.connect (mem_fun (*this, &LevelMeter::color_handler)); +} + +void +LevelMeter::on_theme_changed() +{ + style_changed = true; +} + +LevelMeter::~LevelMeter () +{ + for (vector<MeterInfo>::iterator i = meters.begin(); i != meters.end(); i++) { + if ((*i).meter) { + delete (*i).meter; + } + } +} + +void +LevelMeter::update_meters () +{ + vector<MeterInfo>::iterator i; + uint32_t n; + float peak, mpeak; + + for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) { + if ((*i).packed) { + peak = _io->peak_meter().peak_power (n); + (*i).meter->set (log_meter (peak)); + mpeak = _io->peak_meter().max_peak_power(n); + } + } +} + +void +LevelMeter::parameter_changed(const char* parameter_name) +{ +#define PARAM_IS(x) (!strcmp (parameter_name, (x))) + + ENSURE_GUI_THREAD (bind (mem_fun(*this, &LevelMeter::parameter_changed), parameter_name)); + + if (PARAM_IS ("meter-hold")) { + + vector<MeterInfo>::iterator i; + uint32_t n; + + for (n = 0, i = meters.begin(); i != meters.end(); ++i, ++n) { + + (*i).meter->set_hold_count ((uint32_t) floor(Config->get_meter_hold())); + } + } + +#undef PARAM_IS +} + +void +LevelMeter::hide_all_meters () +{ + + for (vector<MeterInfo>::iterator i = meters.begin(); i != meters.end(); ++i) { + if ((*i).packed) { + remove (*((*i).meter)); + (*i).packed = false; + } + } +} + +void +LevelMeter::setup_meters (int len) +{ + uint32_t nmeters = _io->n_outputs().n_total(); + guint16 width; + + hide_all_meters (); + + Route* r; + + if ((r = dynamic_cast<Route*> (_io.get())) != 0) { + + switch (r->meter_point()) { + case MeterInput: + nmeters = r->n_inputs().n_total(); + break; + case MeterPreFader: + nmeters = r->pre_fader_streams().n_total(); + break; + case MeterPostFader: + nmeters = r->n_outputs().n_total(); + break; + } + + } else { + + nmeters = _io->n_outputs().n_total(); + + } + + if (nmeters == 0) { + return; + } + + if (nmeters <= 2) { + width = regular_meter_width; + } else { + width = thin_meter_width; + } + + while (meters.size() < nmeters) { + meters.push_back (MeterInfo()); + } + + + int b = ARDOUR_UI::config()->canvasvar_MeterColorBase.get(); + int m = ARDOUR_UI::config()->canvasvar_MeterColorMid.get(); + int t = ARDOUR_UI::config()->canvasvar_MeterColorTop.get(); + int c = ARDOUR_UI::config()->canvasvar_MeterColorClip.get(); + + //cerr << "LevelMeter::setup_meters() called color_changed = " << color_changed << " colors: " << endl;//DEBUG + + for (int32_t n = nmeters-1; nmeters && n >= 0 ; --n) { + if (meters[n].width != width || meters[n].length != len || color_changed) { + delete meters[n].meter; + meters[n].meter = new FastMeter ((uint32_t) floor (Config->get_meter_hold()), width, FastMeter::Vertical, len, b, m, t, c); + //cerr << "LevelMeter::setup_meters() w:l = " << width << ":" << len << endl;//DEBUG + meters[n].width = width; + meters[n].length = len; + meters[n].meter->add_events (Gdk::BUTTON_RELEASE_MASK); + } + + pack_end (*meters[n].meter, false, false); + meters[n].meter->show_all (); + meters[n].packed = true; + } + show(); + color_changed = false; +} + +void LevelMeter::clear_meters () +{ + for (vector<MeterInfo>::iterator i = meters.begin(); i < meters.end(); i++) { + (*i).meter->clear(); + } +} + +void LevelMeter::hide_meters () +{ + hide_all_meters(); +} + +void +LevelMeter::color_handler () +{ + color_changed = true; +} + diff --git a/gtk2_ardour/level_meter.h b/gtk2_ardour/level_meter.h new file mode 100644 index 0000000000..dfae72a576 --- /dev/null +++ b/gtk2_ardour/level_meter.h @@ -0,0 +1,109 @@ +/* + Copyright (C) 2002 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_gtk_track_meter_h__ +#define __ardour_gtk_track_meter_h__ + +#include <vector> +#include <map> + +#include <gtkmm/box.h> +#include <gtkmm/adjustment.h> +#include <gtkmm/frame.h> +#include <gtkmm/eventbox.h> +#include <gtkmm/button.h> +#include <gtkmm/table.h> +#include <gtkmm/drawingarea.h> + +#include <ardour/types.h> + +#include <gtkmm2ext/click_box.h> +#include <gtkmm2ext/focus_entry.h> +#include <gtkmm2ext/slider_controller.h> + +#include "enums.h" + +namespace ARDOUR { + class IO; + class Session; + class Route; + class RouteGroup; +} +namespace Gtkmm2ext { + class FastMeter; + class BarController; +} +namespace Gtk { + class Menu; +} + +class LevelMeter : public Gtk::HBox +{ + public: + LevelMeter (boost::shared_ptr<ARDOUR::IO>, ARDOUR::Session&); + ~LevelMeter (); + + void update_gain_sensitive (); + + void update_meters (); + void update_meters_falloff (); + void clear_meters (); + void hide_meters (); + void setup_meters (int len=0); + + private: + + //friend class MixerStrip; + boost::shared_ptr<ARDOUR::IO> _io; + ARDOUR::Session& _session; + + Width _width; + + struct MeterInfo { + Gtkmm2ext::FastMeter *meter; + gint16 width; + int length; + bool packed; + + MeterInfo() { + meter = 0; + width = 0; + length = 0; + packed = false; + } + }; + + static const guint16 regular_meter_width = 3; + static const guint16 thin_meter_width = 2; + vector<MeterInfo> meters; + + //Gtk::HBox meter_packer; + + void hide_all_meters (); + + void parameter_changed (const char*); + + void on_theme_changed (); + bool style_changed; + bool color_changed; + void color_handler (); +}; + +#endif /* __ardour_gtk_track_meter_h__ */ + diff --git a/gtk2_ardour/route_time_axis.cc b/gtk2_ardour/route_time_axis.cc index 38e5a4c330..f654a3056c 100644 --- a/gtk2_ardour/route_time_axis.cc +++ b/gtk2_ardour/route_time_axis.cc @@ -93,9 +93,11 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh playlist_button (_("p")), size_button (_("h")), // height automation_button (_("a")), - visual_button (_("v")) - + visual_button (_("v")), + lm (rt, sess) { + lm.set_no_show_all(); + lm.setup_meters(50); _has_state = true; playlist_menu = 0; playlist_action_menu = 0; @@ -145,12 +147,17 @@ RouteTimeAxisView::RouteTimeAxisView (PublicEditor& ed, Session& sess, boost::sh rec_enable_button->signal_button_press_event().connect (mem_fun(*this, &RouteUI::rec_enable_press), false); rec_enable_button->signal_button_release_event().connect (mem_fun(*this, &RouteUI::rec_enable_release)); - controls_table.attach (*rec_enable_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*rec_enable_button, 4, 5, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); ARDOUR_UI::instance()->tooltips().set_tip(*rec_enable_button, _("Record")); } - controls_table.attach (*mute_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); - controls_table.attach (*solo_button, 7, 8, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_hbox.pack_start(lm, false, false); + _route->meter_change.connect (mem_fun(*this, &RouteTimeAxisView::meter_changed)); + _route->input_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed)); + _route->output_changed.connect (mem_fun(*this, &RouteTimeAxisView::io_changed)); + + controls_table.attach (*mute_button, 5, 6, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); + controls_table.attach (*solo_button, 6, 7, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); controls_table.attach (edit_group_button, 6, 7, 1, 2, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND, 0, 0); @@ -731,6 +738,7 @@ RouteTimeAxisView::show_selection (TimeSelection& ts) void RouteTimeAxisView::set_height (TrackHeight h) { + int gmlen = (height_to_pixels (h)) - 5; bool height_changed = (height == 0) || (h != height_style); TimeAxisView::set_height (h); @@ -772,6 +780,7 @@ RouteTimeAxisView::set_height (TrackHeight h) case Large: case Larger: case Normal: + reset_meter(); show_name_entry (); hide_name_label (); @@ -792,6 +801,7 @@ RouteTimeAxisView::set_height (TrackHeight h) break; case Smaller: + reset_meter(); show_name_entry (); hide_name_label (); @@ -812,6 +822,7 @@ RouteTimeAxisView::set_height (TrackHeight h) break; case Small: + hide_meter(); hide_name_entry (); show_name_label (); @@ -2028,3 +2039,50 @@ RouteTimeAxisView::automation_child(ARDOUR::Parameter param) return boost::shared_ptr<AutomationTimeAxisView>(); } +void +RouteTimeAxisView::fast_update () +{ + lm.update_meters (); +} + +void +RouteTimeAxisView::hide_meter () +{ + clear_meter (); + lm.hide_meters (); +} + +void +RouteTimeAxisView::show_meter () +{ + reset_meter (); +} + +void +RouteTimeAxisView::reset_meter () +{ + if (Config->get_show_track_meters()) { + lm.setup_meters (height-5); + } else { + hide_meter (); + } +} + +void +RouteTimeAxisView::clear_meter () +{ + lm.clear_meters (); +} + +void +RouteTimeAxisView::meter_changed (void *src) +{ + ENSURE_GUI_THREAD (bind (mem_fun(*this, &RouteTimeAxisView::meter_changed), src)); + reset_meter(); +} + +void +RouteTimeAxisView::io_changed (IOChange change, void *src) +{ + reset_meter (); +} diff --git a/gtk2_ardour/route_time_axis.h b/gtk2_ardour/route_time_axis.h index 1331831f39..de89d54d94 100644 --- a/gtk2_ardour/route_time_axis.h +++ b/gtk2_ardour/route_time_axis.h @@ -38,6 +38,7 @@ #include "enums.h" #include "time_axis_view.h" #include "canvas.h" +#include "level_meter.h" namespace ARDOUR { class Session; @@ -118,6 +119,14 @@ public: ARDOUR::RouteGroup* edit_group() const; boost::shared_ptr<ARDOUR::Playlist> playlist() const; + void fast_update (); + void hide_meter (); + void show_meter (); + void reset_meter (); + void clear_meter (); + void io_changed (ARDOUR::IOChange, void *); + void meter_changed (void *); + protected: friend class StreamView; @@ -283,6 +292,8 @@ protected: void set_state (const XMLNode&); XMLNode* get_automation_child_xml_node (ARDOUR::Parameter param); + + LevelMeter lm; }; #endif /* __ardour_route_time_axis_h__ */ diff --git a/gtk2_ardour/time_axis_view.cc b/gtk2_ardour/time_axis_view.cc index cf0e39cdbd..4815aff0a0 100644 --- a/gtk2_ardour/time_axis_view.cc +++ b/gtk2_ardour/time_axis_view.cc @@ -74,7 +74,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie height_style(Small), y_position(0), order(0), - controls_table (2, 8) + controls_table (2, 7) { if (need_size_info) { compute_controls_size_info (); @@ -128,7 +128,7 @@ TimeAxisView::TimeAxisView (ARDOUR::Session& sess, PublicEditor& ed, TimeAxisVie controls_table.set_col_spacings (0); controls_table.set_homogeneous (true); - controls_table.attach (name_hbox, 0, 4, 0, 1, Gtk::FILL|Gtk::EXPAND, Gtk::FILL|Gtk::EXPAND); + controls_table.attach (name_hbox, 0, 4, 0, 1, Gtk::SHRINK|Gtk::EXPAND, Gtk::SHRINK|Gtk::EXPAND); controls_table.show_all (); controls_table.set_no_show_all (); diff --git a/libs/ardour/ardour/configuration_vars.h b/libs/ardour/ardour/configuration_vars.h index b592a9f721..edae45a56a 100644 --- a/libs/ardour/ardour/configuration_vars.h +++ b/libs/ardour/ardour/configuration_vars.h @@ -115,6 +115,7 @@ CONFIG_VARIABLE (ShuttleUnits, shuttle_units, "shuttle-units", Percentage) CONFIG_VARIABLE (bool, quieten_at_speed, "quieten-at-speed", true) CONFIG_VARIABLE (bool, primary_clock_delta_edit_cursor, "primary-clock-delta-edit-cursor", false) CONFIG_VARIABLE (bool, secondary_clock_delta_edit_cursor, "secondary-clock-delta-edit-cursor", false) +CONFIG_VARIABLE (bool, show_track_meters, "show-track-meters", true) /* timecode and sync */ diff --git a/libs/gtkmm2ext/fastmeter.cc b/libs/gtkmm2ext/fastmeter.cc index ab1e1472b3..5c76c98e12 100644 --- a/libs/gtkmm2ext/fastmeter.cc +++ b/libs/gtkmm2ext/fastmeter.cc @@ -27,6 +27,8 @@ #include <gtkmm/style.h> #include <string.h> +#define UINT_TO_RGB(u,r,g,b) { (*(r)) = ((u)>>16)&0xff; (*(g)) = ((u)>>8)&0xff; (*(b)) = (u)&0xff; } +#define UINT_TO_RGBA(u,r,g,b,a) { UINT_TO_RGB(((u)>>8),r,g,b); (*(a)) = (u)&0xff; } using namespace Gtk; using namespace Gdk; using namespace Glib; @@ -34,22 +36,30 @@ using namespace Gtkmm2ext; using namespace std; -int FastMeter::min_v_pixbuf_size = 50; +int FastMeter::min_v_pixbuf_size = 10; int FastMeter::max_v_pixbuf_size = 1024; Glib::RefPtr<Gdk::Pixbuf>* FastMeter::v_pixbuf_cache = 0; -int FastMeter::min_h_pixbuf_size = 50; +int FastMeter::min_h_pixbuf_size = 10; int FastMeter::max_h_pixbuf_size = 1024; Glib::RefPtr<Gdk::Pixbuf>* FastMeter::h_pixbuf_cache = 0; +int FastMeter::_clr0 = 0; +int FastMeter::_clr1 = 0; +int FastMeter::_clr2 = 0; +int FastMeter::_clr3 = 0; -FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o) +FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o, int len, int clr0, int clr1, int clr2, int clr3) { orientation = o; hold_cnt = hold; hold_state = 0; current_peak = 0; current_level = 0; + _clr0 = clr0; + _clr1 = clr1; + _clr2 = clr2; + _clr3 = clr3; set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK); @@ -57,9 +67,13 @@ FastMeter::FastMeter (long hold, unsigned long dimen, Orientation o) pixrect.y = 0; if (orientation == Vertical) { - pixbuf = request_vertical_meter(dimen, 250); + if (!len) + len = 250; + pixbuf = request_vertical_meter(dimen, len); } else { - pixbuf = request_horizontal_meter(186, dimen); + if (!len) + len = 186; + pixbuf = request_horizontal_meter(len, dimen); } pixheight = pixbuf->get_height(); @@ -83,70 +97,80 @@ Glib::RefPtr<Gdk::Pixbuf> FastMeter::request_vertical_meter(int width, int heigh height = min_v_pixbuf_size; if (height > max_v_pixbuf_size) height = max_v_pixbuf_size; - - int index = height - 1; - if (v_pixbuf_cache == 0) { - v_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size); - memset(v_pixbuf_cache,0,sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size); - } - Glib::RefPtr<Gdk::Pixbuf> ret = v_pixbuf_cache[index]; - if (ret) - return ret; + //if (v_pixbuf_cache == 0) { + // v_pixbuf_cache = (Glib::RefPtr<Gdk::Pixbuf>*) malloc(sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size); + // memset(v_pixbuf_cache,0,sizeof(Glib::RefPtr<Gdk::Pixbuf>) * max_v_pixbuf_size); + //} + Glib::RefPtr<Gdk::Pixbuf> ret;// = v_pixbuf_cache[index]; + //if (ret) + // return ret; guint8* data; data = (guint8*) malloc(width*height * 3); - - guint8 r,g,b; - r=0; - g=255; - b=0; + guint8 r,g,b,r0,g0,b0,r1,g1,b1,r2,g2,b2,r3,g3,b3,a; + + UINT_TO_RGBA (_clr0, &r0, &g0, &b0, &a); + UINT_TO_RGBA (_clr1, &r1, &g1, &b1, &a); + UINT_TO_RGBA (_clr2, &r2, &g2, &b2, &a); + UINT_TO_RGBA (_clr3, &r3, &g3, &b3, &a); // fake log calculation copied from log_meter.h // actual calculation: // log_meter(0.0f) = // def = (0.0f + 20.0f) * 2.5f + 50f // return def / 115.0f int knee = (int)floor((float)height * 100.0f / 115.0f); - int y; - - for (y = 0; y < knee / 2; y++) { - r = (guint8)floor(255.0 * (float)y/(float)(knee / 2)); - + for (y = 0; y < knee/2; y++) { + + r = (guint8)floor((float)abs(r1 - r0) * (float)y / (float)(knee/2)); + (r0 >= r1) ? r = r0 - r : r += r0; + + g = (guint8)floor((float)abs(g1 - g0) * (float)y / (float)(knee/2)); + (g0 >= g1) ? g = g0 - g : g += g0; + + b = (guint8)floor((float)abs(b1 - b0) * (float)y / (float)(knee/2)); + (b0 >= b1) ? b = b0 - b : b += b0; + for (int x = 0; x < width; x++) { data[ (x+(height-y-1)*width) * 3 + 0 ] = r; data[ (x+(height-y-1)*width) * 3 + 1 ] = g; data[ (x+(height-y-1)*width) * 3 + 2 ] = b; } } - - for (; y < knee; y++) { - g = 255 - (guint8)floor(170.0 * (float)(y - knee/ 2)/(float)(knee / 2)); - + int offset = knee - y; + for (int i=0; i < offset; i++,y++) { + + r = (guint8)floor((float)abs(r2 - r1) * (float)i / (float)offset); + (r1 >= r2) ? r = r1 - r : r += r1; + + g = (guint8)floor((float)abs(g2 - g1) * (float)i / (float)offset); + (g1 >= g2) ? g = g1 - g : g += g1; + + b = (guint8)floor((float)abs(b2 - b1) * (float)i / (float)offset); + (b1 >= b2) ? b = b1 - b : b += b1; + for (int x = 0; x < width; x++) { data[ (x+(height-y-1)*width) * 3 + 0 ] = r; data[ (x+(height-y-1)*width) * 3 + 1 ] = g; data[ (x+(height-y-1)*width) * 3 + 2 ] = b; } } - - r=255; - g=0; - b=0; + y--; for (; y < height; y++) { for (int x = 0; x < width; x++) { - data[ (x+(height-y-1)*width) * 3 + 0 ] = r; - data[ (x+(height-y-1)*width) * 3 + 1 ] = g; - data[ (x+(height-y-1)*width) * 3 + 2 ] = b; + data[ (x+(height-y-1)*width) * 3 + 0 ] = r3; + data[ (x+(height-y-1)*width) * 3 + 1 ] = g3; + data[ (x+(height-y-1)*width) * 3 + 2 ] = b3; } } ret = Pixbuf::create_from_data(data, COLORSPACE_RGB, false, 8, width, height, width * 3); - v_pixbuf_cache[index] = ret; + //v_pixbuf_cache[index] = ret; return ret; } diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index 48bed3d150..38b640788a 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -32,7 +32,7 @@ class FastMeter : public Gtk::DrawingArea { Vertical }; - FastMeter (long hold_cnt, unsigned long width, Orientation); + FastMeter (long hold_cnt, unsigned long width, Orientation, int len=0, int clrb0=0x00ff00, int clr1=0xffff00, int clr2=0xffaa00, int clr3=0xff0000); virtual ~FastMeter (); void set (float level); @@ -55,6 +55,7 @@ class FastMeter : public Gtk::DrawingArea { Glib::RefPtr<Gdk::Pixbuf> pixbuf; gint pixheight; gint pixwidth; + static int _clr0, _clr1, _clr2, _clr3; Orientation orientation; GdkRectangle pixrect; |