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 
23 #ifndef H2_MIDI_INPUT_H
24 #define H2_MIDI_INPUT_H
25 
26 #include <hydrogen/object.h>
27 #include <string>
28 #include <vector>
29 #include "MidiCommon.h"
30 
31 namespace H2Core
32 {
33 
34 /**
35  * MIDI input base class
36  */
37 class MidiInput : public virtual Object
38 {
39 public:
40 	MidiInput( const char* class_name );
41 	virtual ~MidiInput();
42 
43 	virtual void open() = 0;
44 	virtual void close() = 0;
45 	virtual std::vector<QString> getOutputPortList() = 0;
46 
setActive(bool isActive)47 	void setActive( bool isActive ) {
48 		m_bActive = isActive;
49 	}
50 	void handleMidiMessage( const MidiMessage& msg );
51 	void handleSysexMessage( const MidiMessage& msg );
52 	void handleControlChangeMessage( const MidiMessage& msg );
53 	void handleProgramChangeMessage( const MidiMessage& msg );
54 	void handlePolyphonicKeyPressureMessage( const MidiMessage& msg );
55 
56 protected:
57 	bool m_bActive;
58 
59 	void handleNoteOnMessage( const MidiMessage& msg );
60 	void handleNoteOffMessage( const MidiMessage& msg, bool CymbalChoke );
61 
62 
63 private:
64 	unsigned long  __noteOnTick;
65 	unsigned long  __noteOffTick;
66 	unsigned long computeDeltaNoteOnOfftime();
67 
68 	int __hihat_cc_openess;
69 
70 
71 
72 };
73 
74 };
75 
76 #endif
77 
78