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 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 * |
30 |
# warning InstrumentResourceManager.h included |
# warning InstrumentResourceManager.h included |
31 |
#endif // DEBUG_HEADERS |
#endif // DEBUG_HEADERS |
32 |
|
|
33 |
|
#include <gig.h> |
34 |
|
|
35 |
#include "../../common/global.h" |
#include "../../common/global.h" |
36 |
#include "../../common/LinuxSamplerException.h" |
#include "../../common/LinuxSamplerException.h" |
37 |
#include "../../common/ResourceManager.h" |
#include "../../common/ResourceManager.h" |
38 |
#include "../../drivers/audio/AudioOutputDevice.h" |
#include "../../drivers/audio/AudioOutputDevice.h" |
|
#include "../../lib/fileloader/libgig/gig.h" |
|
39 |
|
|
40 |
// preload 64k samples = 128kB of data in RAM for 16 bit mono samples |
// preload 64k samples = 128kB of data in RAM for 16 bit mono samples |
41 |
#define NUM_RAM_PRELOAD_SAMPLES 32768 |
#define NUM_RAM_PRELOAD_SAMPLES 32768 |
48 |
|
|
49 |
}} // namespace LinuxSampler::gig |
}} // namespace LinuxSampler::gig |
50 |
|
|
51 |
|
#include "EngineChannel.h" |
52 |
#include "Engine.h" |
#include "Engine.h" |
53 |
|
|
54 |
namespace LinuxSampler { namespace gig { |
namespace LinuxSampler { namespace gig { |
55 |
|
|
56 |
// just symbol prototyping |
// just symbol prototyping |
57 |
class Engine; |
class EngineChannel; |
58 |
|
|
59 |
/** |
/** |
60 |
* Explicitly identifies a Gigasampler instrument. |
* Explicitly identifies a Gigasampler instrument. |
72 |
/** Gig instrument manager |
/** Gig instrument manager |
73 |
* |
* |
74 |
* Manager to share gig instruments between multiple Gigasampler |
* Manager to share gig instruments between multiple Gigasampler |
75 |
* engines. The engines Borrow() instruments when they need them and |
* engine channels. The engine channels Borrow() instruments when they |
76 |
* HandBack() when they don't need them anymore. The |
* need them and HandBack() when they don't need them anymore. The |
77 |
* InstrumentResourceManager loads the corresponding gig file and gig |
* InstrumentResourceManager loads the corresponding gig file and gig |
78 |
* 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 |
79 |
* it just returns the same resource, if an gig instrument / file is not |
* channel, then it just returns the same resource, if an gig |
80 |
* 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 |
81 |
|
* it will be freed from memory. |
82 |
*/ |
*/ |
83 |
class InstrumentResourceManager : public ResourceManager<instrument_id_t, ::gig::Instrument> { |
class InstrumentResourceManager : public ResourceManager<instrument_id_t, ::gig::Instrument> { |
84 |
public: |
public: |
85 |
virtual ~InstrumentResourceManager() {} |
virtual ~InstrumentResourceManager() {} |
86 |
protected: |
protected: |
87 |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
virtual ::gig::Instrument* Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg); |
88 |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
virtual void Destroy(::gig::Instrument* pResource, void* pArg); |
101 |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
virtual ::gig::File* Create(String Key, GigConsumer* pConsumer, void*& pArg); |
102 |
virtual void Destroy(::gig::File* pResource, void* pArg); |
virtual void Destroy(::gig::File* pResource, void* pArg); |
103 |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
virtual void OnBorrow(::gig::File* pResource, GigConsumer* pConsumer, void*& pArg) {} // ignore |
104 |
public: |
public: |
105 |
virtual ~GigResourceManager() {} |
virtual ~GigResourceManager() {} |
106 |
} Gigs; |
} Gigs; |
107 |
|
|
108 |
void CacheInitialSamples(::gig::Sample* pSample, gig::Engine* pEngine); |
void CacheInitialSamples(::gig::Sample* pSample, gig::EngineChannel* pEngineChannel); |
109 |
}; |
}; |
110 |
|
|
111 |
/** |
/** |