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

Annotation of /linuxsampler/trunk/src/engines/gig/InstrumentResourceManager.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1212 - (hide annotations) (download) (as text)
Tue May 29 23:59:36 2007 UTC (16 years, 10 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 6589 byte(s)
* added highly experimental support for on-the-fly instrument editing
  within the sampler's process (by using instrument editor plugins),
  you'll notice the new "Registered instrument editors:" message on
  startup, the plugin path can be overridden at compile time with
  ./configure --enable-plugin-dir=/some/dir
* added a new LSCP command "EDIT INSTRUMENT <sampler-channel>" to spawn
  a matching instrument editor for the instrument on the given sampler
  channel (LSCP command syntax might be subject to change soon)
* config.h is not going to be installed along with liblinuxsampler's
  API header files anymore (not necessary anymore)
* take care of $(DESTDIR) when creating the instruments DB on 'make
  install' rule (needed for packaging and cross compilation)
* bumped version to 0.4.0.5cvs

1 schoenebeck 53 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5 schoenebeck 56 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 1212 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
7 schoenebeck 53 * *
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_GIG_INSTRUMENTRESOURCEMANAGER_H__
25     #define __LS_GIG_INSTRUMENTRESOURCEMANAGER_H__
26    
27     #include "../../common/global.h"
28    
29 schoenebeck 505 #include <gig.h>
30    
31 schoenebeck 53 #include "../../common/global.h"
32     #include "../../common/ResourceManager.h"
33 schoenebeck 203 #include "../../drivers/audio/AudioOutputDevice.h"
34 schoenebeck 947 #include "../InstrumentManager.h"
35 schoenebeck 53
36     //namespace libgig = gig;
37    
38     namespace LinuxSampler { namespace gig {
39    
40     typedef ResourceConsumer< ::gig::Instrument> InstrumentConsumer;
41    
42     }} // namespace LinuxSampler::gig
43    
44 schoenebeck 411 #include "EngineChannel.h"
45 schoenebeck 53 #include "Engine.h"
46 schoenebeck 1212 #include "../InstrumentEditor.h"
47 schoenebeck 53
48     namespace LinuxSampler { namespace gig {
49    
50     // just symbol prototyping
51 schoenebeck 411 class EngineChannel;
52 schoenebeck 53
53 schoenebeck 947 /** @brief Gig instrument manager
54 schoenebeck 53 *
55     * Manager to share gig instruments between multiple Gigasampler
56 schoenebeck 411 * engine channels. The engine channels Borrow() instruments when they
57     * need them and HandBack() when they don't need them anymore. The
58 schoenebeck 53 * InstrumentResourceManager loads the corresponding gig file and gig
59 schoenebeck 411 * instrument if needed, if it's already in use by another engine
60     * channel, then it just returns the same resource, if an gig
61 schoenebeck 947 * instrument / file is not needed anymore, then it will be freed from
62     * memory.
63 schoenebeck 53 */
64 schoenebeck 1212 class InstrumentResourceManager : public InstrumentManager, public ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument>, public InstrumentEditorListener {
65 schoenebeck 411 public:
66 persson 1038 InstrumentResourceManager() : Gigs(this) {}
67 schoenebeck 411 virtual ~InstrumentResourceManager() {}
68 schoenebeck 517 static void OnInstrumentLoadingProgress(::gig::progress_t* pProgress);
69 schoenebeck 947
70     // implementation of derived abstract methods from 'InstrumentManager'
71     virtual std::vector<instrument_id_t> Instruments();
72     virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID);
73     virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode);
74     virtual String GetInstrumentName(instrument_id_t ID);
75 schoenebeck 1212 virtual String GetInstrumentTypeName(instrument_id_t ID);
76     virtual String GetInstrumentTypeVersion(instrument_id_t ID);
77     virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException);
78 persson 1038
79 schoenebeck 1212 // implementation of derived abstract method from 'InstrumentEditorListener'
80     virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender);
81    
82 persson 1038 void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer,
83     ::gig::DimensionRegion** dimRegionsInUse);
84     void HandBackDimReg(::gig::DimensionRegion* pDimReg);
85    
86 schoenebeck 53 protected:
87     virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg);
88     virtual void Destroy(::gig::Instrument* pResource, void* pArg);
89     virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg);
90     private:
91     typedef ResourceConsumer< ::gig::File> GigConsumer;
92    
93     class GigResourceManager : public ResourceManager<String, ::gig::File> {
94     protected:
95     virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg);
96     virtual void Destroy(::gig::File* pResource, void* pArg);
97     virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore
98 schoenebeck 411 public:
99 persson 1038 GigResourceManager(InstrumentResourceManager* parent) : parent(parent) {}
100 schoenebeck 411 virtual ~GigResourceManager() {}
101 persson 1038 private:
102     InstrumentResourceManager* parent;
103 schoenebeck 53 } Gigs;
104    
105 schoenebeck 411 void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel);
106 persson 1038
107     struct dimreg_info_t {
108     int refCount;
109     ::gig::File* file;
110     ::RIFF::File* riff;
111     };
112     Mutex DimRegInfoMutex; ///< protects the DimRegInfo and SampleRefCount maps from concurrent access by the instrument loader and disk threads
113     std::map< ::gig::DimensionRegion*, dimreg_info_t> DimRegInfo; ///< contains dimension regions that are still in use but belong to released instrument
114     std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument
115 schoenebeck 53
116 schoenebeck 1212 Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map
117     std::map<InstrumentEditor*, InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor
118 schoenebeck 53 };
119    
120     }} // namespace LinuxSampler::gig
121    
122     #endif // __LS_GIG_INSTRUMENTRESOURCEMANAGER_H__

  ViewVC Help
Powered by ViewVC