/[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 274 by schoenebeck, Sat Oct 9 00:46:18 2004 UTC revision 675 by schoenebeck, Wed Jun 22 22:09:28 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 "midi.h"
32  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
33  #include "../../engines/common/Engine.h"  #include "../../engines/common/EngineChannel.h"
34    
35  namespace LinuxSampler {  namespace LinuxSampler {
36    
37      // just symbol prototyping      // just symbol prototyping
38      class MidiInputDevice;      class MidiInputDevice;
39        class EngineChannel;
40    
41      class MidiInputPort {      class MidiInputPort {
42          public:          public:
# Line 40  namespace LinuxSampler { Line 44  namespace LinuxSampler {
44              /////////////////////////////////////////////////////////////////              /////////////////////////////////////////////////////////////////
45              // type definitions              // type definitions
46    
             /**  
              * 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  
             };  
   
47              /** MIDI Port Parameter 'NAME'              /** MIDI Port Parameter 'NAME'
48               *               *
49               * 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 77  namespace LinuxSampler {
77               * @param MidiChannel - MIDI channel to connect to               * @param MidiChannel - MIDI channel to connect to
78               * @throws MidiInputException  if MidiChannel argument invalid               * @throws MidiInputException  if MidiChannel argument invalid
79               */               */
80              void Connect(Engine* pEngine, midi_chan_t MidiChannel);              void Connect(EngineChannel* pEngineChannel, midi_chan_t MidiChannel);
81    
82              /**              /**
83               * Disconnect given sampler engine from this MIDI input device.               * Disconnect given sampler engine from this MIDI input device.
84                 * If the given engine was not connected with this device,
85                 * nothing happens.
86               *               *
87               * @param pEngine - sampler engine               * @param pEngine - sampler engine
88               */               */
89              void Disconnect(Engine* pEngine);              void Disconnect(EngineChannel* pEngineChannel);
90    
91              /**              /**
92               * Return MIDI device where this MIDI port belongs to.               * Return MIDI device where this MIDI port belongs to.
# Line 181  namespace LinuxSampler { Line 164  namespace LinuxSampler {
164    
165              /**              /**
166               * Should be called by the implementing MIDI input device               * Should be called by the implementing MIDI input device
167                 * whenever a program change event arrived, this will cause the
168                 * appropriate sampler channel to be connected with this MIDI
169                 * device.
170                 *
171                 * For example consider a program change event on MIDI channel
172                 * 3 for program number 18. This would cause this MIDI input
173                 * device to be connected to sampler channel 18 and would cause
174                 * sampler channel 18 to listen to MIDI channel 3.
175                 *
176                 * This is the current, general implementation of program
177                 * change events. It might change in future, e.g to allow
178                 * sampler engines to allow by themselfes how to act on a
179                 * program change event.
180                 *
181                 * @param Program     - sampler channel to connect to this MIDI
182                 *                      input device
183                 * @param MidiChannel - MIDI channel on which sampler channel
184                 *                      \a Program should listen to
185                 */
186                void DispatchProgramChange(uint8_t Program, uint MidiChannel);
187    
188                /**
189                 * Should be called by the implementing MIDI input device
190               * whenever a system exclusive message arrived, this will cause               * whenever a system exclusive message arrived, this will cause
191               * the message to be forwarded to all connected engines.               * the message to be forwarded to all connected engines.
192               *               *
# Line 193  namespace LinuxSampler { Line 199  namespace LinuxSampler {
199              MidiInputDevice* pDevice;              MidiInputDevice* pDevice;
200              int portNumber;              int portNumber;
201              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.              std::map<String,DeviceRuntimeParameter*> Parameters;  ///< All port parameters.
202              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.
203                Mutex MidiChannelMapMutex; ///< Used to protect the MidiChannelMap from being used at the same time by different threads.
204    
205              /**              /**
206               * Constructor               * Constructor
# Line 206  namespace LinuxSampler { Line 213  namespace LinuxSampler {
213              virtual ~MidiInputPort();              virtual ~MidiInputPort();
214    
215              friend class MidiInputDevice;              friend class MidiInputDevice;
216    
217            private:
218                EngineChannel* pPreviousProgramChangeEngineChannel; ///< Points to the engine channel which was connected by the previous DispatchProgramChange() call.
219      };      };
220    
221  } // namsepace LinuxSampler  } // namsepace LinuxSampler

Legend:
Removed from v.274  
changed lines
  Added in v.675

  ViewVC Help
Powered by ViewVC