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 * |
181 |
pEntry->ID.Index = Key.Index; |
pEntry->ID.Index = Key.Index; |
182 |
pEntry->pSf2 = pSf2; |
pEntry->pSf2 = pSf2; |
183 |
|
|
184 |
|
// (try to resolve the audio device context) |
185 |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
186 |
|
AudioOutputDevice* pDevice = |
187 |
|
(pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL; |
188 |
|
|
189 |
// 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' |
190 |
pEntry->MaxSamplesPerCycle = |
pEntry->MaxSamplesPerCycle = |
191 |
(!pEngineChannel) ? 0 /* don't care for instrument editors */ : |
(pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle(); |
192 |
(pEngineChannel->GetEngine()) ? |
|
|
dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle() |
|
|
: GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE; |
|
193 |
pArg = pEntry; |
pArg = pEntry; |
194 |
|
|
195 |
return pInstrument; |
return pInstrument; |
204 |
|
|
205 |
void InstrumentResourceManager::OnBorrow(::sf2::Preset* pResource, InstrumentConsumer* pConsumer, void*& pArg) { |
void InstrumentResourceManager::OnBorrow(::sf2::Preset* pResource, InstrumentConsumer* pConsumer, void*& pArg) { |
206 |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
207 |
|
|
208 |
|
// (try to resolve the audio device context) |
209 |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
EngineChannel* pEngineChannel = dynamic_cast<EngineChannel*>(pConsumer); |
210 |
|
AudioOutputDevice* pDevice = |
211 |
|
(pEngineChannel) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice : NULL; |
212 |
|
|
213 |
uint maxSamplesPerCycle = |
uint maxSamplesPerCycle = |
214 |
(pEngineChannel && pEngineChannel->GetEngine()) ? dynamic_cast<Engine*>(pEngineChannel->GetEngine())->pAudioOutputDevice->MaxSamplesPerCycle() |
(pDevice) ? pDevice->MaxSamplesPerCycle() : DefaultMaxSamplesPerCycle(); |
215 |
: GIG_RESOURCE_MANAGER_DEFAULT_MAX_SAMPLES_PER_CYCLE; |
|
216 |
if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) { |
if (pEntry->MaxSamplesPerCycle < maxSamplesPerCycle) { |
217 |
|
dmsg(1,("Completely reloading instrument due to insufficient precached samples ...\n")); |
218 |
Update(pResource, pConsumer); |
Update(pResource, pConsumer); |
219 |
} |
} |
220 |
} |
} |