/[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 221 - (hide annotations) (download) (as text)
Fri Aug 20 17:25:19 2004 UTC (19 years, 8 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8359 byte(s)
* src/drivers/midi/MidiInputDeviceAlsa.cpp: implemented port parameter
 "NAME" which now updates the registered ALSA seq port name as well, fixed
  port parameter "ALSA_SEQ_BINDINGS" to allow more than one binding
* src/network/lscp.y: fixed symbol STRINGVAL (that is strings encapsulated
  into apostrophes) which didn't allow space characters
* changed all driver names and driver paramaters to upper case
* fixed typo in LSCP documentation
  (section 5.3.12, was: "SET MIDI_INPUT_PORT PARAMETER",
   should be: "SET MIDI_INPUT_PORT_PARAMETER")

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

  ViewVC Help
Powered by ViewVC