/[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 2687 - (hide annotations) (download) (as text)
Sun Jan 4 17:16:05 2015 UTC (9 years, 3 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8016 byte(s)
* Instrument editor interface: Changed instrument editor plugin interface,
providing additional informations like the EngineChannel for which the
instrument editor was spawned for. This allows the instrument editors to
interact more actively with the sampler.
* Bumped version (1.0.0.svn60).

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 persson 2326 * Copyright (C) 2005 - 2012 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 iliev 2012 #include "../../common/Pool.h"
32 schoenebeck 53 #include "../../common/ResourceManager.h"
33 iliev 2012 #include "../InstrumentManagerBase.h"
34 schoenebeck 203 #include "../../drivers/audio/AudioOutputDevice.h"
35 schoenebeck 947 #include "../InstrumentManager.h"
36 schoenebeck 1653 #include "../../common/ArrayList.h"
37 schoenebeck 53
38     //namespace libgig = gig;
39    
40     namespace LinuxSampler { namespace gig {
41    
42     typedef ResourceConsumer< ::gig::Instrument> InstrumentConsumer;
43    
44     }} // namespace LinuxSampler::gig
45    
46 schoenebeck 1375 #include "../../plugins/InstrumentEditor.h"
47 schoenebeck 53
48     namespace LinuxSampler { namespace gig {
49 schoenebeck 2687
50 iliev 2012 class Engine;
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 iliev 2012 class InstrumentResourceManager : public InstrumentManagerBase< ::gig::File, ::gig::Instrument, ::gig::DimensionRegion, ::gig::Sample>, 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 String GetInstrumentName(instrument_id_t ID);
72 schoenebeck 1321 virtual String GetInstrumentDataStructureName(instrument_id_t ID);
73     virtual String GetInstrumentDataStructureVersion(instrument_id_t ID);
74 schoenebeck 2687 virtual InstrumentEditor* LaunchInstrumentEditor(LinuxSampler::EngineChannel* pEngineChannel, instrument_id_t ID, void* pUserData = NULL) throw (InstrumentManagerException) OVERRIDE;
75 schoenebeck 1525 virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException);
76     virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException);
77 persson 1038
78 schoenebeck 1321 // implementation of derived abstract methods from 'InstrumentEditorListener'
79 schoenebeck 1212 virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender);
80 schoenebeck 1321 virtual void OnSamplesToBeRemoved(std::set<void*> Samples, InstrumentEditor* pSender);
81     virtual void OnSamplesRemoved(InstrumentEditor* pSender);
82     virtual void OnDataStructureToBeChanged(void* pStruct, String sStructType, InstrumentEditor* pSender);
83     virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender);
84     virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender);
85 schoenebeck 1212
86 schoenebeck 1662 #if 0 // currently unused :
87 schoenebeck 1653 void TrySendNoteOnToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument);
88     void TrySendNoteOffToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument);
89 schoenebeck 1662 #endif // unused
90 schoenebeck 1653
91 schoenebeck 53 protected:
92 schoenebeck 1321 // implementation of derived abstract methods from 'ResourceManager'
93 schoenebeck 53 virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg);
94     virtual void Destroy(::gig::Instrument* pResource, void* pArg);
95 iliev 2012 virtual void DeleteRegionIfNotUsed(::gig::DimensionRegion* pRegion, region_info_t* pRegInfo);
96     virtual void DeleteSampleIfNotUsed(::gig::Sample* pSample, region_info_t* pRegInfo);
97 schoenebeck 53 private:
98 persson 2326 void CacheInitialSamples(::gig::Sample* pSample, AbstractEngine* pEngine);
99     void CacheInitialSamples(::gig::Sample* pSample, EngineChannel* pEngineChannel);
100     void CacheInitialSamples(::gig::Sample* pSample, uint maxSamplesPerCycle);
101    
102 schoenebeck 53 typedef ResourceConsumer< ::gig::File> GigConsumer;
103    
104     class GigResourceManager : public ResourceManager<String, ::gig::File> {
105     protected:
106 schoenebeck 1321 // implementation of derived abstract methods from 'ResourceManager'
107 schoenebeck 53 virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg);
108     virtual void Destroy(::gig::File* pResource, void* pArg);
109     virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore
110 schoenebeck 411 public:
111 persson 1038 GigResourceManager(InstrumentResourceManager* parent) : parent(parent) {}
112 schoenebeck 411 virtual ~GigResourceManager() {}
113 persson 1038 private:
114     InstrumentResourceManager* parent;
115 schoenebeck 53 } Gigs;
116    
117 schoenebeck 1321 void UncacheInitialSamples(::gig::Sample* pSample);
118     std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock);
119 iliev 2012 std::set<EngineChannel*> GetEngineChannelsUsing(::gig::Instrument* pInstrument, bool bLock);
120     std::set<Engine*> GetEnginesUsing(::gig::Instrument* pInstrument, bool bLock);
121     std::set<Engine*> GetEnginesUsing(::gig::File* pFile, bool bLock);
122 schoenebeck 1321 bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument);
123     void SuspendEnginesUsing(::gig::Instrument* pInstrument);
124     void SuspendEnginesUsing(::gig::File* pFile);
125     void ResumeAllEngines();
126 persson 1038
127 schoenebeck 1212 Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map
128 schoenebeck 1653 ArrayList<InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor
129 schoenebeck 1321 std::set<Engine*> suspendedEngines; ///< all engines currently completely suspended
130     Mutex suspendedEnginesMutex; ///< protects 'suspendedEngines' set
131 schoenebeck 53 };
132    
133     }} // namespace LinuxSampler::gig
134    
135     #endif // __LS_GIG_INSTRUMENTRESOURCEMANAGER_H__

  ViewVC Help
Powered by ViewVC