improve sysex data display.

- don't add a new SysEx canvas item every time we zoom or drag.

	- speed up redisplay generally using PatchChange-like method
	  for finding items (find_canvas_sys_ex() in boost::unordered_map).
This commit is contained in:
nick_m 2017-02-02 03:34:21 +11:00
parent 52d3c2216d
commit 3e4eaf3991
4 changed files with 40 additions and 22 deletions

View file

@ -1144,6 +1144,18 @@ MidiRegionView::find_canvas_patch_change (MidiModel::PatchChangePtr p)
return boost::shared_ptr<PatchChange>();
}
boost::shared_ptr<SysEx>
MidiRegionView::find_canvas_sys_ex (MidiModel::SysExPtr s)
{
SysExes::const_iterator f = _sys_exes.find (s);
if (f != _sys_exes.end()) {
return f->second;
}
return 0;
}
void
MidiRegionView::get_events (Events& e, Evoral::Sequence<Evoral::Beats>::NoteOperator op, uint8_t val, int chan_mask)
{
@ -1284,8 +1296,6 @@ MidiRegionView::redisplay_model()
}
}
_sys_exes.clear();
display_sysexes();
display_patch_changes ();
@ -1377,7 +1387,8 @@ MidiRegionView::display_sysexes()
}
for (MidiModel::SysExes::const_iterator i = _model->sysexes().begin(); i != _model->sysexes().end(); ++i) {
Evoral::Beats time = (*i)->time();
MidiModel::SysExPtr sysex_ptr = *i;
Evoral::Beats time = sysex_ptr->time();
if ((*i)->is_spp() || (*i)->is_mtc_quarter() || (*i)->is_mtc_full()) {
if (!display_periodic_messages) {
@ -1401,9 +1412,13 @@ MidiRegionView::display_sysexes()
// CAIROCANVAS: no longer passing *i (the sysex event) to the
// SysEx canvas object!!!
boost::shared_ptr<SysEx> sysex = find_canvas_sys_ex (sysex_ptr);
boost::shared_ptr<SysEx> sysex = boost::shared_ptr<SysEx>(
new SysEx (*this, _note_group, text, height, x, 1.0));
if (!sysex) {
sysex = boost::shared_ptr<SysEx>(
new SysEx (*this, _note_group, text, height, x, 1.0, sysex_ptr));
_sys_exes.insert (make_pair (sysex_ptr, sysex));
}
// Show unless message is beyond the region bounds
if (time - _region->start() >= _region->length() || time < _region->start()) {
@ -1411,8 +1426,6 @@ MidiRegionView::display_sysexes()
} else {
sysex->show();
}
_sys_exes.push_back(sysex);
}
}

View file

@ -412,9 +412,9 @@ private:
uint8_t _current_range_min;
uint8_t _current_range_max;
typedef boost::unordered_map<boost::shared_ptr<NoteType>, NoteBase*> Events;
typedef boost::unordered_map<boost::shared_ptr<NoteType>, NoteBase*> Events;
typedef boost::unordered_map<ARDOUR::MidiModel::PatchChangePtr, boost::shared_ptr<PatchChange> > PatchChanges;
typedef std::vector< boost::shared_ptr<SysEx> > SysExes;
typedef boost::unordered_map<ARDOUR::MidiModel::constSysExPtr, boost::shared_ptr<SysEx> > SysExes;
typedef std::vector<NoteBase*> CopyDragEvents;
ARDOUR::BeatsFramesConverter _region_relative_time_converter;
@ -466,6 +466,7 @@ private:
Events::iterator _optimization_iterator;
boost::shared_ptr<PatchChange> find_canvas_patch_change (ARDOUR::MidiModel::PatchChangePtr p);
boost::shared_ptr<SysEx> find_canvas_sys_ex (ARDOUR::MidiModel::SysExPtr s);
void update_note (NoteBase*, bool update_ghost_regions = true);
void update_sustained (Note *, bool update_ghost_regions = true);

View file

@ -25,12 +25,14 @@
using namespace std;
SysEx::SysEx (
MidiRegionView& region,
ArdourCanvas::Container* parent,
string& text,
double height,
double x,
double y)
MidiRegionView& region,
ArdourCanvas::Container* parent,
string& text,
double height,
double x,
double y,
ARDOUR::MidiModel::SysExPtr sysex)
: _sysex (sysex)
{
_flag = new ArdourCanvas::Flag (
parent,

View file

@ -20,7 +20,7 @@
#ifndef __SYSEX_H__
#define __SYSEX_H__
class MidiRegionView;
#include "midi_region_view.h"
namespace ArdourCanvas {
class Flag;
@ -30,12 +30,13 @@ class SysEx
{
public:
SysEx (
MidiRegionView& region,
ArdourCanvas::Container* parent,
std::string& text,
double height,
double x,
double y);
MidiRegionView& region,
ArdourCanvas::Container* parent,
std::string& text,
double height,
double x,
double y,
ARDOUR::MidiModel::SysExPtr sysex);
~SysEx ();
@ -48,6 +49,7 @@ private:
bool event_handler (GdkEvent* ev);
SysEx(const SysEx& rhs){}
ArdourCanvas::Flag* _flag;
ARDOUR::MidiModel::SysExPtr _sysex;
};
#endif /* __SYSEX_H__ */