/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDeviceAlsa.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceAlsa.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1951 - (show annotations) (download) (as text)
Wed Jul 29 15:31:09 2009 UTC (14 years, 8 months ago) by persson
File MIME type: text/x-c++hdr
File size: 5840 byte(s)
* ASIO fixes: avoid initializing the device twice, avoid throwing
  exception when getting parameters from a disconnected device
* Windows: add the installation directory to the DLL search path when
  loading an editor plugin (solves problems with VST and gigedit on
  systems with other GTK versions installed)
* fixed minor memory leak in ALSA MIDI driver

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #ifndef __LS_MIDIINPUTDEVICEALSA_H__
25 #define __LS_MIDIINPUTDEVICEALSA_H__
26
27 #include <alsa/asoundlib.h>
28
29 #include "../../common/global_private.h"
30 #include "../../common/Thread.h"
31 #include "MidiInputDevice.h"
32
33 namespace LinuxSampler {
34
35 /** ALSA MIDI input driver
36 *
37 * Implements MIDI input for the Advanced Linux Sound Architecture
38 * (ALSA).
39 */
40 class MidiInputDeviceAlsa : public MidiInputDevice, public Thread {
41 public:
42
43 /**
44 * MIDI Port implementation for the ALSA MIDI input driver.
45 */
46 class MidiInputPortAlsa : public MidiInputPort {
47 public:
48 /** MIDI Port Parameter 'NAME'
49 *
50 * Used to assign an arbitrary name to the MIDI port.
51 */
52 class ParameterName : public MidiInputPort::ParameterName {
53 public:
54 ParameterName(MidiInputPort* pPort) throw (Exception);
55 virtual void OnSetValue(String s) throw (Exception);
56 };
57
58 /** MIDI Port Parameter 'ALSA_SEQ_BINDINGS'
59 *
60 * Used to connect to other Alsa sequencer clients.
61 */
62 class ParameterAlsaSeqBindings : public DeviceRuntimeParameterStrings {
63 public:
64 ParameterAlsaSeqBindings(MidiInputPortAlsa* pPort);
65 virtual String Description();
66 virtual bool Fix();
67 virtual std::vector<String> PossibilitiesAsString();
68 virtual void OnSetValue(std::vector<String> vS) throw (Exception);
69 protected:
70 MidiInputPortAlsa* pPort;
71 };
72
73 /** MIDI Port Parameter 'ALSA_SEQ_ID'
74 *
75 * Reflects the ALSA sequencer ID of this MIDI port,
76 * e.g. "128:0".
77 */
78 class ParameterAlsaSeqId : public DeviceRuntimeParameterString {
79 public:
80 ParameterAlsaSeqId(MidiInputPortAlsa* pPort);
81 virtual String Description();
82 virtual bool Fix();
83 virtual std::vector<String> PossibilitiesAsString();
84 virtual void OnSetValue(String s);
85 };
86
87 void ConnectToAlsaMidiSource(const char* MidiSource);
88 protected:
89 std::vector<snd_seq_port_subscribe_t*> subscriptions;
90
91 MidiInputPortAlsa(MidiInputDeviceAlsa* pDevice) throw (MidiInputException);
92 ~MidiInputPortAlsa();
93 friend class MidiInputDeviceAlsa;
94 private:
95 MidiInputDeviceAlsa* pDevice;
96
97 friend class ParameterName;
98 friend class ParameterAlsaSeqBindings;
99 void UnsubscribeAll();
100 };
101
102 MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler);
103 ~MidiInputDeviceAlsa();
104
105 // derived abstract methods from class 'MidiInputDevice'
106 void Listen();
107 void StopListen();
108 virtual String Driver();
109 static String Name();
110 static String Description();
111 static String Version();
112
113 MidiInputPortAlsa* CreateMidiPort();
114 protected:
115 int Main(); ///< Implementation of virtual method from class Thread
116 private:
117 snd_seq_t* hAlsaSeq;
118 int hAlsaSeqClient; ///< Alsa Sequencer client ID
119
120 friend class MidiInputPortAlsa;
121 friend class MidiInputPortAlsa::ParameterName;
122 friend class MidiInputPortAlsa::ParameterAlsaSeqBindings;
123 };
124 }
125
126 #endif // __LS_MIDIINPUTDEVICEALSA_H__

  ViewVC Help
Powered by ViewVC