hydrogen 1.2.6
MidiMap Class Reference

The MidiMap maps MidiActions to MidiEvents. More...

#include <MidiMap.h>

Inheritance diagram for MidiMap:
Object< MidiMap > Base

Public Member Functions

 ~MidiMap ()
 
std::vector< int > findCCValuesByActionParam1 (QString sActionType, QString sParam1)
 
std::vector< int > findCCValuesByActionType (QString sActionType)
 
std::multimap< int, std::shared_ptr< Action > > getCCActionMap () const
 
std::vector< std::shared_ptr< Action > > getCCActions (int nParameter)
 Returns the cc action which was linked to the given event.
 
std::multimap< QString, std::shared_ptr< Action > > getMMCActionMap () const
 
std::vector< std::shared_ptr< Action > > getMMCActions (QString sEventString)
 Returns all MMC actions which are linked to the given event.
 
std::multimap< int, std::shared_ptr< Action > > getNoteActionMap () const
 
std::vector< std::shared_ptr< Action > > getNoteActions (int nNote)
 Returns all note actions which are linked to the given event.
 
std::vector< std::shared_ptr< Action > > getPCActions () const
 Returns the pc action which was linked to the given event.
 
std::vector< std::pair< H2Core::MidiMessage::Event, int > > getRegisteredMidiEvents (std::shared_ptr< Action > pAction) const
 
void registerCCEvent (int, std::shared_ptr< Action >)
 Sets up the relation between a cc event and an action.
 
void registerMMCEvent (QString, std::shared_ptr< Action >)
 Sets up the relation between a mmc event and an action.
 
void registerNoteEvent (int, std::shared_ptr< Action >)
 Sets up the relation between a note event and an action.
 
void registerPCEvent (std::shared_ptr< Action >)
 Sets up the relation between a program change and an action.
 
void reset ()
 Reinitializes the object.
 
QString toQString (const QString &sPrefix="", bool bShort=true) const override
 Formatted string version for debugging purposes.
 
- Public Member Functions inherited from Object< MidiMap >
 Object ()
 
 Object (const Object< MidiMap > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void logBacktrace () const
 Print the current stack at point into the debug log.
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 

Static Public Member Functions

static void create_instance ()
 If __instance equals 0, a new MidiMap singleton will be created and stored in it.
 
static MidiMapget_instance ()
 Returns a pointer to the current MidiMap singleton stored in __instance.
 
static void reset_instance ()
 Convenience function calling reset() on the current MidiMap __instance.
 
- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 

Static Public Attributes

static MidiMap__instance = nullptr
 Object holding the current MidiMap singleton.
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 

Private Member Functions

 MidiMap ()
 

Private Attributes

QMutex __mutex
 
std::multimap< int, std::shared_ptr< Action > > m_ccActionMap
 
std::multimap< QString, std::shared_ptr< Action > > m_mmcActionMap
 
std::multimap< int, std::shared_ptr< Action > > m_noteActionMap
 
std::vector< std::shared_ptr< Action > > m_pcActionVector
 

Additional Inherited Members

- Protected Member Functions inherited from Object< MidiMap >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 
static bool bLogColors = true
 

Detailed Description

The MidiMap maps MidiActions to MidiEvents.

The MidiMap stores the mapping between midi events and midi actions. Each event relates to at most 1 midi action. Several events can relate to the same action. Midi events are note, mmc or cc messages.

Author
Sebastian Moors

Definition at line 37 of file MidiMap.h.

Constructor & Destructor Documentation

◆ ~MidiMap()

~MidiMap ( )

Definition at line 57 of file MidiMap.cpp.

◆ MidiMap()

MidiMap ( )
private

Definition at line 46 of file MidiMap.cpp.

Member Function Documentation

◆ create_instance()

void create_instance ( )
static

If __instance equals 0, a new MidiMap singleton will be created and stored in it.

It is called in Hydrogen::create_instance().

Definition at line 64 of file MidiMap.cpp.

◆ findCCValuesByActionParam1()

std::vector< int > findCCValuesByActionParam1 ( QString sActionType,
QString sParam1 )

Definition at line 262 of file MidiMap.cpp.

◆ findCCValuesByActionType()

std::vector< int > findCCValuesByActionType ( QString sActionType)

Definition at line 276 of file MidiMap.cpp.

◆ get_instance()

static MidiMap * get_instance ( )
inlinestatic

Returns a pointer to the current MidiMap singleton stored in __instance.

Definition at line 65 of file MidiMap.h.

◆ getCCActionMap()

std::multimap< int, std::shared_ptr< Action > > getCCActionMap ( ) const
inline

Definition at line 128 of file MidiMap.h.

◆ getCCActions()

std::vector< std::shared_ptr< Action > > getCCActions ( int nParameter)

Returns the cc action which was linked to the given event.

Definition at line 246 of file MidiMap.cpp.

◆ getMMCActionMap()

std::multimap< QString, std::shared_ptr< Action > > getMMCActionMap ( ) const
inline

Definition at line 122 of file MidiMap.h.

◆ getMMCActions()

std::vector< std::shared_ptr< Action > > getMMCActions ( QString sEventString)

Returns all MMC actions which are linked to the given event.

Definition at line 212 of file MidiMap.cpp.

◆ getNoteActionMap()

std::multimap< int, std::shared_ptr< Action > > getNoteActionMap ( ) const
inline

Definition at line 125 of file MidiMap.h.

◆ getNoteActions()

std::vector< std::shared_ptr< Action > > getNoteActions ( int nNote)

Returns all note actions which are linked to the given event.

Definition at line 229 of file MidiMap.cpp.

◆ getPCActions()

std::vector< std::shared_ptr< Action > > getPCActions ( ) const
inline

Returns the pc action which was linked to the given event.

Definition at line 131 of file MidiMap.h.

◆ getRegisteredMidiEvents()

std::vector< std::pair< H2Core::MidiMessage::Event, int > > getRegisteredMidiEvents ( std::shared_ptr< Action > pAction) const
Returns
a list of all MIDI events registered to a particular pAction grouped in MIDI event type name and MIDI event parameter pairs.

Definition at line 289 of file MidiMap.cpp.

◆ registerCCEvent()

void registerCCEvent ( int nParameter,
std::shared_ptr< Action > pAction )

Sets up the relation between a cc event and an action.

Definition at line 161 of file MidiMap.cpp.

◆ registerMMCEvent()

void registerMMCEvent ( QString sEventString,
std::shared_ptr< Action > pAction )

Sets up the relation between a mmc event and an action.

Definition at line 96 of file MidiMap.cpp.

◆ registerNoteEvent()

void registerNoteEvent ( int nNote,
std::shared_ptr< Action > pAction )

Sets up the relation between a note event and an action.

Definition at line 130 of file MidiMap.cpp.

◆ registerPCEvent()

void registerPCEvent ( std::shared_ptr< Action > pAction)

Sets up the relation between a program change and an action.

Definition at line 190 of file MidiMap.cpp.

◆ reset()

void reset ( )

Reinitializes the object.

Clears the complete midi map and releases the memory of the contained actions.

Definition at line 82 of file MidiMap.cpp.

◆ reset_instance()

void reset_instance ( )
static

Convenience function calling reset() on the current MidiMap __instance.

Definition at line 71 of file MidiMap.cpp.

◆ toQString()

QString toQString ( const QString & sPrefix = "",
bool bShort = true ) const
overridevirtual

Formatted string version for debugging purposes.

Parameters
sPrefixString prefix which will be added in front of every new line
bShortInstead of the whole content of all classes stored as members just a single unique identifier will be displayed without line breaks.
Returns
String presentation of current object.

Reimplemented from Base.

Definition at line 334 of file MidiMap.cpp.

Field Documentation

◆ __instance

MidiMap * __instance = nullptr
static

Object holding the current MidiMap singleton.

It is initialized with NULL, set with create_instance(), and accessed with get_instance().

Definition at line 46 of file MidiMap.h.

◆ __mutex

QMutex __mutex
private

Definition at line 119 of file MidiMap.h.

◆ m_ccActionMap

std::multimap<int, std::shared_ptr<Action> > m_ccActionMap
private

Definition at line 114 of file MidiMap.h.

◆ m_mmcActionMap

std::multimap<QString, std::shared_ptr<Action> > m_mmcActionMap
private

Definition at line 115 of file MidiMap.h.

◆ m_noteActionMap

std::multimap<int, std::shared_ptr<Action> > m_noteActionMap
private

Definition at line 113 of file MidiMap.h.

◆ m_pcActionVector

std::vector<std::shared_ptr<Action> > m_pcActionVector
private

Definition at line 116 of file MidiMap.h.