/[svn]/linuxsampler/trunk/src/engines/EngineFactory.cpp
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/EngineFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2012 - (hide annotations) (download)
Fri Oct 23 17:53:17 2009 UTC (14 years, 5 months ago) by iliev
File size: 3569 byte(s)
* Refactoring: moved the independent code from
  the Gigasampler format engine to base classes
* SFZ format engine: experimental code (not usable yet)
* SoundFont format engine: experimental code (not usable yet)
* Fixed crash which may occur when MIDI key + transpose is out of range

1 schoenebeck 411 /***************************************************************************
2     * *
3 capela 1012 * Copyright (C) 2005-2007 Christian Schoenebeck *
4 schoenebeck 411 * *
5     * This program is free software; you can redistribute it and/or modify *
6     * it under the terms of the GNU General Public License as published by *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This program is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this program; if not, write to the Free Software *
17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18     * MA 02111-1307 USA *
19     ***************************************************************************/
20    
21     #include "EngineFactory.h"
22    
23     #include <strings.h>
24    
25     #include "gig/Engine.h"
26    
27 iliev 2012 #if HAVE_SF2
28     #include "sf2/Engine.h"
29     #endif
30    
31     #include "sfz/Engine.h"
32    
33 schoenebeck 420 #include "../common/global.h"
34    
35 schoenebeck 411 namespace LinuxSampler {
36    
37 schoenebeck 420 // all currently existing engine instances
38     static std::set<LinuxSampler::Engine*> engines;
39    
40 schoenebeck 900 std::vector<String> EngineFactory::AvailableEngineTypes() {
41     std::vector<String> result;
42 iliev 2012 result.push_back("GIG");
43     #if HAVE_SF2
44     result.push_back("SF2");
45     #endif
46     result.push_back("SFZ");
47 schoenebeck 900 return result;
48     }
49    
50     String EngineFactory::AvailableEngineTypesAsString() {
51     std::vector<String> types = AvailableEngineTypes();
52     String result;
53     std::vector<String>::iterator iter = types.begin();
54     for (; iter != types.end(); iter++) {
55     if (result != "") result += ",";
56 iliev 908 result += "'" + *iter + "'";
57 schoenebeck 900 }
58     return result;
59     }
60    
61 schoenebeck 880 LinuxSampler::Engine* EngineFactory::Create(String EngineType) throw (Exception) {
62 schoenebeck 411 if (!strcasecmp(EngineType.c_str(),"GigEngine") || !strcasecmp(EngineType.c_str(),"gig")) {
63 schoenebeck 420 Engine* pEngine = new gig::Engine;
64     engines.insert(pEngine);
65     return pEngine;
66 iliev 2012 } else if (!strcasecmp(EngineType.c_str(),"sf2")) {
67     #if HAVE_SF2
68     Engine* pEngine = new sf2::Engine;
69     engines.insert(pEngine);
70     return pEngine;
71     #else
72     throw Exception("LinuxSampler is not compiled with SF2 support");
73     #endif
74     } else if (!strcasecmp(EngineType.c_str(),"sfz")) {
75     Engine* pEngine = new sfz::Engine;
76     engines.insert(pEngine);
77     return pEngine;
78 schoenebeck 411 }
79 iliev 2012
80 schoenebeck 880 throw Exception("Unknown engine type");
81 schoenebeck 411 }
82    
83 capela 1012 void EngineFactory::Erase(LinuxSampler::Engine* pEngine) {
84 schoenebeck 420 engines.erase(pEngine);
85     }
86    
87 capela 1012 void EngineFactory::Destroy(LinuxSampler::Engine* pEngine) {
88     delete pEngine;
89     }
90    
91 persson 840 const std::set<LinuxSampler::Engine*>& EngineFactory::EngineInstances() {
92 schoenebeck 420 return engines;
93     }
94    
95 persson 840 } // namespace LinuxSampler

  ViewVC Help
Powered by ViewVC