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, 2006 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 * |
26 |
|
|
27 |
#include "../../common/global.h" |
#include "../../common/global.h" |
28 |
|
|
29 |
#if DEBUG_HEADERS |
#include <gig.h> |
|
# warning InstrumentResourceManager.h included |
|
|
#endif // DEBUG_HEADERS |
|
30 |
|
|
31 |
#include "../../common/global.h" |
#include "../../common/global.h" |
32 |
#include "../../common/LinuxSamplerException.h" |
#include "../../common/Exception.h" |
33 |
#include "../../common/ResourceManager.h" |
#include "../../common/ResourceManager.h" |
34 |
#include "../../audiodriver/AudioOutputDevice.h" |
#include "../../drivers/audio/AudioOutputDevice.h" |
|
#include "../../lib/fileloader/libgig/gig.h" |
|
|
|
|
|
// preload 64k samples = 128kB of data in RAM for 16 bit mono samples |
|
|
#define NUM_RAM_PRELOAD_SAMPLES 32768 |
|
35 |
|
|
36 |
//namespace libgig = gig; |
//namespace libgig = gig; |
37 |
|
|
41 |
|
|
42 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |
43 |
|
|
44 |
|
#include "EngineChannel.h" |
45 |
#include "Engine.h" |
#include "Engine.h" |
46 |
|
|
47 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
48 |
|
|
49 |
// just symbol prototyping |
// just symbol prototyping |
50 |
class Engine; |
class EngineChannel; |
51 |
|
|
52 |
/** |
/** |
53 |
* Explicitly identifies a Gigasampler instrument. |
* Explicitly identifies a Gigasampler instrument. |
65 |
/** Gig instrument manager |
/** Gig instrument manager |
66 |
* |
* |
67 |
* Manager to share gig instruments between multiple Gigasampler |
* Manager to share gig instruments between multiple Gigasampler |
68 |
* engines. The engines Borrow() instruments when they need them and |
* engine channels. The engine channels Borrow() instruments when they |
69 |
* HandBack() when they don't need them anymore. The |
* need them and HandBack() when they don't need them anymore. The |
70 |
* InstrumentResourceManager loads the corresponding gig file and gig |
* InstrumentResourceManager loads the corresponding gig file and gig |
71 |
* instrument if needed, if it's already in use by another engine, then |
* instrument if needed, if it's already in use by another engine |
72 |
* it just returns the same resource, if an gig instrument / file is not |
* channel, then it just returns the same resource, if an gig |
73 |
* in use by any engine anymore, then it will be freed from memory. |
* instrument / file is not in use by any engine channel anymore, then |
74 |
|
* it will be freed from memory. |
75 |
*/ |
*/ |
76 |
class InstrumentResourceManager : public ResourceManager<instrument_id_t, ::gig::Instrument> { |
class InstrumentResourceManager : public ResourceManager<instrument_id_t, ::gig::Instrument> { |
77 |
|
public: |
78 |
|
virtual ~InstrumentResourceManager() {} |
79 |
|
static void OnInstrumentLoadingProgress(::gig::progress_t* pProgress); |
80 |
protected: |
protected: |
81 |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
82 |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
95 |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
96 |
virtual void Destroy(::gig::File* pResource, void* pArg); |
virtual void Destroy(::gig::File* pResource, void* pArg); |
97 |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
98 |
|
public: |
99 |
|
virtual ~GigResourceManager() {} |
100 |
} Gigs; |
} Gigs; |
101 |
|
|
102 |
void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine); |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
103 |
}; |
}; |
104 |
|
|
105 |
/** |
/** |
106 |
* Will be thrown by the InstrumentResourceManager on errors. |
* Will be thrown by the InstrumentResourceManager on errors. |
107 |
*/ |
*/ |
108 |
class InstrumentResourceManagerException : public LinuxSamplerException { |
class InstrumentResourceManagerException : public Exception { |
109 |
public: |
public: |
110 |
InstrumentResourceManagerException(String msg) : LinuxSamplerException(msg) {} |
InstrumentResourceManagerException(String msg) : Exception(msg) {} |
111 |
}; |
}; |
112 |
|
|
113 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |