summaryrefslogtreecommitdiff
path: root/src/midimapper.cc
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-08-08 22:19:46 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2011-08-08 22:19:46 +0200
commit2289074fe008a0d1a8d05f44a12a405351aad506 (patch)
treef79089a47b6c7269a5d60b5d5b7608fef05135d6 /src/midimapper.cc
parent08a41cf525193e90ce8f397476ac3825e5e9fdb8 (diff)
New midimapper.
Diffstat (limited to 'src/midimapper.cc')
-rw-r--r--src/midimapper.cc74
1 files changed, 5 insertions, 69 deletions
diff --git a/src/midimapper.cc b/src/midimapper.cc
index 243c22e..ca0cc21 100644
--- a/src/midimapper.cc
+++ b/src/midimapper.cc
@@ -26,74 +26,10 @@
*/
#include "midimapper.h"
-#include <stdio.h>
-
-#define NOTE_ON 0x9
-
-MidiMapper::MidiMapper(DrumKit *drumkit)
-{
- this->drumkit = drumkit;
- /*
-35 Acoustic Bass Drum 59 Ride Cymbal 2
-36 Bass Drum 1 60 Hi Bongo
-37 Side Stick 61 Low Bongo
-38 Acoustic Snare 62 Mute Hi Conga
-39 Hand Clap 63 Open Hi Conga
-40 Electric Snare 64 Low Conga
-41 Low Floor Tom 65 High Timbale
-42 Closed Hi-Hat 66 Low Timbale
-43 High Floor Tom 67 High Agogo
-44 Pedal Hi-Hat 68 Low Agogo
-45 Low Tom 69 Cabasa
-46 Open Hi-Hat 70 Maracas
-47 Low-Mid Tom 71 Short Whistle
-48 Hi-Mid Tom 72 Long Whistle
-49 Crash Cymbal 1 73 Short Guiro
-50 High Tom 74 Long Guiro
-51 Ride Cymbal 1 75 Claves
-52 Chinese Cymbal 76 Hi Wood Block
-53 Ride Bell 77 Low Wood Block
-54 Tambourine 78 Mute Cuica
-55 Splash Cymbal 79 Open Cuica
-56 Cowbell 80 Mute Triangle
-57 Crash Cymbal 2 81 Open Triangle
-58 Vibraslap
- */
-}
-
-//http://ccrma-www.stanford.edu/~craig/articles/linuxmidi/misc/essenmidi.html
-Sample *MidiMapper::map(jack_midi_event_t event)
+int MidiMapper::lookup(int note)
{
- Sample *sample = NULL;
-#if 0
- // printf("m"); fflush(stdout);
-
- if(event.size != 3) return NULL;
- if((event.buffer[0] & NOTE_ON) != NOTE_ON) return NULL;
-
- int key = event.buffer[1];
- int velocity = event.buffer[2];
-
- if(velocity == 0) return NULL;
- /*
- // Parse midi event
- printf("[ Time: %d Size: %d ", event.time, event.size);
- for(size_t j = 0; j < event.size; j++) {
- jack_midi_data_t m = event.buffer[j];
- printf(" Data: %d ", m);
- }
- printf("]\n");
- */
-
- if(drumkit->instruments.find(key) == drumkit->instruments.end()) {
- printf("Unknown instrument %d\n", key);
- return NULL;
- }
-
- Velocity *v = drumkit->instruments[key]->getVelocity(velocity);
-
- if(!v) return NULL;
- sample = v->getSample();
-#endif
- return sample;
+ if(midimap.find(note) == midimap.end()) return -1;
+ std::string instr = midimap[note];
+ if(instrmap.find(instr) == instrmap.end()) return -1;
+ return instrmap[instr];
}