3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* 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 * |
* it under the terms of the GNU General Public License as published by * |
32 |
#include "../../common/ResourceManager.h" |
#include "../../common/ResourceManager.h" |
33 |
#include "../../drivers/audio/AudioOutputDevice.h" |
#include "../../drivers/audio/AudioOutputDevice.h" |
34 |
#include "../InstrumentManager.h" |
#include "../InstrumentManager.h" |
35 |
|
#include "../../common/ArrayList.h" |
36 |
|
|
37 |
//namespace libgig = gig; |
//namespace libgig = gig; |
38 |
|
|
44 |
|
|
45 |
#include "EngineChannel.h" |
#include "EngineChannel.h" |
46 |
#include "Engine.h" |
#include "Engine.h" |
47 |
#include "../InstrumentEditor.h" |
#include "../../plugins/InstrumentEditor.h" |
48 |
|
|
49 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
50 |
|
|
51 |
// just symbol prototyping |
// just symbol prototyping |
52 |
class EngineChannel; |
class EngineChannel; |
53 |
|
class Engine; |
54 |
|
|
55 |
/** @brief Gig instrument manager |
/** @brief Gig instrument manager |
56 |
* |
* |
74 |
virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); |
virtual InstrumentManager::mode_t GetMode(const instrument_id_t& ID); |
75 |
virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); |
virtual void SetMode(const instrument_id_t& ID, InstrumentManager::mode_t Mode); |
76 |
virtual String GetInstrumentName(instrument_id_t ID); |
virtual String GetInstrumentName(instrument_id_t ID); |
77 |
virtual String GetInstrumentTypeName(instrument_id_t ID); |
virtual String GetInstrumentDataStructureName(instrument_id_t ID); |
78 |
virtual String GetInstrumentTypeVersion(instrument_id_t ID); |
virtual String GetInstrumentDataStructureVersion(instrument_id_t ID); |
79 |
virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException); |
virtual void LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException); |
80 |
|
virtual std::vector<instrument_id_t> GetInstrumentFileContent(String File) throw (InstrumentManagerException); |
81 |
|
virtual instrument_info_t GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException); |
82 |
|
|
83 |
// implementation of derived abstract method from 'InstrumentEditorListener' |
// implementation of derived abstract methods from 'InstrumentEditorListener' |
84 |
virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender); |
virtual void OnInstrumentEditorQuit(InstrumentEditor* pSender); |
85 |
|
virtual void OnSamplesToBeRemoved(std::set<void*> Samples, InstrumentEditor* pSender); |
86 |
|
virtual void OnSamplesRemoved(InstrumentEditor* pSender); |
87 |
|
virtual void OnDataStructureToBeChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); |
88 |
|
virtual void OnDataStructureChanged(void* pStruct, String sStructType, InstrumentEditor* pSender); |
89 |
|
virtual void OnSampleReferenceChanged(void* pOldSample, void* pNewSample, InstrumentEditor* pSender); |
90 |
|
|
91 |
void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
void HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
92 |
::gig::DimensionRegion** dimRegionsInUse); |
RTList< ::gig::DimensionRegion*>* pDimRegionsInUse); |
93 |
void HandBackDimReg(::gig::DimensionRegion* pDimReg); |
void HandBackDimReg(::gig::DimensionRegion* pDimReg); |
94 |
|
|
95 |
|
void TrySendNoteOnToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
96 |
|
void TrySendNoteOffToEditors(uint8_t Key, uint8_t Velocity, ::gig::Instrument* pInstrument); |
97 |
|
|
98 |
protected: |
protected: |
99 |
|
// implementation of derived abstract methods from 'ResourceManager' |
100 |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
101 |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
102 |
virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg); |
virtual void OnBorrow(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg); |
105 |
|
|
106 |
class GigResourceManager : public ResourceManager<String, ::gig::File> { |
class GigResourceManager : public ResourceManager<String, ::gig::File> { |
107 |
protected: |
protected: |
108 |
|
// implementation of derived abstract methods from 'ResourceManager' |
109 |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
110 |
virtual void Destroy(::gig::File* pResource, void* pArg); |
virtual void Destroy(::gig::File* pResource, void* pArg); |
111 |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
117 |
} Gigs; |
} Gigs; |
118 |
|
|
119 |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
120 |
|
void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine); |
121 |
|
void UncacheInitialSamples(::gig::Sample* pSample); |
122 |
|
std::vector< ::gig::Instrument*> GetInstrumentsCurrentlyUsedOf(::gig::File* pFile, bool bLock); |
123 |
|
std::set<gig::Engine*> GetEnginesUsing(::gig::Instrument* pFile, bool bLock); |
124 |
|
std::set<gig::Engine*> GetEnginesUsing(::gig::File* pFile, bool bLock); |
125 |
|
bool SampleReferencedByInstrument(::gig::Sample* pSample, ::gig::Instrument* pInstrument); |
126 |
|
void SuspendEnginesUsing(::gig::Instrument* pInstrument); |
127 |
|
void SuspendEnginesUsing(::gig::File* pFile); |
128 |
|
void ResumeAllEngines(); |
129 |
|
|
130 |
struct dimreg_info_t { |
struct dimreg_info_t { |
131 |
int refCount; |
int refCount; |
137 |
std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument |
std::map< ::gig::Sample*, int> SampleRefCount; ///< contains samples that are still in use but belong to a released instrument |
138 |
|
|
139 |
Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map |
Mutex InstrumentEditorProxiesMutex; ///< protects the 'InstrumentEditorProxies' map |
140 |
std::map<InstrumentEditor*, InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor |
ArrayList<InstrumentConsumer*> InstrumentEditorProxies; ///< here we store the objects that react on instrument specific notifications on behalf of the respective instrument editor |
141 |
|
std::set<Engine*> suspendedEngines; ///< all engines currently completely suspended |
142 |
|
Mutex suspendedEnginesMutex; ///< protects 'suspendedEngines' set |
143 |
}; |
}; |
144 |
|
|
145 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |