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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 411 - (hide annotations) (download) (as text)
Sat Feb 26 02:01:14 2005 UTC (19 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 9199 byte(s)
* design change: using now one sampler engine instance and one disk thread
  instance for all sampler channels that are connected to the same audio
  output device (and are using the same engine type of course)
* added EngineFactory / EngineChannelFactory to remove the annoying build
  dependencies e.g. of the lscpserver to the actual sampler engine
  implementations
* bumped version to 0.3.0 (current CVS state is still quite broken,
  previous, stable CVS version was tagged as "v0_2_0" and is also available
  as source tarball)

1 schoenebeck 221 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 411 * Copyright (C) 2005 Christian Schoenebeck *
7 schoenebeck 221 * *
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_MIDIINPUTPORT_H__
25     #define __LS_MIDIINPUTPORT_H__
26    
27     #include "../../common/global.h"
28     #include "../../common/LinuxSamplerException.h"
29     #include "../DeviceParameter.h"
30     #include "MidiInputDevice.h"
31 schoenebeck 411 #include "../../engines/common/EngineChannel.h"
32 schoenebeck 221
33     namespace LinuxSampler {
34    
35     // just symbol prototyping
36     class MidiInputDevice;
37    
38     class MidiInputPort {
39     public:
40    
41     /////////////////////////////////////////////////////////////////
42     // type definitions
43    
44     /**
45     * MIDI channels
46     */
47     enum midi_chan_t {
48 schoenebeck 274 midi_chan_1 = 0,
49     midi_chan_2 = 1,
50     midi_chan_3 = 2,
51     midi_chan_4 = 3,
52     midi_chan_5 = 4,
53     midi_chan_6 = 5,
54     midi_chan_7 = 6,
55     midi_chan_8 = 7,
56     midi_chan_9 = 8,
57     midi_chan_10 = 9,
58     midi_chan_11 = 10,
59     midi_chan_12 = 11,
60     midi_chan_13 = 12,
61     midi_chan_14 = 13,
62     midi_chan_15 = 14,
63     midi_chan_16 = 15,
64     midi_chan_all = 16
65 schoenebeck 221 };
66    
67     /** MIDI Port Parameter 'NAME'
68     *
69     * Used to assign an arbitrary name to the MIDI port.
70     */
71     class ParameterName : public DeviceRuntimeParameterString {
72     public:
73     ParameterName(MidiInputPort* pPort);
74     ParameterName(MidiInputPort* pPort, String val);
75     virtual String Description();
76     virtual bool Fix();
77     virtual std::vector<String> PossibilitiesAsString();
78     virtual void OnSetValue(String s) throw (LinuxSamplerException);
79     protected:
80     MidiInputPort* pPort;
81     };
82    
83    
84    
85     /////////////////////////////////////////////////////////////////
86     // normal methods
87     // (usually not to be overriden by descendant)
88    
89     /**
90     * Connect given sampler engine with this MIDI input device.
91     * The engine can either be connected to one specific MIDI
92     * channel or all MIDI channels. If an engine gets connected
93     * twice to this MIDI input device, then the engine's old
94     * connection will be detached (no matter on which MIDI channel).
95     *
96     * @param pEngine - sampler engine
97     * @param MidiChannel - MIDI channel to connect to
98     * @throws MidiInputException if MidiChannel argument invalid
99     */
100 schoenebeck 411 void Connect(EngineChannel* pEngineChannel, midi_chan_t MidiChannel);
101 schoenebeck 221
102     /**
103     * Disconnect given sampler engine from this MIDI input device.
104     *
105     * @param pEngine - sampler engine
106     */
107 schoenebeck 411 void Disconnect(EngineChannel* pEngineChannel);
108 schoenebeck 221
109     /**
110     * Return MIDI device where this MIDI port belongs to.
111     */
112     MidiInputDevice* GetDevice();
113    
114     /**
115     * Return port number with which this MIDI port is registered to
116     * the MIDI device.
117     */
118     uint GetPortNumber();
119    
120     /**
121     * Return all parameter settings of this MIDI port.
122     */
123     std::map<String,DeviceRuntimeParameter*> PortParameters();
124    
125    
126    
127    
128    
129     /////////////////////////////////////////////////////////////////
130     // dispatch methods
131     // (should be called by the MidiInputDevice descendant on events)
132    
133     /**
134     * Should be called by the implementing MIDI input device
135     * whenever a note on event arrived, this will cause the note on
136     * event to be forwarded to all connected engines on the
137     * corresponding MIDI channel.
138     *
139     * @param Key - MIDI key number of the triggered key
140     * @param Velocity - MIDI velocity of the triggered key
141     * @param MidiChannel - MIDI channel on which event occured on
142 schoenebeck 274 * (low level indexing, means 0..15)
143 schoenebeck 221 */
144     void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel);
145    
146     /**
147     * Should be called by the implementing MIDI input device
148     * whenever a note off event arrived, this will cause the note
149     * off event to be forwarded to all connected engines on the
150     * corresponding MIDI channel.
151     *
152     * @param Key - MIDI key number of the released key
153     * @param Velocity - MIDI velocity of the released key
154     * @param MidiChannel - MIDI channel on which event occured on
155 schoenebeck 274 * (low level indexing, means 0..15)
156 schoenebeck 221 */
157     void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel);
158    
159     /**
160     * Should be called by the implementing MIDI input device
161     * whenever a pitchbend event arrived, this will cause the
162     * pitchbend event to be forwarded to all connected engines.
163     *
164     * @param Pitch - MIDI pitch value
165     * @param MidiChannel - MIDI channel on which event occured on
166 schoenebeck 274 * (low level indexing, means 0..15)
167 schoenebeck 221 */
168     void DispatchPitchbend(int Pitch, uint MidiChannel);
169    
170     /**
171     * Should be called by the implementing MIDI input device
172     * whenever a control change event arrived, this will cause the
173     * control change event to be forwarded to all engines on the
174     * corresponding MIDI channel.
175     *
176     * @param Controller - MIDI controller number
177     * @param Value - MIDI control change value
178     * @param MidiChannel - MIDI channel on which event occured on
179 schoenebeck 274 * (low level indexing, means 0..15)
180 schoenebeck 221 */
181     void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel);
182    
183 schoenebeck 244 /**
184     * Should be called by the implementing MIDI input device
185     * whenever a system exclusive message arrived, this will cause
186     * the message to be forwarded to all connected engines.
187     *
188     * @param pData - pointer to the sysex data
189     * @param Size - length of the sysex data (in bytes)
190     */
191     void DispatchSysex(void* pData, uint Size);
192    
193 schoenebeck 221 protected:
194     MidiInputDevice* pDevice;
195     int portNumber;
196     std::map<String,DeviceRuntimeParameter*> Parameters; ///< All port parameters.
197 schoenebeck 411 std::set<EngineChannel*> MidiChannelMap[17]; ///< Contains the list of connected engines for each MIDI channel, where index 0 points to the list of engines which are connected to all MIDI channels. Usually it's not necessary for the descendant to use this map, instead it should just use the Dispatch* methods.
198 schoenebeck 221
199     /**
200     * Constructor
201     */
202     MidiInputPort(MidiInputDevice* pDevice, int portNumber);
203    
204     /**
205     * Destructor
206     */
207     virtual ~MidiInputPort();
208    
209     friend class MidiInputDevice;
210     };
211    
212     } // namsepace LinuxSampler
213    
214     #endif // __LS_MIDIINPUTPORT_H__

  ViewVC Help
Powered by ViewVC