/[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 244 by schoenebeck, Fri Sep 17 01:01:11 2004 UTC revision 840 by persson, Sun Feb 26 13:00: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                              *
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 "midi.h"
32  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
33  #include "../../engines/common/Engine.h"  #include "../../engines/common/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 40  namespace LinuxSampler { Line 45  namespace LinuxSampler {
45              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
46              // type definitions              // type definitions
47    
             /**  
              * MIDI channels  
              */  
             enum midi_chan_t {  
                 midi_chan_all = 0,  
                 midi_chan_1   = 1,  
                 midi_chan_2   = 2,  
                 midi_chan_3   = 3,  
                 midi_chan_4   = 4,  
                 midi_chan_5   = 5,  
                 midi_chan_6   = 6,  
                 midi_chan_7   = 7,  
                 midi_chan_8   = 8,  
                 midi_chan_9   = 9,  
                 midi_chan_10  = 10,  
                 midi_chan_11  = 11,  
                 midi_chan_12  = 12,  
                 midi_chan_13  = 13,  
                 midi_chan_14  = 14,  
                 midi_chan_15  = 15,  
                 midi_chan_16  = 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 96  namespace LinuxSampler { Line 78  namespace LinuxSampler {
78               * @param MidiChannel - MIDI channel to connect to               * @param MidiChannel - MIDI channel to connect to
79               * @throws MidiInputException  if MidiChannel argument invalid               * @throws MidiInputException  if MidiChannel argument invalid
80               */               */
81              void Connect(Engine* pEngine, midi_chan_t MidiChannel);              void Connect(EngineChannel* pEngineChannel, midi_chan_t MidiChannel);
82    
83              /**              /**
84               * Disconnect given sampler engine from this MIDI input device.               * Disconnect given sampler engine from this MIDI input device.
85                 * If the given engine was not connected with this device,
86                 * nothing happens.
87               *               *
88               * @param pEngine - sampler engine               * @param pEngine - sampler engine
89               */               */
90              void Disconnect(Engine* pEngine);              void Disconnect(EngineChannel* pEngineChannel);
91    
92              /**              /**
93               * Return MIDI device where this MIDI port belongs to.               * Return MIDI device where this MIDI port belongs to.
# Line 138  namespace LinuxSampler { Line 122  namespace LinuxSampler {
122               * @param Key         - MIDI key number of the triggered key               * @param Key         - MIDI key number of the triggered key
123               * @param Velocity    - MIDI velocity of the triggered key               * @param Velocity    - MIDI velocity of the triggered key
124               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
125                 *                      (low level indexing, means 0..15)
126               */               */
127              void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel);              void DispatchNoteOn(uint8_t Key, uint8_t Velocity, uint MidiChannel);
128    
# Line 150  namespace LinuxSampler { Line 135  namespace LinuxSampler {
135               * @param Key         - MIDI key number of the released key               * @param Key         - MIDI key number of the released key
136               * @param Velocity    - MIDI velocity of the released key               * @param Velocity    - MIDI velocity of the released key
137               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
138                 *                      (low level indexing, means 0..15)
139               */               */
140              void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel);              void DispatchNoteOff(uint8_t Key, uint8_t Velocity, uint MidiChannel);
141    
# Line 160  namespace LinuxSampler { Line 146  namespace LinuxSampler {
146               *               *
147               * @param Pitch       - MIDI pitch value               * @param Pitch       - MIDI pitch value
148               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
149                 *                      (low level indexing, means 0..15)
150               */               */
151              void DispatchPitchbend(int Pitch, uint MidiChannel);              void DispatchPitchbend(int Pitch, uint MidiChannel);
152    
# Line 172  namespace LinuxSampler { Line 159  namespace LinuxSampler {
159               * @param Controller  - MIDI controller number               * @param Controller  - MIDI controller number
160               * @param Value       - MIDI control change value               * @param Value       - MIDI control change value
161               * @param MidiChannel - MIDI channel on which event occured on               * @param MidiChannel - MIDI channel on which event occured on
162                 *                      (low level indexing, means 0..15)
163               */               */
164              void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel);              void DispatchControlChange(uint8_t Controller, uint8_t Value, uint MidiChannel);
165    
166              /**              /**
167               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
168                 * whenever a program change event arrived, this will cause the
169                 * appropriate sampler channel to be connected with this MIDI
170                 * device.
171                 *
172                 * For example consider a program change event on MIDI channel
173                 * 3 for program number 18. This would cause this MIDI input
174                 * device to be connected to sampler channel 18 and would cause
175                 * sampler channel 18 to listen to MIDI channel 3.
176                 *
177                 * This is the current, general implementation of program
178                 * change events. It might change in future, e.g to allow
179                 * sampler engines to allow by themselfes how to act on a
180                 * program change event.
181                 *
182                 * @param Program     - sampler channel to connect to this MIDI
183                 *                      input device
184                 * @param MidiChannel - MIDI channel on which sampler channel
185                 *                      \a Program should listen to
186                 */
187                void DispatchProgramChange(uint8_t Program, uint MidiChannel);
188    
189                /**
190                 * Should be called by the implementing MIDI input device
191               * whenever a system exclusive message arrived, this will cause               * whenever a system exclusive message arrived, this will cause
192               * the message to be forwarded to all connected engines.               * the message to be forwarded to all connected engines.
193               *               *
# Line 189  namespace LinuxSampler { Line 200  namespace LinuxSampler {
200              MidiInputDevice* pDevice;              MidiInputDevice* pDevice;
201              int portNumber;              int portNumber;
202              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.
203              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.              typedef std::set<EngineChannel*> MidiChannelMap_t[17];
204                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.
205                Mutex MidiChannelMapMutex; ///< Used to protect the MidiChannelMap from being used at the same time by different threads.
206    
207              /**              /**
208               * Constructor               * Constructor
# Line 202  namespace LinuxSampler { Line 215  namespace LinuxSampler {
215              virtual ~MidiInputPort();              virtual ~MidiInputPort();
216    
217              friend class MidiInputDevice;              friend class MidiInputDevice;
218    
219            private:
220                EngineChannel* pPreviousProgramChangeEngineChannel; ///< Points to the engine channel which was connected by the previous DispatchProgramChange() call.
221      };      };
222    
223  } // namsepace LinuxSampler  } // namsepace LinuxSampler

Legend:
Removed from v.244  
changed lines
  Added in v.840

  ViewVC Help
Powered by ViewVC