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

Annotation of /linuxsampler/trunk/src/drivers/midi/MidiInputDevice.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 277 - (hide annotations) (download) (as text)
Sat Oct 9 15:48:32 2004 UTC (19 years, 6 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7883 byte(s)
* compatibility fixes for old gcc 2.95.4

1 schoenebeck 201 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
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, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #ifndef __LS_MIDIINPUTDEVICE_H__
24     #define __LS_MIDIINPUTDEVICE_H__
25    
26     #include <stdexcept>
27     #include <set>
28     #include <map>
29     #include <vector>
30    
31     #include "../../common/global.h"
32     #include "../../common/LinuxSamplerException.h"
33     #include "../DeviceParameter.h"
34 schoenebeck 221 #include "MidiInputPort.h"
35 schoenebeck 201 #include "../../engines/common/Engine.h"
36    
37     namespace LinuxSampler {
38    
39     // just symbol prototyping
40 schoenebeck 221 class MidiInputPort;
41 schoenebeck 201 class Engine;
42    
43 schoenebeck 221 /**
44     * Midi input exception that should be thrown by the MidiInputDevice
45     * descendants in case initialization of the MIDI input system failed
46     * (which should be done in the constructor of the MidiInputDevice
47     * descendant).
48     */
49     class MidiInputException : public LinuxSamplerException {
50     public:
51     MidiInputException(const std::string& msg) : LinuxSamplerException(msg) {}
52     };
53    
54 schoenebeck 201 /** Abstract base class for MIDI input drivers in LinuxSampler
55     *
56     * This class will be derived by specialized classes which implement the
57     * connection to a specific MIDI input system (e.g. Alsa Sequencer,
58     * CoreMIDI). The MidiInputDevice desendant should just call the
59     * appropriate (protected) Dispatch* method here when an MIDI event
60     * occured. The dispatch* methods here will automatically forward the
61     * MIDI event to the appropriate, connected sampler engines.
62     */
63 schoenebeck 207 class MidiInputDevice : public Device {
64 schoenebeck 201 public:
65    
66     /////////////////////////////////////////////////////////////////
67     // type definitions
68    
69 schoenebeck 221 /** Device Parameter 'ACTIVE'
70     *
71     * Used to activate / deactivate the MIDI input device.
72     */
73 schoenebeck 201 class ParameterActive : public DeviceCreationParameterBool {
74 schoenebeck 221 public:
75     ParameterActive();
76     ParameterActive(String active);
77     virtual String Description();
78     virtual bool Fix();
79     virtual bool Mandatory();
80     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
81     virtual optional<bool> DefaultAsBool(std::map<String,String> Parameters);
82     virtual void OnSetValue(bool b) throw (LinuxSamplerException);
83     static String Name();
84     };
85 schoenebeck 201
86 schoenebeck 221 /** Device Parameter 'PORTS'
87     *
88     * Used to increase / decrease the number of MIDI ports of the
89     * MIDI input device.
90     */
91     class ParameterPorts : public DeviceCreationParameterInt {
92     public:
93     ParameterPorts();
94     ParameterPorts(String val);
95     virtual String Description();
96     virtual bool Fix();
97     virtual bool Mandatory();
98     virtual std::map<String,DeviceCreationParameter*> DependsAsParameters();
99     virtual optional<int> DefaultAsInt(std::map<String,String> Parameters);
100     virtual optional<int> RangeMinAsInt(std::map<String,String> Parameters);
101     virtual optional<int> RangeMaxAsInt(std::map<String,String> Parameters);
102     virtual std::vector<int> PossibilitiesAsInt(std::map<String,String> Parameters);
103     virtual void OnSetValue(int i) throw (LinuxSamplerException);
104     static String Name();
105     };
106 schoenebeck 201
107    
108    
109 schoenebeck 221 /////////////////////////////////////////////////////////////////
110     // abstract methods
111     // (these have to be implemented by the descendant)
112 schoenebeck 201
113 schoenebeck 221 /**
114     * Start listen to MIDI input events on the MIDI input port.
115     * The MIDIInputPort descendant should forward all MIDI input
116     * events by calling the appropriate (protected) Dispatch*
117     * method of class MidiInputPort.
118     */
119     virtual void Listen() = 0;
120 schoenebeck 201
121 schoenebeck 221 /**
122     * Stop to listen to MIDI input events on the MIDI input port.
123     * After this method was called, the MidiInputPort descendant
124     * should ignore all MIDI input events.
125     */
126     virtual void StopListen() = 0;
127 schoenebeck 201
128 schoenebeck 221 /**
129     * Return device driver name
130     */
131     virtual String Driver() = 0;
132 schoenebeck 201
133 schoenebeck 221 /**
134     * Create new Midi port
135     * This will be called by AcquirePorts
136     * Each individual device must implement this.
137     */
138     virtual MidiInputPort* CreateMidiPort() = 0;
139 schoenebeck 201
140    
141    
142 schoenebeck 221 /////////////////////////////////////////////////////////////////
143     // normal methods
144     // (usually not to be overriden by descendant)
145 schoenebeck 201
146 schoenebeck 221 /**
147     * Return midi port \a iPort.
148     *
149     * @throws MidiInputException if index out of bounds
150     */
151     MidiInputPort* GetPort(uint iPort) throw (MidiInputException);
152 schoenebeck 201
153 schoenebeck 221 /**
154     * Return all device parameter settings.
155     */
156     std::map<String,DeviceCreationParameter*> DeviceParameters();
157 schoenebeck 201
158     protected:
159 schoenebeck 221 std::map<String,DeviceCreationParameter*> Parameters; ///< All device parameters.
160     std::map<int,MidiInputPort*> Ports; ///< All MIDI ports.
161 schoenebeck 201
162 schoenebeck 221 /**
163     * Constructor
164     */
165 schoenebeck 201 MidiInputDevice(std::map<String,DeviceCreationParameter*> DriverParameters);
166    
167 schoenebeck 221 /**
168     * Destructor
169     */
170     virtual ~MidiInputDevice();
171 schoenebeck 201
172     /**
173     * Set number of MIDI ports required by the engine
174 schoenebeck 221 * This can either do nothing, create more ports
175     * or destroy ports depenging on the parameter
176     * and how many ports already exist on this driver.
177 schoenebeck 201 *
178     * @param Ports - number of ports to be left on this driver after this call.
179     */
180 schoenebeck 221 void AcquirePorts(uint Ports);
181 schoenebeck 201
182 schoenebeck 277 friend class ParameterActive;
183     friend class ParameterPorts;
184 schoenebeck 221 friend class Sampler; // allow Sampler class to destroy midi devices
185 schoenebeck 201 };
186     }
187    
188     #endif // __LS_MIDIINPUTDEVICE_H__

  ViewVC Help
Powered by ViewVC