summaryrefslogtreecommitdiff
path: root/gtk2_ardour/midi_region_view.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-06-12 16:32:06 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-06-12 16:32:06 +0000
commitd1d08e391059449977e7de1e858851ffd1afadc6 (patch)
tree5bb21a8854d1f2c6f5e3e2467226f9275d7dc07b /gtk2_ardour/midi_region_view.cc
parentd7551a8f087483af2ef1eae4b0d6988585f03e79 (diff)
fix complete screw up in connecting MIDNAM PatchNameList with ChannelNameSets; more tweaks and twirls for patch/program change mgmt
git-svn-id: svn://localhost/ardour2/branches/3.0@12673 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/midi_region_view.cc')
-rw-r--r--gtk2_ardour/midi_region_view.cc23
1 files changed, 12 insertions, 11 deletions
diff --git a/gtk2_ardour/midi_region_view.cc b/gtk2_ardour/midi_region_view.cc
index 9e9e7efe86..94a07e4fdd 100644
--- a/gtk2_ardour/midi_region_view.cc
+++ b/gtk2_ardour/midi_region_view.cc
@@ -1809,8 +1809,14 @@ MidiRegionView::add_canvas_patch_change (MidiModel::PatchChangePtr patch, const
_patch_changes.push_back (patch_change);
}
-void
-MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key)
+MIDI::Name::PatchPrimaryKey
+MidiRegionView::patch_change_to_patch_key (MidiModel::PatchChangePtr p)
+{
+ return MIDI::Name::PatchPrimaryKey (p->program(), p->bank());
+}
+
+void
+MidiRegionView::get_patch_key_at (double time, uint8_t channel, MIDI::Name::PatchPrimaryKey& key)
{
MidiModel::PatchChanges::iterator i = _model->patch_change_lower_bound (time);
while (i != _model->patch_changes().end() && (*i)->channel() != channel) {
@@ -1827,7 +1833,6 @@ MidiRegionView::get_patch_key_at (Evoral::MusicalTime time, uint8_t channel, MID
assert (key.is_sane());
}
-
void
MidiRegionView::change_patch_change (CanvasPatchChange& pc, const MIDI::Name::PatchPrimaryKey& new_patch)
{
@@ -1926,8 +1931,7 @@ void
MidiRegionView::previous_patch (CanvasPatchChange& patch)
{
if (patch.patch()->program() < 127) {
- MIDI::Name::PatchPrimaryKey key;
- get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
+ MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
key.program_number++;
change_patch_change (patch, key);
}
@@ -1937,8 +1941,7 @@ void
MidiRegionView::next_patch (CanvasPatchChange& patch)
{
if (patch.patch()->program() > 0) {
- MIDI::Name::PatchPrimaryKey key;
- get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
+ MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
key.program_number--;
change_patch_change (patch, key);
}
@@ -1948,8 +1951,7 @@ void
MidiRegionView::previous_bank (CanvasPatchChange& patch)
{
if (patch.patch()->program() < 127) {
- MIDI::Name::PatchPrimaryKey key;
- get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
+ MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
if (key.bank_number > 0) {
key.bank_number--;
change_patch_change (patch, key);
@@ -1961,8 +1963,7 @@ void
MidiRegionView::next_bank (CanvasPatchChange& patch)
{
if (patch.patch()->program() > 0) {
- MIDI::Name::PatchPrimaryKey key;
- get_patch_key_at (patch.patch()->time(), patch.patch()->channel(), key);
+ MIDI::Name::PatchPrimaryKey key = patch_change_to_patch_key (patch.patch());
if (key.bank_number < 127) {
key.bank_number++;
change_patch_change (patch, key);