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

Annotation of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 288 - (hide annotations) (download)
Tue Oct 19 00:36:34 2004 UTC (19 years, 6 months ago) by schoenebeck
File size: 5659 byte(s)
* configure.in: added check for UNIX98 compatibility, check if there's at
  least one supported MIDI input and audio output system available, added
  conditionals for ALSA and JACK
* src/drivers/audio/Makefile.am: ALSA and JACK drivers are only compiled
  respectively if they're supported by the system
* MidiInputDeviceFactory.cpp, AudioOutputDeviceFactory.cpp: little
  workaround for reported linker problem
* removed autotools generated files from CVS

1 schoenebeck 201 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6     * *
7     * This program is free software; you can redistribute it and/or modify *
8     * it under the terms of the GNU General Public License as published by *
9     * the Free Software Foundation; either version 2 of the License, or *
10     * (at your option) any later version. *
11     * *
12     * This program is distributed in the hope that it will be useful, *
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15     * GNU General Public License for more details. *
16     * *
17     * You should have received a copy of the GNU General Public License *
18     * along with this program; if not, write to the Free Software *
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20     * MA 02111-1307 USA *
21     ***************************************************************************/
22    
23     #include "MidiInputDeviceFactory.h"
24    
25 schoenebeck 288 // just to avoid linker problems
26     #include "MidiInputDeviceAlsa.h"
27    
28 schoenebeck 201 namespace LinuxSampler {
29    
30     std::map<String, MidiInputDeviceFactory::InnerFactory*> MidiInputDeviceFactory::InnerFactories;
31     std::map<String, DeviceParameterFactory*> MidiInputDeviceFactory::ParameterFactories;
32    
33 schoenebeck 288 // just a little hack to avoid linker problems
34     static int ___init___foo___() {
35     #if HAVE_ALSA
36     MidiInputDeviceAlsa::Name().c_str();
37     #endif // HAVE_ALSA
38     return 0;
39     }
40     static int ___foo___ = ___init___foo___();
41    
42 schoenebeck 201 MidiInputDevice* MidiInputDeviceFactory::Create(String DriverName, std::map<String,String> Parameters) throw (LinuxSamplerException) {
43     if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no midi input driver '" + DriverName + "'.");
44     //Let's see if we need to create parameters
45     std::map<String,DeviceCreationParameter*> thisDeviceParams;
46     DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
47     if (pParamFactory) {
48     thisDeviceParams = pParamFactory->CreateAllParams(Parameters);
49     } else {
50     //No parameters are registered by the driver. Throw if any parameters were specified.
51     if (Parameters.size() != 0) throw LinuxSamplerException("Driver '" + DriverName + "' does not have any parameters.");
52     }
53     //Now create the device using those parameters
54     MidiInputDevice* pDevice = InnerFactories[DriverName]->Create(thisDeviceParams);
55     //Now attach all parameters to the newely created device.
56     for (std::map<String,DeviceCreationParameter*>::iterator iter = thisDeviceParams.begin(); iter != thisDeviceParams.end(); iter++) {
57     iter->second->Attach(pDevice);
58     }
59     return pDevice;
60     }
61    
62     std::vector<String> MidiInputDeviceFactory::AvailableDrivers() {
63     std::vector<String> result;
64     std::map<String, InnerFactory*>::iterator iter = InnerFactories.begin();
65     while (iter != InnerFactories.end()) {
66     result.push_back(iter->first);
67     iter++;
68     }
69     return result;
70     }
71    
72     String MidiInputDeviceFactory::AvailableDriversAsString() {
73     std::vector<String> drivers = AvailableDrivers();
74     String result;
75     std::vector<String>::iterator iter = drivers.begin();
76     for (; iter != drivers.end(); iter++) {
77     if (result != "") result += ",";
78     result += *iter;
79     }
80     return result;
81     }
82    
83     std::map<String,DeviceCreationParameter*> MidiInputDeviceFactory::GetAvailableDriverParameters(String DriverName) throw (LinuxSamplerException) {
84     if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no midi input driver '" + DriverName + "'.");
85     std::map<String,DeviceCreationParameter*> thisDeviceParams;
86     DeviceParameterFactory* pParamFactory = ParameterFactories[DriverName];
87     if (pParamFactory) {
88     thisDeviceParams = pParamFactory->CreateAllParams();
89     }
90     return thisDeviceParams;
91     }
92    
93     DeviceCreationParameter* MidiInputDeviceFactory::GetDriverParameter(String DriverName, String ParameterName) throw (LinuxSamplerException) {
94     std::map<String,DeviceCreationParameter*> parameters = GetAvailableDriverParameters(DriverName);
95     if (!parameters.count(ParameterName)) throw LinuxSamplerException("Midi input driver '" + DriverName + "' does not have a parameter '" + ParameterName + "'.");
96     return parameters[ParameterName];
97     }
98    
99     String MidiInputDeviceFactory::GetDriverDescription(String DriverName) throw (LinuxSamplerException) {
100     if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no midi input driver '" + DriverName + "'.");
101     return InnerFactories[DriverName]->Description();
102     }
103    
104     String MidiInputDeviceFactory::GetDriverVersion(String DriverName) throw (LinuxSamplerException) {
105     if (!InnerFactories.count(DriverName)) throw LinuxSamplerException("There is no midi input driver '" + DriverName + "'.");
106     return InnerFactories[DriverName]->Version();
107     }
108    
109     } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC