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 - 2007 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 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 * |
115 |
return ::gig::libraryVersion(); |
return ::gig::libraryVersion(); |
116 |
} |
} |
117 |
|
|
118 |
|
std::vector<InstrumentResourceManager::instrument_id_t> InstrumentResourceManager::GetInstrumentFileContent(String File) throw (InstrumentManagerException) { |
119 |
|
::RIFF::File* riff = NULL; |
120 |
|
::gig::File* gig = NULL; |
121 |
|
try { |
122 |
|
std::vector<instrument_id_t> result; |
123 |
|
riff = new ::RIFF::File(File); |
124 |
|
gig = new ::gig::File(riff); |
125 |
|
gig->SetAutoLoad(false); // avoid time consuming samples scanning |
126 |
|
for (int i = 0; gig->GetInstrument(i); i++) { |
127 |
|
instrument_id_t id; |
128 |
|
id.FileName = File; |
129 |
|
id.Index = i; |
130 |
|
result.push_back(id); |
131 |
|
} |
132 |
|
if (gig) delete gig; |
133 |
|
if (riff) delete riff; |
134 |
|
return result; |
135 |
|
} catch (::RIFF::Exception e) { |
136 |
|
if (gig) delete gig; |
137 |
|
if (riff) delete riff; |
138 |
|
throw InstrumentManagerException(e.Message); |
139 |
|
} catch (...) { |
140 |
|
if (gig) delete gig; |
141 |
|
if (riff) delete riff; |
142 |
|
throw InstrumentManagerException("Unknown exception while trying to parse '" + File + "'"); |
143 |
|
} |
144 |
|
} |
145 |
|
|
146 |
|
InstrumentResourceManager::instrument_info_t InstrumentResourceManager::GetInstrumentInfo(instrument_id_t ID) throw (InstrumentManagerException) { |
147 |
|
std::vector<instrument_id_t> result; |
148 |
|
::RIFF::File* riff = NULL; |
149 |
|
::gig::File* gig = NULL; |
150 |
|
try { |
151 |
|
riff = new ::RIFF::File(ID.FileName); |
152 |
|
gig = new ::gig::File(riff); |
153 |
|
gig->SetAutoLoad(false); // avoid time consuming samples scanning |
154 |
|
::gig::Instrument* pInstrument = gig->GetInstrument(ID.Index); |
155 |
|
if (!pInstrument) throw InstrumentManagerException("There is no instrument " + ToString(ID.Index) + " in " + ID.FileName); |
156 |
|
instrument_info_t info; |
157 |
|
if (gig->pVersion) { |
158 |
|
info.FormatVersion = ToString(gig->pVersion->major); |
159 |
|
info.Product = gig->pInfo->Product; |
160 |
|
info.Artists = gig->pInfo->Artists; |
161 |
|
} |
162 |
|
info.InstrumentName = pInstrument->pInfo->Name; |
163 |
|
if (gig) delete gig; |
164 |
|
if (riff) delete riff; |
165 |
|
return info; |
166 |
|
} catch (::RIFF::Exception e) { |
167 |
|
if (gig) delete gig; |
168 |
|
if (riff) delete riff; |
169 |
|
throw InstrumentManagerException(e.Message); |
170 |
|
} catch (...) { |
171 |
|
if (gig) delete gig; |
172 |
|
if (riff) delete riff; |
173 |
|
throw InstrumentManagerException("Unknown exception while trying to parse '" + ID.FileName + "'"); |
174 |
|
} |
175 |
|
} |
176 |
|
|
177 |
void InstrumentResourceManager::LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException) { |
void InstrumentResourceManager::LaunchInstrumentEditor(instrument_id_t ID) throw (InstrumentManagerException) { |
178 |
const String sDataType = GetInstrumentDataStructureName(ID); |
const String sDataType = GetInstrumentDataStructureName(ID); |
179 |
const String sDataVersion = GetInstrumentDataStructureVersion(ID); |
const String sDataVersion = GetInstrumentDataStructureVersion(ID); |
463 |
* Give back an instrument. This should be used instead of |
* Give back an instrument. This should be used instead of |
464 |
* HandBack if there are some dimension regions that are still in |
* HandBack if there are some dimension regions that are still in |
465 |
* use. (When an instrument is changed, the voices currently |
* use. (When an instrument is changed, the voices currently |
466 |
* playing is allowed to keep playing with the old instrument |
* playing are allowed to keep playing with the old instrument |
467 |
* until note off arrives. New notes will use the new instrument.) |
* until note off arrives. New notes will use the new instrument.) |
468 |
*/ |
*/ |
469 |
void InstrumentResourceManager::HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
void InstrumentResourceManager::HandBackInstrument(::gig::Instrument* pResource, InstrumentConsumer* pConsumer, |
470 |
::gig::DimensionRegion** dimRegionsInUse) { |
RTList< ::gig::DimensionRegion*>* pDimRegionsInUse) { |
471 |
DimRegInfoMutex.Lock(); |
DimRegInfoMutex.Lock(); |
472 |
for (int i = 0 ; dimRegionsInUse[i] ; i++) { |
for (RTList< ::gig::DimensionRegion*>::Iterator i = pDimRegionsInUse->first() ; i != pDimRegionsInUse->end() ; i++) { |
473 |
DimRegInfo[dimRegionsInUse[i]].refCount++; |
DimRegInfo[*i].refCount++; |
474 |
SampleRefCount[dimRegionsInUse[i]->pSample]++; |
SampleRefCount[(*i)->pSample]++; |
475 |
} |
} |
476 |
HandBack(pResource, pConsumer, true); |
HandBack(pResource, pConsumer, true); |
477 |
DimRegInfoMutex.Unlock(); |
DimRegInfoMutex.Unlock(); |