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

Contents of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceFactory.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 551 - (show annotations) (download) (as text)
Tue May 17 18:16:54 2005 UTC (18 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5113 byte(s)
* Implemented MIDI program change as general, engine independant solution.
  The program number will determine the sampler channel to which the MIDI
  device will be connected to and the given MIDI channel defines on which
  MIDI channel that sampler channel should listen to. Also the program
  change will disconnect probably established connection from the previous
  program change event.

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * 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 *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21 * MA 02111-1307 USA *
22 ***************************************************************************/
23
24 #ifndef __LS_MIDI_INPUT_DEVICE_FACTORY_H__
25 #define __LS_MIDI_INPUT_DEVICE_FACTORY_H__
26
27 #include <map>
28 #include <vector>
29
30 #include "../../common/LinuxSamplerException.h"
31 #include "../DeviceParameterFactory.h"
32 #include "MidiInputDevice.h"
33 #include "../../Sampler.h"
34
35 #define REGISTER_MIDI_INPUT_DRIVER(DriverClass) static LinuxSampler::MidiInputDeviceFactory::InnerFactoryRegistrator<DriverClass> __auto_register_midi_input_driver__##DriverClass
36 #define REGISTER_MIDI_INPUT_DRIVER_PARAMETER(DriverClass, ParameterClass) static LinuxSampler::MidiInputDeviceFactory::ParameterRegistrator<DriverClass, DriverClass::ParameterClass> __auto_register_midi_input_driver_parameter__##DriverClass##ParameterClass
37
38 namespace LinuxSampler {
39
40 class MidiInputDeviceFactory {
41 public:
42 class InnerFactory {
43 public:
44 virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) = 0;
45 virtual String Description() = 0;
46 virtual String Version() = 0;
47 };
48
49 template <class Driver_T>
50 class InnerFactoryTemplate : public InnerFactory {
51 public:
52 virtual MidiInputDevice* Create(std::map<String,DeviceCreationParameter*>& Parameters, Sampler* pSampler) { return new Driver_T(Parameters, pSampler); }
53 virtual String Description() { return Driver_T::Description(); }
54 virtual String Version() { return Driver_T::Version(); }
55 };
56
57 template <class Driver_T>
58 class InnerFactoryRegistrator {
59 public:
60 InnerFactoryRegistrator() {
61 MidiInputDeviceFactory::InnerFactories[Driver_T::Name()] = new MidiInputDeviceFactory::InnerFactoryTemplate<Driver_T>;
62 MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()] = new DeviceParameterFactory();
63 }
64 };
65
66 template <class Driver_T, class Parameter_T>
67 class ParameterRegistrator {
68 public:
69 ParameterRegistrator() {
70 DeviceParameterFactory::Register<Parameter_T>(MidiInputDeviceFactory::ParameterFactories[Driver_T::Name()]);
71 }
72 };
73
74
75 static MidiInputDevice* Create(String DriverName, std::map<String,String> Parameters, Sampler* pSampler) throw (LinuxSamplerException);
76 static std::vector<String> AvailableDrivers();
77 static String AvailableDriversAsString();
78 static std::map<String,DeviceCreationParameter*> GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException);
79 static DeviceCreationParameter* GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException);
80 static String GetDriverDescription(String DriverName) throw (LinuxSamplerException);
81 static String GetDriverVersion(String DriverName) throw (LinuxSamplerException);
82
83 // protected: /* FIXME: fields below should be protected, causes errors on gcc 2.95 though */
84 static std::map<String, InnerFactory*> InnerFactories;
85 static std::map<String, DeviceParameterFactory*> ParameterFactories;
86 };
87
88 } // namespace LinuxSampler
89
90 #endif // __LS_AUDIO_OUTPUT_DEVICE_FACTORY_H__

  ViewVC Help
Powered by ViewVC