1 /*  SpiralSynth
2  *  Copyleft (C) 2000 David Griffiths <dave@pawfal.org>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 
19 #include <sys/types.h>
20 #include <stdio.h>
21 #include <fcntl.h>
22 #include <unistd.h>
23 #include <iostream>
24 #include <limits.h>
25 
26 #ifndef MIDI
27 #define MIDI
28 
29 class MidiEvent
30 {
31 public:
32 	enum type{NONE,ON,OFF,PITCHBEND,PARAMETER};
33 
MidiEvent()34 	MidiEvent() {m_Type=NONE;}
MidiEvent(type t,int octave,int note,float v)35 	MidiEvent(type t, int octave, int note, float v)
36 		{m_Type=t; m_Octave=octave; m_Note=note; m_Volume=v;}
37 
GetType()38 	type GetType() {return m_Type;}
GetVolume()39 	float GetVolume() {return m_Volume;}
GetOctave()40 	int GetOctave() {return m_Octave;}
GetNote()41 	int GetNote() {return m_Note;}
42 private:
43 	float m_Volume;
44 	type  m_Type;
45 	int   m_Octave;
46 	int   m_Note;
47 };
48 
49 class MidiDevice
50 {
51 public:
52 	MidiDevice();
53 	~MidiDevice();
54 
55 	MidiEvent GetEvent();
56 	void CollectEvents();
57 	void Close();
58 
59 private:
60 	void Init();
61 	int m_MidiFd;
62 	int   m_Pipefd[2];
63 	int   m_ChildPID;
64 };
65 
66 #endif
67