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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 551 by schoenebeck, Tue May 17 18:16:54 2005 UTC revision 906 by schoenebeck, Sun Jul 23 16:44:08 2006 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 26  Line 26 
26    
27  #include "../../common/global.h"  #include "../../common/global.h"
28  #include "../../common/Mutex.h"  #include "../../common/Mutex.h"
29  #include "../../common/LinuxSamplerException.h"  #include "../../common/Exception.h"
30  #include "../DeviceParameter.h"  #include "../DeviceParameter.h"
31    #include "midi.h"
32  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
33  #include "../../engines/common/EngineChannel.h"  #include "../../engines/EngineChannel.h"
34    #include "../../common/SynchronizedConfig.h"
35    
36  namespace LinuxSampler {  namespace LinuxSampler {
37    
38      // just symbol prototyping      // just symbol prototyping
39      class MidiInputDevice;      class MidiInputDevice;
40        class EngineChannel;
41    
42      class MidiInputPort {      class MidiInputPort {
43          public:          public:
# Line 42  namespace LinuxSampler { Line 45  namespace LinuxSampler {
45              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
46              // type definitions              // type definitions
47    
             /**  
              * MIDI channels  
              */  
             enum midi_chan_t {  
                 midi_chan_1   = 0,  
                 midi_chan_2   = 1,  
                 midi_chan_3   = 2,  
                 midi_chan_4   = 3,  
                 midi_chan_5   = 4,  
                 midi_chan_6   = 5,  
                 midi_chan_7   = 6,  
                 midi_chan_8   = 7,  
                 midi_chan_9   = 8,  
                 midi_chan_10  = 9,  
                 midi_chan_11  = 10,  
                 midi_chan_12  = 11,  
                 midi_chan_13  = 12,  
                 midi_chan_14  = 13,  
                 midi_chan_15  = 14,  
                 midi_chan_16  = 15,  
                 midi_chan_all = 16  
             };  
   
48              /** MIDI Port Parameter 'NAME'              /** MIDI Port Parameter 'NAME'
49               *               *
50               * Used to assign an arbitrary name to the MIDI port.               * Used to assign an arbitrary name to the MIDI port.
# Line 76  namespace LinuxSampler { Line 56  namespace LinuxSampler {
56                      virtual String Description();                      virtual String Description();
57                      virtual bool   Fix();                      virtual bool   Fix();
58                      virtual std::vector<String> PossibilitiesAsString();                      virtual std::vector<String> PossibilitiesAsString();
59                      virtual void OnSetValue(String s) throw (LinuxSamplerException);                      virtual void OnSetValue(String s) throw (Exception);
60                  protected:                  protected:
61                      MidiInputPort* pPort;                      MidiInputPort* pPort;
62              };              };
# Line 125  namespace LinuxSampler { Line 105  namespace LinuxSampler {
105               */               */
106              std::map<String,DeviceRuntimeParameter*> PortParameters();              std::map<String,DeviceRuntimeParameter*> PortParameters();
107    
108                /**
109                 * Registers that an engine wants to have sysex messages.
110                 */
111                static void AddSysexListener(Engine* engine);
112    
113                /**
114                 * Removes engine from list of engines getting sysex
115                 * messages.
116                 *
117                 * @returns true if engine was removed, false if it wasn't
118                 *          present in the list.
119                 */
120                static bool RemoveSysexListener(Engine* engine);
121    
122    
123              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
# Line 139  namespace LinuxSampler { Line 130  namespace LinuxSampler {
130               * event to be forwarded to all connected engines on the               * event to be forwarded to all connected engines on the
131               * corresponding MIDI channel.               * corresponding MIDI channel.
132               *               *
133                 * This method is meant for realtime rendering, this way an event
134                 * is immediately created with the current system time as time
135                 * stamp.
136                 *
137               * @param Key         - MIDI key number of the triggered key               * @param Key         - MIDI key number of the triggered key
138               * @param Velocity    - MIDI velocity of the triggered key               * @param Velocity    - MIDI velocity of the triggered key
139               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
# Line 148  namespace LinuxSampler { Line 143  namespace LinuxSampler {
143    
144              /**              /**
145               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
146                 * whenever a note on event arrived, this will cause the note on
147                 * event to be forwarded to all connected engines on the
148                 * corresponding MIDI channel.
149                 *
150                 * This method is meant for offline rendering and / or in case the
151                 * exact fragment position of the event is already known.
152                 *
153                 * @param Key         - MIDI key number of the triggered key
154                 * @param Velocity    - MIDI velocity of the triggered key
155                 * @param MidiChannel - MIDI channel on which event occured on
156                 *                      (low level indexing, means 0..15)
157                 * @param FragmentPos - event's sample point position in the
158                 *                      current audio fragment
159                 */
160                void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos);
161    
162                /**
163                 * Should be called by the implementing MIDI input device
164               * whenever a note off event arrived, this will cause the note               * whenever a note off event arrived, this will cause the note
165               * off event to be forwarded to all connected engines on the               * off event to be forwarded to all connected engines on the
166               * corresponding MIDI channel.               * corresponding MIDI channel.
167               *               *
168                 * This method is meant for realtime rendering, this way an event
169                 * is immediately created with the current system time as time
170                 * stamp.
171                 *
172               * @param Key         - MIDI key number of the released key               * @param Key         - MIDI key number of the released key
173               * @param Velocity    - MIDI velocity of the released key               * @param Velocity    - MIDI velocity of the released key
174               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
# Line 161  namespace LinuxSampler { Line 178  namespace LinuxSampler {
178    
179              /**              /**
180               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
181                 * whenever a note off event arrived, this will cause the note
182                 * off event to be forwarded to all connected engines on the
183                 * corresponding MIDI channel.
184                 *
185                 * This method is meant for offline rendering and / or in case the
186                 * exact fragment position of the event is already known.
187                 *
188                 * @param Key         - MIDI key number of the released key
189                 * @param Velocity    - MIDI velocity of the released key
190                 * @param MidiChannel - MIDI channel on which event occured on
191                 *                      (low level indexing, means 0..15)
192                 * @param FragmentPos - event's sample point position in the
193                 *                      current audio fragment
194                 */
195                void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel, int32_t FragmentPos);
196    
197                /**
198                 * Should be called by the implementing MIDI input device
199               * whenever a pitchbend event arrived, this will cause the               * whenever a pitchbend event arrived, this will cause the
200               * pitchbend event to be forwarded to all connected engines.               * pitchbend event to be forwarded to all connected engines.
201               *               *
202                 * This method is meant for realtime rendering, this way an event
203                 * is immediately created with the current system time as time
204                 * stamp.
205                 *
206               * @param Pitch       - MIDI pitch value               * @param Pitch       - MIDI pitch value
207               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
208               *                      (low level indexing, means 0..15)               *                      (low level indexing, means 0..15)
# Line 172  namespace LinuxSampler { Line 211  namespace LinuxSampler {
211    
212              /**              /**
213               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
214                 * whenever a pitchbend event arrived, this will cause the
215                 * pitchbend event to be forwarded to all connected engines.
216                 *
217                 * This method is meant for offline rendering and / or in case the
218                 * exact fragment position of the event is already known.
219                 *
220                 * @param Pitch       - MIDI pitch value
221                 * @param MidiChannel - MIDI channel on which event occured on
222                 *                      (low level indexing, means 0..15)
223                 * @param FragmentPos - event's sample point position in the
224                 *                      current audio fragment
225                 */
226                void DispatchPitchbend(int Pitch, uint MidiChannel, int32_t FragmentPos);
227    
228                /**
229                 * Should be called by the implementing MIDI input device
230               * whenever a control change event arrived, this will cause the               * whenever a control change event arrived, this will cause the
231               * control change event to be forwarded to all engines on the               * control change event to be forwarded to all engines on the
232               * corresponding MIDI channel.               * corresponding MIDI channel.
233               *               *
234                 * This method is meant for realtime rendering, this way an event
235                 * is immediately created with the current system time as time
236                 * stamp.
237                 *
238               * @param Controller  - MIDI controller number               * @param Controller  - MIDI controller number
239               * @param Value       - MIDI control change value               * @param Value       - MIDI control change value
240               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
# Line 185  namespace LinuxSampler { Line 244  namespace LinuxSampler {
244    
245              /**              /**
246               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
247                 * whenever a control change event arrived, this will cause the
248                 * control change event to be forwarded to all engines on the
249                 * corresponding MIDI channel.
250                 *
251                 * This method is meant for offline rendering and / or in case the
252                 * exact fragment position of the event is already known.
253                 *
254                 * @param Controller  - MIDI controller number
255                 * @param Value       - MIDI control change value
256                 * @param MidiChannel - MIDI channel on which event occured on
257                 *                      (low level indexing, means 0..15)
258                 * @param FragmentPos - event's sample point position in the
259                 *                      current audio fragment
260                 */
261                void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel, int32_t FragmentPos);
262    
263                /**
264                 * Should be called by the implementing MIDI input device
265               * whenever a program change event arrived, this will cause the               * whenever a program change event arrived, this will cause the
266               * appropriate sampler channel to be connected with this MIDI               * appropriate sampler channel to be connected with this MIDI
267               * device.               * device.
# Line 220  namespace LinuxSampler { Line 297  namespace LinuxSampler {
297              MidiInputDevice* pDevice;              MidiInputDevice* pDevice;
298              int portNumber;              int portNumber;
299              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.
300              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.              typedef std::set<EngineChannel*> MidiChannelMap_t[17];
301                SynchronizedConfig<MidiChannelMap_t> MidiChannelMap; ///< 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.
302                SynchronizedConfig<MidiChannelMap_t>::Reader MidiChannelMapReader; ///< MIDI thread access to MidiChannelMap
303              Mutex MidiChannelMapMutex; ///< Used to protect the MidiChannelMap from being used at the same time by different threads.              Mutex MidiChannelMapMutex; ///< Used to protect the MidiChannelMap from being used at the same time by different threads.
304                SynchronizedConfig<std::set<Engine*> >::Reader SysexListenersReader; ///< MIDI thread access to SysexListeners
305    
306              /**              /**
307               * Constructor               * Constructor
# Line 234  namespace LinuxSampler { Line 314  namespace LinuxSampler {
314              virtual ~MidiInputPort();              virtual ~MidiInputPort();
315    
316              friend class MidiInputDevice;              friend class MidiInputDevice;
317                
318          private:          private:
319              EngineChannel* pPreviousProgramChangeEngineChannel; ///< Points to the engine channel which was connected by the previous DispatchProgramChange() call.              EngineChannel* pPreviousProgramChangeEngineChannel; ///< Points to the engine channel which was connected by the previous DispatchProgramChange() call.
320                static SynchronizedConfig<std::set<Engine*> > SysexListeners; ///< All engines that are listening to sysex messages.
321      };      };
322    
323  } // namsepace LinuxSampler  } // namsepace LinuxSampler

Legend:
Removed from v.551  
changed lines
  Added in v.906

  ViewVC Help
Powered by ViewVC