merged with 1697 revision of trunk (which is post-rc1 but pre-rc2
[ardour.git] / libs / midi++2 / midi++ / alsa_sequencer.h
1 /*
2     Copyright (C) 2004 Paul Davis 
3     This program is free software; you can redistribute it and/or modify
4     it under the terms of the GNU General Public License as published by
5     the Free Software Foundation; either version 2 of the License, or
6     (at your option) any later version.
7
8     This program is distributed in the hope that it will be useful,
9     but WITHOUT ANY WARRANTY; without even the implied warranty of
10     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11     GNU General Public License for more details.
12
13     You should have received a copy of the GNU General Public License
14     along with this program; if not, write to the Free Software
15     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17 */
18
19 #ifndef __alsa_sequencer_midiport_h__
20 #define __alsa_sequencer_midiport_h__
21
22 #include <vector>
23 #include <string>
24
25 #include <fcntl.h>
26 #include <unistd.h>
27
28 #include <alsa/asoundlib.h>
29 #include <midi++/port.h>
30
31 namespace MIDI {
32
33 class ALSA_SequencerMidiPort : public Port
34
35 {
36   public:
37         ALSA_SequencerMidiPort (PortRequest &req);
38         virtual ~ALSA_SequencerMidiPort ();
39
40         /* select(2)/poll(2)-based I/O */
41
42         virtual int selectable() const;
43
44   protected:
45         /* Direct I/O */
46         
47         int write (byte *msg, size_t msglen);   
48         int read (byte *buf, size_t max);
49
50   private:
51         snd_midi_event_t *decoder, *encoder;
52         int port_id;
53         snd_seq_event_t SEv;
54
55         int CreatePorts(PortRequest &req);
56
57         static int init_client (std::string name);
58         static snd_seq_t* seq;
59 };
60
61 }; /* namespace MIDI */
62
63 #endif // __alsa_sequencer_midiport_h__
64