1 /* 2 * Hydrogen 3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net] 4 * 5 * http://www.hydrogen-music.org 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY, without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 * 21 */ 22 #ifndef MIDIMAP_H 23 #define MIDIMAP_H 24 25 26 #include <map> 27 #include <cassert> 28 #include <hydrogen/object.h> 29 30 #include <QtCore/QMutex> 31 32 class Action; 33 34 class MidiMap : public H2Core::Object 35 { 36 H2_OBJECT 37 public: 38 typedef std::map< QString, Action* > map_t; 39 /** 40 * Object holding the current MidiMap singleton. It is 41 * initialized with NULL, set with create_instance(), 42 * and accessed with get_instance(). 43 */ 44 static MidiMap* __instance; 45 ~MidiMap(); 46 47 /** 48 * If #__instance equals 0, a new MidiMap singleton will 49 * be created and stored in it. 50 * 51 * It is called in Hydrogen::create_instance(). 52 */ 53 static void create_instance(); 54 /** 55 * Convenience function calling reset() on the current 56 * MidiMap #__instance. 57 */ 58 static void reset_instance(); 59 /** 60 * Returns a pointer to the current MidiMap singleton 61 * stored in #__instance. 62 */ get_instance()63 static MidiMap* get_instance() { assert(__instance); return __instance; } 64 65 void reset(); ///< Reinitializes the object. 66 67 void registerMMCEvent( QString, Action* ); 68 void registerNoteEvent( int , Action* ); 69 void registerCCEvent( int , Action* ); 70 void registerPCEvent( Action* ); 71 72 map_t getMMCMap(); 73 74 Action* getMMCAction( QString ); 75 Action* getNoteAction( int note ); 76 Action* getCCAction( int parameter ); 77 Action* getPCAction(); 78 79 int findCCValueByActionParam1( QString actionType, QString param1 ); 80 int findCCValueByActionType( QString actionType ); 81 82 void setupNoteArray(); 83 private: 84 MidiMap(); 85 86 Action* __note_array[ 128 ]; 87 Action* __cc_array[ 128 ]; 88 Action* __pc_action; 89 90 map_t mmcMap; 91 QMutex __mutex; 92 }; 93 #endif 94