From d537434b6b85b342cd9fcabfc49ca626de049d12 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 2 Dec 2011 19:35:18 +0000 Subject: [PATCH] use new parameter that controls display of MTC and MIDI clock, as well as attempt to do the first step of something vaguely smart with showing them only a very-zoomed-in levels even if requested git-svn-id: svn://localhost/ardour2/branches/3.0@10865 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/midi_region_view.cc | 55 +++++++++++++++++++++++++++++++-- gtk2_ardour/rc_option_editor.cc | 8 +++++ 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc index 00bdb94dce..c852e656a9 100644 --- a/gtk2_ardour/midi_region_view.cc +++ b/gtk2_ardour/midi_region_view.cc @@ -41,6 +41,7 @@ #include "evoral/Parameter.hpp" #include "evoral/MIDIParameters.hpp" +#include "evoral/MIDIEvent.hpp" #include "evoral/Control.hpp" #include "evoral/midi_util.h" @@ -1232,9 +1233,58 @@ MidiRegionView::display_patch_changes_on_channel (uint8_t channel) void MidiRegionView::display_sysexes() { + bool have_periodic_system_messages = false; + bool display_periodic_messages = true; + + if (!Config->get_never_display_periodic_midi()) { + + for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { + const boost::shared_ptr > mev = + boost::dynamic_pointer_cast > (*i); + + if (mev) { + if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { + have_periodic_system_messages = true; + break; + } + } + } + + if (have_periodic_system_messages) { + double zoom = trackview.editor().get_current_zoom (); // frames per pixel + + /* get an approximate value for the number of samples per video frame */ + + double video_frame = trackview.session()->frame_rate() * (1.0/30); + + /* if we are zoomed out beyond than the cutoff (i.e. more + * frames per pixel than frames per 4 video frames), don't + * show periodic sysex messages. + */ + + if (zoom > (video_frame*4)) { + display_periodic_messages = false; + } + } + } else { + display_periodic_messages = false; + } + for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) { + + const boost::shared_ptr > mev = + boost::dynamic_pointer_cast > (*i); + Evoral::MusicalTime time = (*i)->time(); - assert(time >= 0); + assert (time >= 0); + + if (mev) { + if (mev->is_spp() || mev->is_mtc_quarter() || mev->is_mtc_full()) { + if (!display_periodic_messages) { + continue; + } + } + } ostringstream str; str << hex; @@ -1253,7 +1303,7 @@ MidiRegionView::display_sysexes() boost::shared_ptr sysex = boost::shared_ptr( new CanvasSysEx(*this, *_note_group, text, height, x, 1.0)); - // Show unless patch change is beyond the region bounds + // Show unless message is beyond the region bounds if (time - _region->start() >= _region->length() || time < _region->start()) { sysex->hide(); } else { @@ -1264,7 +1314,6 @@ MidiRegionView::display_sysexes() } } - MidiRegionView::~MidiRegionView () { in_destructor = true; diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 97254a05f3..6aea36168f 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -1480,6 +1480,14 @@ RCOptionEditor::RCOptionEditor () sigc::mem_fun (*_rc_config, &RCConfiguration::set_first_midi_bank_is_zero) )); + add_option (_("MIDI"), + new BoolOption ( + "never-display-periodic-midi", + _("Never display periodic MIDI messages (MTC, MIDI Clock)"), + sigc::mem_fun (*_rc_config, &RCConfiguration::get_never_display_periodic_midi), + sigc::mem_fun (*_rc_config, &RCConfiguration::set_never_display_periodic_midi) + )); + /* USER INTERACTION */ add_option (_("User interaction"), new OptionEditorHeading (_("Keyboard")));