/[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 221 by schoenebeck, Fri Aug 20 17:25:19 2004 UTC revision 551 by schoenebeck, Tue May 17 18:16:54 2005 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                              *
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 24  Line 25 
25  #define __LS_MIDIINPUTPORT_H__  #define __LS_MIDIINPUTPORT_H__
26    
27  #include "../../common/global.h"  #include "../../common/global.h"
28    #include "../../common/Mutex.h"
29  #include "../../common/LinuxSamplerException.h"  #include "../../common/LinuxSamplerException.h"
30  #include "../DeviceParameter.h"  #include "../DeviceParameter.h"
31  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
32  #include "../../engines/common/Engine.h"  #include "../../engines/common/EngineChannel.h"
33    
34  namespace LinuxSampler {  namespace LinuxSampler {
35    
# Line 44  namespace LinuxSampler { Line 46  namespace LinuxSampler {
46               * MIDI channels               * MIDI channels
47               */               */
48              enum midi_chan_t {              enum midi_chan_t {
49                  midi_chan_all = 0,                  midi_chan_1   = 0,
50                  midi_chan_1   = 1,                  midi_chan_2   = 1,
51                  midi_chan_2   = 2,                  midi_chan_3   = 2,
52                  midi_chan_3   = 3,                  midi_chan_4   = 3,
53                  midi_chan_4   = 4,                  midi_chan_5   = 4,
54                  midi_chan_5   = 5,                  midi_chan_6   = 5,
55                  midi_chan_6   = 6,                  midi_chan_7   = 6,
56                  midi_chan_7   = 7,                  midi_chan_8   = 7,
57                  midi_chan_8   = 8,                  midi_chan_9   = 8,
58                  midi_chan_9   = 9,                  midi_chan_10  = 9,
59                  midi_chan_10  = 10,                  midi_chan_11  = 10,
60                  midi_chan_11  = 11,                  midi_chan_12  = 11,
61                  midi_chan_12  = 12,                  midi_chan_13  = 12,
62                  midi_chan_13  = 13,                  midi_chan_14  = 13,
63                  midi_chan_14  = 14,                  midi_chan_15  = 14,
64                  midi_chan_15  = 15,                  midi_chan_16  = 15,
65                  midi_chan_16  = 16                  midi_chan_all = 16
66              };              };
67    
68              /** MIDI Port Parameter 'NAME'              /** MIDI Port Parameter 'NAME'
# Line 96  namespace LinuxSampler { Line 98  namespace LinuxSampler {
98               * @param MidiChannel - MIDI channel to connect to               * @param MidiChannel - MIDI channel to connect to
99               * @throws MidiInputException  if MidiChannel argument invalid               * @throws MidiInputException  if MidiChannel argument invalid
100               */               */
101              void Connect(Engine* pEngine, midi_chan_t MidiChannel);              void Connect(EngineChannel* pEngineChannel, midi_chan_t MidiChannel);
102    
103              /**              /**
104               * Disconnect given sampler engine from this MIDI input device.               * Disconnect given sampler engine from this MIDI input device.
105                 * If the given engine was not connected with this device,
106                 * nothing happens.
107               *               *
108               * @param pEngine - sampler engine               * @param pEngine - sampler engine
109               */               */
110              void Disconnect(Engine* pEngine);              void Disconnect(EngineChannel* pEngineChannel);
111    
112              /**              /**
113               * Return MIDI device where this MIDI port belongs to.               * Return MIDI device where this MIDI port belongs to.
# Line 138  namespace LinuxSampler { Line 142  namespace LinuxSampler {
142               * @param Key         - MIDI key number of the triggered key               * @param Key         - MIDI key number of the triggered key
143               * @param Velocity    - MIDI velocity of the triggered key               * @param Velocity    - MIDI velocity of the triggered key
144               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
145                 *                      (low level indexing, means 0..15)
146               */               */
147              void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel);              void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel);
148    
# Line 150  namespace LinuxSampler { Line 155  namespace LinuxSampler {
155               * @param Key         - MIDI key number of the released key               * @param Key         - MIDI key number of the released key
156               * @param Velocity    - MIDI velocity of the released key               * @param Velocity    - MIDI velocity of the released key
157               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
158                 *                      (low level indexing, means 0..15)
159               */               */
160              void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel);              void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel);
161    
# Line 160  namespace LinuxSampler { Line 166  namespace LinuxSampler {
166               *               *
167               * @param Pitch       - MIDI pitch value               * @param Pitch       - MIDI pitch value
168               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
169                 *                      (low level indexing, means 0..15)
170               */               */
171              void DispatchPitchbend(int Pitch, uint MidiChannel);              void DispatchPitchbend(int Pitch, uint MidiChannel);
172    
# Line 172  namespace LinuxSampler { Line 179  namespace LinuxSampler {
179               * @param Controller  - MIDI controller number               * @param Controller  - MIDI controller number
180               * @param Value       - MIDI control change value               * @param Value       - MIDI control change value
181               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
182                 *                      (low level indexing, means 0..15)
183               */               */
184              void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel);              void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel);
185    
186                /**
187                 * Should be called by the implementing MIDI input device
188                 * whenever a program change event arrived, this will cause the
189                 * appropriate sampler channel to be connected with this MIDI
190                 * device.
191                 *
192                 * For example consider a program change event on MIDI channel
193                 * 3 for program number 18. This would cause this MIDI input
194                 * device to be connected to sampler channel 18 and would cause
195                 * sampler channel 18 to listen to MIDI channel 3.
196                 *
197                 * This is the current, general implementation of program
198                 * change events. It might change in future, e.g to allow
199                 * sampler engines to allow by themselfes how to act on a
200                 * program change event.
201                 *
202                 * @param Program     - sampler channel to connect to this MIDI
203                 *                      input device
204                 * @param MidiChannel - MIDI channel on which sampler channel
205                 *                      \a Program should listen to
206                 */
207                void DispatchProgramChange(uint8_t Program, uint MidiChannel);
208    
209                /**
210                 * Should be called by the implementing MIDI input device
211                 * whenever a system exclusive message arrived, this will cause
212                 * the message to be forwarded to all connected engines.
213                 *
214                 * @param pData - pointer to the sysex data
215                 * @param Size  - length of the sysex data (in bytes)
216                 */
217                void DispatchSysex(void* pData, uint Size);
218    
219          protected:          protected:
220              MidiInputDevice* pDevice;              MidiInputDevice* pDevice;
221              int portNumber;              int portNumber;
222              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.
223              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.              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.
224                Mutex MidiChannelMapMutex; ///< Used to protect the MidiChannelMap from being used at the same time by different threads.
225    
226              /**              /**
227               * Constructor               * Constructor
# Line 192  namespace LinuxSampler { Line 234  namespace LinuxSampler {
234              virtual ~MidiInputPort();              virtual ~MidiInputPort();
235    
236              friend class MidiInputDevice;              friend class MidiInputDevice;
237                
238            private:
239                EngineChannel* pPreviousProgramChangeEngineChannel; ///< Points to the engine channel which was connected by the previous DispatchProgramChange() call.
240      };      };
241    
242  } // namsepace LinuxSampler  } // namsepace LinuxSampler

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

  ViewVC Help
Powered by ViewVC