77 |
SetAvailabilityMode(ID, static_cast<ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument>::mode_t>(Mode)); |
SetAvailabilityMode(ID, static_cast<ResourceManager<InstrumentManager::instrument_id_t, ::gig::Instrument>::mode_t>(Mode)); |
78 |
} |
} |
79 |
|
|
|
float InstrumentResourceManager::GetVolume(const instrument_id_t& ID) { |
|
|
void* pCustomData = CustomData(ID); |
|
|
const float fVolume = (pCustomData) ? *((float*)pCustomData) /* stored value */ : 1.0f /* default value */; |
|
|
return fVolume; |
|
|
} |
|
|
|
|
|
void InstrumentResourceManager::SetVolume(const instrument_id_t& ID, float Volume) { |
|
|
void* pCustomData = CustomData(ID); |
|
|
if (Volume == 1.0f) { // if default volume ... |
|
|
if (pCustomData) { // ... delete volume entry if necessary |
|
|
delete (float*)pCustomData; |
|
|
SetCustomData(ID, NULL); |
|
|
} |
|
|
} else { // if not default volume |
|
|
if (!pCustomData) { // create volume entry if necessary |
|
|
pCustomData = new float; |
|
|
SetCustomData(ID, pCustomData); |
|
|
} |
|
|
*((float*)pCustomData) = Volume; |
|
|
} |
|
|
} |
|
|
|
|
80 |
String InstrumentResourceManager::GetInstrumentName(instrument_id_t ID) { |
String InstrumentResourceManager::GetInstrumentName(instrument_id_t ID) { |
81 |
return ""; // TODO: ... |
::gig::Instrument* pInstrument = Resource(ID); |
82 |
|
return (pInstrument) ? pInstrument->pInfo->Name : ""; |
83 |
} |
} |
84 |
|
|
85 |
::gig::Instrument* InstrumentResourceManager::Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg) { |
::gig::Instrument* InstrumentResourceManager::Create(instrument_id_t Key, InstrumentConsumer* pConsumer, void*& pArg) { |
146 |
|
|
147 |
void InstrumentResourceManager::Destroy( ::gig::Instrument* pResource, void* pArg) { |
void InstrumentResourceManager::Destroy( ::gig::Instrument* pResource, void* pArg) { |
148 |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
instr_entry_t* pEntry = (instr_entry_t*) pArg; |
|
// remove volume entry if necessary |
|
|
void* pCustomData = CustomData(pEntry->ID); |
|
|
if (pCustomData) { |
|
|
delete (float*)pCustomData; |
|
|
SetCustomData(pEntry->ID, NULL); |
|
|
} |
|
149 |
// we don't need the .gig file here anymore |
// we don't need the .gig file here anymore |
150 |
Gigs.HandBack(pEntry->pGig, (GigConsumer*) pEntry->ID.Index); // conversion kinda hackish :/ |
Gigs.HandBack(pEntry->pGig, (GigConsumer*) pEntry->ID.Index); // conversion kinda hackish :/ |
151 |
delete pEntry; |
delete pEntry; |