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 - 2012 Christian Schoenebeck * |
* Copyright (C) 2005 - 2015 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 * |
69 |
* instrument ID |
* instrument ID |
70 |
*/ |
*/ |
71 |
void InstrumentResourceManager::OnInstrumentLoadingProgress(::gig::progress_t* pProgress) { |
void InstrumentResourceManager::OnInstrumentLoadingProgress(::gig::progress_t* pProgress) { |
72 |
dmsg(7,("gig::InstrumentResourceManager: progress %f%", pProgress->factor)); |
dmsg(7,("gig::InstrumentResourceManager: progress %f%%", pProgress->factor)); |
73 |
progress_callback_arg_t* pArg = static_cast<progress_callback_arg_t*>(pProgress->custom); |
progress_callback_arg_t* pArg = static_cast<progress_callback_arg_t*>(pProgress->custom); |
74 |
// we randomly schedule 90% for the .gig file loading and the remaining 10% later for sample caching |
// we randomly schedule 90% for the .gig file loading and the remaining 10% later for sample caching |
75 |
const float localProgress = 0.9f * pProgress->factor; |
const float localProgress = 0.9f * pProgress->factor; |
208 |
} |
} |
209 |
} |
} |
210 |
|
|
211 |
InstrumentEditor* InstrumentResourceManager::LaunchInstrumentEditor(instrument_id_t ID, void* pUserData) throw (InstrumentManagerException) { |
InstrumentEditor* InstrumentResourceManager::LaunchInstrumentEditor(LinuxSampler::EngineChannel* pEngineChannel, instrument_id_t ID, void* pUserData) throw (InstrumentManagerException) { |
212 |
const String sDataType = GetInstrumentDataStructureName(ID); |
const String sDataType = GetInstrumentDataStructureName(ID); |
213 |
const String sDataVersion = GetInstrumentDataStructureVersion(ID); |
const String sDataVersion = GetInstrumentDataStructureVersion(ID); |
214 |
// find instrument editors capable to handle given instrument |
// find instrument editors capable to handle given instrument |
235 |
InstrumentEditorProxies.add(pProxy); |
InstrumentEditorProxies.add(pProxy); |
236 |
InstrumentEditorProxiesMutex.Unlock(); |
InstrumentEditorProxiesMutex.Unlock(); |
237 |
// launch the instrument editor for the given instrument |
// launch the instrument editor for the given instrument |
238 |
pEditor->Launch(pInstrument, sDataType, sDataVersion, pUserData); |
pEditor->Launch(pEngineChannel, pInstrument, sDataType, sDataVersion, pUserData); |
239 |
|
|
240 |
// register the instrument editor as virtual MIDI device as well ... |
// register the instrument editor as virtual MIDI device as well ... |
241 |
VirtualMidiDevice* pVirtualMidiDevice = |
VirtualMidiDevice* pVirtualMidiDevice = |
271 |
int iProxyIndex = -1; |
int iProxyIndex = -1; |
272 |
|
|
273 |
// first find the editor proxy entry for this editor |
// first find the editor proxy entry for this editor |
274 |
InstrumentEditorProxiesMutex.Lock(); |
{ |
275 |
for (int i = 0; i < InstrumentEditorProxies.size(); i++) { |
LockGuard lock(InstrumentEditorProxiesMutex); |
276 |
InstrumentEditorProxy* pCurProxy = |
for (int i = 0; i < InstrumentEditorProxies.size(); i++) { |
277 |
dynamic_cast<InstrumentEditorProxy*>( |
InstrumentEditorProxy* pCurProxy = |
278 |
InstrumentEditorProxies[i] |
dynamic_cast<InstrumentEditorProxy*>( |
279 |
); |
InstrumentEditorProxies[i] |
280 |
if (pCurProxy->pEditor == pSender) { |
); |
281 |
pProxy = pCurProxy; |
if (pCurProxy->pEditor == pSender) { |
282 |
iProxyIndex = i; |
pProxy = pCurProxy; |
283 |
pInstrument = pCurProxy->pInstrument; |
iProxyIndex = i; |
284 |
|
pInstrument = pCurProxy->pInstrument; |
285 |
|
} |
286 |
} |
} |
287 |
} |
} |
|
InstrumentEditorProxiesMutex.Unlock(); |
|
288 |
|
|
289 |
if (!pProxy) { |
if (!pProxy) { |
290 |
std::cerr << "Eeeek, could not find instrument editor proxy, " |
std::cerr << "Eeeek, could not find instrument editor proxy, " |
312 |
|
|
313 |
// finally delete proxy entry and hand back instrument |
// finally delete proxy entry and hand back instrument |
314 |
if (pInstrument) { |
if (pInstrument) { |
315 |
InstrumentEditorProxiesMutex.Lock(); |
{ |
316 |
InstrumentEditorProxies.remove(iProxyIndex); |
LockGuard lock(InstrumentEditorProxiesMutex); |
317 |
InstrumentEditorProxiesMutex.Unlock(); |
InstrumentEditorProxies.remove(iProxyIndex); |
318 |
|
} |
319 |
|
|
320 |
HandBack(pInstrument, pProxy); |
HandBack(pInstrument, pProxy); |
321 |
delete pProxy; |
delete pProxy; |
676 |
const uint neededSilenceSamples = (maxSamplesPerCycle << CONFIG_MAX_PITCH) + 3; |
const uint neededSilenceSamples = (maxSamplesPerCycle << CONFIG_MAX_PITCH) + 3; |
677 |
const uint currentlyCachedSilenceSamples = pSample->GetCache().NullExtensionSize / pSample->FrameSize; |
const uint currentlyCachedSilenceSamples = pSample->GetCache().NullExtensionSize / pSample->FrameSize; |
678 |
if (currentlyCachedSilenceSamples < neededSilenceSamples) { |
if (currentlyCachedSilenceSamples < neededSilenceSamples) { |
679 |
dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %d)\n", pSample->pInfo->Name.c_str(), pSample->SamplesTotal)); |
dmsg(3,("Caching whole sample (sample name: \"%s\", sample size: %lu)\n", pSample->pInfo->Name.c_str(), pSample->SamplesTotal)); |
680 |
::gig::buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(neededSilenceSamples); |
::gig::buffer_t buf = pSample->LoadSampleDataWithNullSamplesExtension(neededSilenceSamples); |
681 |
dmsg(4,("Cached %d Bytes, %d silence bytes.\n", buf.Size, buf.NullExtensionSize)); |
dmsg(4,("Cached %lu Bytes, %lu silence bytes.\n", buf.Size, buf.NullExtensionSize)); |
682 |
} |
} |
683 |
} |
} |
684 |
else { // we only cache CONFIG_PRELOAD_SAMPLES and stream the other sample points from disk |
else { // we only cache CONFIG_PRELOAD_SAMPLES and stream the other sample points from disk |
689 |
} |
} |
690 |
|
|
691 |
void InstrumentResourceManager::UncacheInitialSamples(::gig::Sample* pSample) { |
void InstrumentResourceManager::UncacheInitialSamples(::gig::Sample* pSample) { |
692 |
dmsg(1,("Uncaching sample %x\n",pSample)); |
dmsg(1,("Uncaching sample %p\n",(void*)pSample)); |
693 |
if (pSample->GetCache().Size) pSample->ReleaseSampleData(); |
if (pSample->GetCache().Size) pSample->ReleaseSampleData(); |
694 |
} |
} |
695 |
|
|