/[svn]/linuxsampler/trunk/src/engines/sf2/InstrumentResourceManager.h
ViewVC logotype

Contents of /linuxsampler/trunk/src/engines/sf2/InstrumentResourceManager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3052 - (show annotations) (download) (as text)
Wed Dec 14 17:34:54 2016 UTC (7 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 5328 byte(s)
- Preparations for Xcode project update.

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005 - 2008 Christian Schoenebeck *
7 * Copyright (C) 2009 - 2012 Christian Schoenebeck and Grigor Iliev *
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17 * GNU General Public License for more details. *
18 * *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, write to the Free Software *
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
22 * MA 02111-1307 USA *
23 ***************************************************************************/
24
25 #ifndef __LS_SF2_INSTRUMENTRESOURCEMANAGER_H__
26 #define __LS_SF2_INSTRUMENTRESOURCEMANAGER_H__
27
28 #include "../../common/global.h"
29
30 #if AC_APPLE_UNIVERSAL_BUILD
31 # include <libgig/SF.h>
32 #else
33 # include <SF.h>
34 #endif
35
36 #include "../../common/global.h"
37 #include "../../common/Pool.h"
38 #include "../../common/ResourceManager.h"
39 #include "../../drivers/audio/AudioOutputDevice.h"
40 #include "../InstrumentManagerBase.h"
41 #include "../../common/ArrayList.h"
42
43 namespace LinuxSampler { namespace sf2 {
44
45 typedef ResourceConsumer< ::sf2::Preset> InstrumentConsumer;
46
47 }} // namespace LinuxSampler::sf2
48
49 #include "../../plugins/InstrumentEditor.h"
50
51 namespace LinuxSampler { namespace sf2 {
52 class Engine;
53 class EngineChannel;
54
55 /** @brief sf2 instrument manager
56 *
57 * Manager to share sf2 instruments between multiple sf2
58 * engine channels. The engine channels Borrow() instruments when they
59 * need them and HandBack() when they don't need them anymore. The
60 * InstrumentResourceManager loads the corresponding sf2 file and sf2
61 * instrument if needed, if it's already in use by another engine
62 * channel, then it just returns the same resource, if a sf2
63 * instrument / file is not needed anymore, then it will be freed from
64 * memory.
65 */
66 class InstrumentResourceManager : public InstrumentManagerBase< ::sf2::File, ::sf2::Preset, ::sf2::Region, ::sf2::Sample> {
67 public:
68 InstrumentResourceManager() : Sf2s(this) {}
69 virtual ~InstrumentResourceManager() {}
70
71 // implementation of derived abstract methods from 'InstrumentManager'
72 virtual String GetInstrumentName(instrument_id_t ID);
73 virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException);
74 virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException);
75
76 protected:
77 // implementation of derived abstract methods from 'ResourceManager'
78 virtual ::sf2::Preset* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg);
79 virtual void Destroy(::sf2::Preset* pResource, void* pArg);
80 virtual void DeleteRegionIfNotUsed(::sf2::Region* pRegion, region_info_t* pRegInfo);
81 virtual void DeleteSampleIfNotUsed(::sf2::Sample* pSample, region_info_t* pRegInfo);
82 private:
83 typedef ResourceConsumer< ::sf2::File> Sf2Consumer;
84
85 class Sf2ResourceManager : public ResourceManager<String, ::sf2::File> {
86 protected:
87 // implementation of derived abstract methods from 'ResourceManager'
88 virtual ::sf2::File* Create(String Key, Sf2Consumer* pConsumer, void*& pArg);
89 virtual void Destroy(::sf2::File* pResource, void* pArg);
90 virtual void OnBorrow(::sf2::File* pResource, Sf2Consumer* pConsumer, void*& pArg) {} // ignore
91 public:
92 Sf2ResourceManager(InstrumentResourceManager* parent) : parent(parent) {}
93 virtual ~Sf2ResourceManager() {}
94 friend class InstrumentResourceManager;
95 private:
96 InstrumentResourceManager* parent;
97 } Sf2s;
98
99 int GetSfInstrumentCount(::sf2::File* pFile);
100 ::sf2::Preset* GetSfInstrument(::sf2::File* pFile, int idx);
101 };
102
103 }} // namespace LinuxSampler::sf2
104
105 #endif // __LS_SF2_INSTRUMENTRESOURCEMANAGER_H__

  ViewVC Help
Powered by ViewVC