From a4b19f67d039c20369c44ca81845cd4b9eda4878 Mon Sep 17 00:00:00 2001
From: Robert Jonsson <spamatica@gmail.com>
Date: Sun, 12 May 2013 17:49:40 +0000
Subject: fixed drum playback in new drum editor

---
 muse2/ChangeLog                 |  3 +++
 muse2/muse/midiedit/dcanvas.cpp | 11 ++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index bff1dfde..c49ae072 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,6 @@
+12.05.2013:
+         - Fixed bug with playback of drums clicking on notes in the new drum editor,
+           it was playing the wrong instrument (rj)
 08.05.2013:
          - Yet another MAJOR audio engine and plugin/synth process chain re-write. (Tim...)
          - Track controllers (vol, pan) now sample-accurate.
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index 734871ef..ebe3a6c8 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -209,7 +209,7 @@ bool DrumCanvas::index2Note(int index, int* port, int* channel, int* note)
         *channel = ch;
       if(note)
         *note = old_style_drummap_mode ? ourDrumMap[index].anote : instrument_map[index].pitch;
-      
+
       return true;
 }
       
@@ -576,6 +576,15 @@ void DrumCanvas::itemPressed(const MusEGui::CItem* item)
       MusECore::Event e = ((DEvent*)item)->event();
       int index = e.pitch();
       // play note:
+
+      if (!old_style_drummap_mode) {
+          for (int i = 0; i < instrument_map.size(); ++i) {
+              if (instrument_map.at(i).pitch == index) {
+                  index = i;
+                  break;
+              }
+          }
+      }
       int pitch, port, channel;
       if(index2Note(index, &port, &channel, &pitch))
         startPlayEvent(pitch, e.velo(), port, channel);
-- 
cgit v1.2.3