From 31dd927c43f72e76ecb61ea02a7832698b7a9496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Nusser?= Date: Sat, 9 Jun 2018 17:37:23 +0200 Subject: Add map to get instrument name from colour. --- plugingui/drumkittab.cc | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'plugingui/drumkittab.cc') diff --git a/plugingui/drumkittab.cc b/plugingui/drumkittab.cc index 91fc801..1dccb52 100644 --- a/plugingui/drumkittab.cc +++ b/plugingui/drumkittab.cc @@ -88,14 +88,14 @@ void DrumkitTab::triggerAudition(int x, int y) { auto map_colour = map_image->getPixel(x, y); - // TODO: convert color to instrument - if (map_colour != Colour(0)) + auto it = colour_to_instrument.find(map_colour); + if (it == colour_to_instrument.end()) { return; } ++settings.audition_counter; - settings.audition_instrument = "Snare"; + settings.audition_instrument = it->second; settings.audition_velocity = current_velocity; } @@ -106,11 +106,18 @@ void DrumkitTab::updateVelocityLabel() velocity_label.setText("Velocity: " + stream.str()); } -// FIXME: this should actually be done somewhere else maybe? void DrumkitTab::loadImageFiles(std::string const& image_file, std::string const& map_file) { drumkit_image = std::make_unique(image_file); map_image = std::make_unique(map_file); + + // TODO: actually use mapping from drumkit file here + colour_to_instrument = { + {Colour(0), "Snare"}, + {Colour(255./255, 15./255, 55./255), "KdrumL"}, + {Colour(154./255, 153./255, 33./255), "HihatClosed"}, + {Colour(248./255, 221./255, 37./255), "Tom4"} + }; } } // GUI:: -- cgit v1.2.3