From faaaf5d328429fd2c3f38131f7a874d056761f3f Mon Sep 17 00:00:00 2001 From: Sander Vocke Date: Sun, 28 Jul 2024 09:24:01 +0200 Subject: Openness development --- src/midimapper.h | 42 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 3 deletions(-) (limited to 'src/midimapper.h') diff --git a/src/midimapper.h b/src/midimapper.h index 94781d4..dcca6dd 100644 --- a/src/midimapper.h +++ b/src/midimapper.h @@ -30,11 +30,40 @@ #include #include #include +#include + +#include "instrumentstate.h" + +enum class MapFrom { + Note, + CC, + NoneOrAny +}; + +enum class MapTo { + PlayInstrument, + InstrumentState, + NoneOrAny +}; struct MidimapEntry { - int note_id; + MapFrom from_kind; // What kind of input is mapped from + int from_id; // note or CC number + MapTo to_kind; // What kind of action is mapped to + std::string instrument_name; + + // For mapping to control state changes + InstrumentStateKind maybe_instrument_state_kind; + + MidimapEntry &operator=(const MidimapEntry& other); + MidimapEntry(const MidimapEntry& other); + MidimapEntry(MapFrom from_kind, + int from_id, + MapTo to_kind, + std::string instrument_name, + InstrumentStateKind maybe_instrument_state_kind); }; using midimap_t = std::vector; @@ -43,8 +72,15 @@ using instrmap_t = std::map; class MidiMapper { public: - //! Lookup note in map and returns the corresponding instrument index list. - std::vector lookup(int note_id); + //! Lookup midi map entries matching the given query. + std::vector lookup( + int from_id = -1, // note or cc #. -1 matches all notes/cc's + MapFrom from_kind = MapFrom::NoneOrAny, // NoneOrAny will return both CC and note maps + MapTo to_kind = MapTo::NoneOrAny, // NoneOrAny will return both instrument hits and controls + InstrumentStateKind state_kind = InstrumentStateKind::NoneOrAny // NoneOrAny maps all state control kinds + ); + + int lookup_instrument(std::string name); //! Set new map sets. void swap(instrmap_t& instrmap, midimap_t& midimap); -- cgit v1.2.3