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 - 2009 Christian Schoenebeck * |
* Copyright (C) 2005 - 2011 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2011 Grigor Iliev * |
* Copyright (C) 2009 - 2011 Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
144 |
pEntry->ID.Index = Key.Index; |
pEntry->ID.Index = Key.Index; |
145 |
pEntry->pSfz = pSfz; |
pEntry->pSfz = pSfz; |
146 |
|
|
147 |
|
// (try to resolve the audio device context) |
148 |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
149 |
|
AudioOutputDevice* pDevice = |
150 |
|
(pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL; |
151 |
|
|
152 |
// and we save this to check if we need to reallocate for a engine with higher value of 'MaxSamplesPerSecond' |
// and we save this to check if we need to reallocate for a engine with higher value of 'MaxSamplesPerSecond' |
153 |
pEntry->MaxSamplesPerCycle = |
pEntry->MaxSamplesPerCycle = |
154 |
(!pEngineChannel) ? 0 /* don't care for instrument editors */ : |
(pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle(); |
155 |
(pEngineChannel->GetEngine()) ? |
|
|
dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle() |
|
|
: GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE; |
|
156 |
pArg = pEntry; |
pArg = pEntry; |
157 |
|
|
158 |
return pInstrument; |
return pInstrument; |
167 |
|
|
168 |
void InstrumentResourceManager::OnBorrow(::sfz::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg) { |
void InstrumentResourceManager::OnBorrow(::sfz::Instrument* pResource, InstrumentConsumer* pConsumer, void*& pArg) { |
169 |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
170 |
|
|
171 |
|
// (try to resolve the audio device context) |
172 |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
173 |
|
AudioOutputDevice* pDevice = |
174 |
|
(pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL; |
175 |
|
|
176 |
uint maxSamplesPerCycle = |
uint maxSamplesPerCycle = |
177 |
(pEngineChannel && pEngineChannel->GetEngine()) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle() |
(pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle(); |
178 |
: GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE; |
|
179 |
if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) { |
if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) { |
180 |
|
dmsg(1,("Completely reloading instrument due to insufficient precached samples ...\n")); |
181 |
Update(pResource, pConsumer); |
Update(pResource, pConsumer); |
182 |
} |
} |
183 |
} |
} |