26#include <QMutexLocker>
100 if ( pAction ==
nullptr || pAction->isNull() ) {
110 ERRORLOG( QString(
"Provided event string [%1] is no supported MMC event" )
111 .arg( sEventString ) );
116 if ( ppAction !=
nullptr && ssType == sEventString &&
117 ppAction->isEquivalentTo( pAction ) ) {
118 WARNINGLOG( QString(
"MMC event [%1] for Action [%2: Param1: [%3], Param2: [%4], Param3: [%5]] was already registered" )
119 .arg( sEventString ).arg( pAction->getType() )
120 .arg( pAction->getParameter1() )
121 .arg( pAction->getParameter2() )
122 .arg( pAction->getParameter3() ) );
134 if ( pAction ==
nullptr || pAction->isNull() ) {
140 ERRORLOG( QString(
"Unable to register Note MIDI [%1]: Provided note [%2] out of bound [%3,%4]" )
141 .arg( pAction->toQString() ).arg( nNote )
147 if ( ppAction !=
nullptr && nnPitch == nNote &&
148 ppAction->isEquivalentTo( pAction ) ) {
149 WARNINGLOG( QString(
"NOTE event [%1] for Action [%2: Param1: [%3], Param2: [%4], Param3: [%5]] was already registered" )
150 .arg( nNote ).arg( pAction->getType() )
151 .arg( pAction->getParameter1() )
152 .arg( pAction->getParameter2() )
153 .arg( pAction->getParameter3() ) );
164 if ( pAction ==
nullptr || pAction->isNull() ) {
169 if ( nParameter < 0 || nParameter > 127 ) {
170 ERRORLOG( QString(
"Unable to register CC MIDI [%1]: Provided parameter [%2] out of bound [0,127]" )
171 .arg( pAction->toQString() ).arg( nParameter ) );
176 if ( ppAction !=
nullptr && nnParam == nParameter &&
177 ppAction->isEquivalentTo( pAction ) ) {
178 WARNINGLOG( QString(
"CC event [%1] for Action [%2: Param1: [%3], Param2: [%4], Param3: [%5]] was already registered" )
179 .arg( nParameter ).arg( pAction->getType() )
180 .arg( pAction->getParameter1() )
181 .arg( pAction->getParameter2() )
182 .arg( pAction->getParameter3() ) );
193 if ( pAction ==
nullptr || pAction->isNull() ) {
199 if ( ppAction !=
nullptr && ppAction->isEquivalentTo( pAction ) ) {
200 WARNINGLOG( QString(
"PC event for Action [%2: Param1: [%3], Param2: [%4], Param3: [%5]] was already registered" )
201 .arg( pAction->getType() )
202 .arg( pAction->getParameter1() )
203 .arg( pAction->getParameter2() )
204 .arg( pAction->getParameter3() ) );
216 std::vector<std::shared_ptr<Action>> actions;
220 for (
auto ii = range.first; ii != range.second; ++ii ) {
221 if ( ii->second !=
nullptr ) {
222 actions.push_back( ii->second );
226 return std::move( actions );
233 std::vector<std::shared_ptr<Action>> actions;
237 for (
auto ii = range.first; ii != range.second; ++ii ) {
238 if ( ii->second !=
nullptr ) {
239 actions.push_back( ii->second );
243 return std::move( actions );
249 std::vector<std::shared_ptr<Action>> actions;
253 for (
auto ii = range.first; ii != range.second; ++ii ) {
254 if ( ii->second !=
nullptr ) {
255 actions.push_back( ii->second );
259 return std::move( actions );
264 std::vector<int> values;
267 if ( ppAction !=
nullptr && ppAction->getType() == sActionType &&
268 ppAction->getParameter1() == sParam1 ){
269 values.push_back( nnParam );
273 return std::move( values );
278 std::vector<int> values;
281 if ( ppAction !=
nullptr && ppAction->getType() == sActionType ){
282 values.push_back( nnParam );
286 return std::move( values );
290 std::vector<std::pair<H2Core::MidiMessage::Event,int>> midiEvents;
292 if ( pAction !=
nullptr && ! pAction->isNull() ) {
294 if ( ppAction !=
nullptr &&
295 ppAction->isEquivalentTo( pAction ) ) {
296 midiEvents.push_back( std::make_pair(
301 if ( ppAction !=
nullptr &&
302 ppAction->isEquivalentTo( pAction ) ) {
303 midiEvents.push_back( std::make_pair(
308 if ( ppAction !=
nullptr &&
309 ppAction->isEquivalentTo( pAction ) ) {
315 ERRORLOG( QString(
"Unexpected event type [%1] found in mmcActionMap" )
319 midiEvents.push_back( std::make_pair( event, 0 ) );
323 if ( ppAction !=
nullptr &&
324 ppAction->isEquivalentTo( pAction ) ) {
325 midiEvents.push_back( std::make_pair(
331 return std::move( midiEvents );
335 QString s = Base::sPrintIndention;
338 sOutput = QString(
"%1[MidiMap]\n" ).arg( sPrefix )
339 .append( QString(
"%1%2m_noteActionMap:\n" ).arg( sPrefix ).arg( s ) );
341 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
342 sOutput.append( QString(
"%1%2%2%3: %4\n" ).arg( sPrefix ).arg( s )
344 .arg( ppAction->toQString(
"",
true ) ) );
347 sOutput.append( QString(
"%1%2m_ccActionMap:\n" ).arg( sPrefix ).arg( s ) );
349 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
350 sOutput.append( QString(
"%1%2%2%3: %4\n" ).arg( sPrefix ).arg( s )
352 .arg( ppAction->toQString(
"",
true ) ) );
355 sOutput.append( QString(
"%1%2m_mmcActionMap:\n" ).arg( sPrefix ).arg( s ) );
357 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
358 sOutput.append( QString(
"%1%2%2%3: %4\n" ).arg( sPrefix ).arg( s )
360 .arg( ppAction->toQString(
"",
true ) ) );
363 sOutput.append( QString(
"%1%2m_pcActionVector:\n" ).arg( sPrefix ).arg( s ) );
365 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
366 sOutput.append( QString(
"%1%2%2%3\n" ).arg( sPrefix ).arg( s )
367 .arg( ppAction->toQString(
"",
true ) ) );
373 sOutput = QString(
"[MidiMap] m_noteActionMap: [" );
375 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
376 sOutput.append( QString(
"%1: %2, " ).arg( nParam )
377 .arg( ppAction->toQString(
"",
true ) ) );
380 sOutput.append( QString(
"], m_ccActionMap: [" ) );
382 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
383 sOutput.append( QString(
"%1: %2, " ).arg( nParam )
384 .arg( ppAction->toQString(
"",
true ) ) );
387 sOutput.append( QString(
"], m_mmcActionMap: [" ) );
389 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
390 sOutput.append( QString(
"%1: %2, " ).arg( nParam )
391 .arg( ppAction->toQString(
"",
true ) ) );
394 sOutput.append( QString(
", m_pcActionVector: [" ) );
396 if ( ppAction !=
nullptr && ! ppAction->isNull() ) {
397 sOutput.append( QString(
"%1, " ).arg( ppAction->toQString(
"",
true ) ) );
400 sOutput.append(
"]" );
static QString getNullActionType()
static Event QStringToEvent(const QString &sEvent)
The MidiMap maps MidiActions to MidiEvents.
void registerMMCEvent(QString, std::shared_ptr< Action >)
Sets up the relation between a mmc event and an action.
std::vector< std::shared_ptr< Action > > getCCActions(int nParameter)
Returns the cc action which was linked to the given event.
std::multimap< int, std::shared_ptr< Action > > m_noteActionMap
static MidiMap * __instance
Object holding the current MidiMap singleton.
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.
static void create_instance()
If __instance equals 0, a new MidiMap singleton will be created and stored in it.
std::vector< int > findCCValuesByActionParam1(QString sActionType, QString sParam1)
std::vector< std::pair< H2Core::MidiMessage::Event, int > > getRegisteredMidiEvents(std::shared_ptr< Action > pAction) 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 > > getMMCActions(QString sEventString)
Returns all MMC actions which are linked to the given event.
std::vector< std::shared_ptr< Action > > m_pcActionVector
std::vector< int > findCCValuesByActionType(QString sActionType)
QString toQString(const QString &sPrefix="", bool bShort=true) const override
Formatted string version for debugging purposes.
std::multimap< QString, std::shared_ptr< Action > > m_mmcActionMap
std::multimap< int, std::shared_ptr< Action > > m_ccActionMap
void reset()
Reinitializes the object.
static void reset_instance()
Convenience function calling reset() on the current MidiMap __instance.
void registerCCEvent(int, std::shared_ptr< Action >)
Sets up the relation between a cc event and an action.
#define MIDI_OUT_NOTE_MIN
#define MIDI_OUT_NOTE_MAX