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); |