2383 |
return result.Produce(); |
return result.Produce(); |
2384 |
} |
} |
2385 |
|
|
2386 |
|
String LSCPServer::GetFileInstruments(String Filename) { |
2387 |
|
LSCPResultSet result; |
2388 |
|
// try to find a sampler engine that can handle the file |
2389 |
|
bool bFound = false; |
2390 |
|
std::vector<String> engineTypes = EngineFactory::AvailableEngineTypes(); |
2391 |
|
for (int i = 0; !bFound && i < engineTypes.size(); i++) { |
2392 |
|
Engine* pEngine = NULL; |
2393 |
|
try { |
2394 |
|
pEngine = EngineFactory::Create(engineTypes[i]); |
2395 |
|
if (!pEngine) throw Exception("Internal error: could not create '" + engineTypes[i] + "' engine"); |
2396 |
|
InstrumentManager* pManager = pEngine->GetInstrumentManager(); |
2397 |
|
if (pManager) { |
2398 |
|
std::vector<InstrumentManager::instrument_id_t> IDs = |
2399 |
|
pManager->GetInstrumentFileContent(Filename); |
2400 |
|
// return the amount of instruments in the file |
2401 |
|
result.Add(IDs.size()); |
2402 |
|
// no more need to ask other engine types |
2403 |
|
bFound = true; |
2404 |
|
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
2405 |
|
} catch (Exception e) { |
2406 |
|
// NOOP, as exception is thrown if engine doesn't support file |
2407 |
|
} |
2408 |
|
if (pEngine) EngineFactory::Destroy(pEngine); |
2409 |
|
} |
2410 |
|
return result.Produce(); |
2411 |
|
} |
2412 |
|
|
2413 |
|
String LSCPServer::ListFileInstruments(String Filename) { |
2414 |
|
LSCPResultSet result; |
2415 |
|
// try to find a sampler engine that can handle the file |
2416 |
|
bool bFound = false; |
2417 |
|
std::vector<String> engineTypes = EngineFactory::AvailableEngineTypes(); |
2418 |
|
for (int i = 0; !bFound && i < engineTypes.size(); i++) { |
2419 |
|
Engine* pEngine = NULL; |
2420 |
|
try { |
2421 |
|
pEngine = EngineFactory::Create(engineTypes[i]); |
2422 |
|
if (!pEngine) throw Exception("Internal error: could not create '" + engineTypes[i] + "' engine"); |
2423 |
|
InstrumentManager* pManager = pEngine->GetInstrumentManager(); |
2424 |
|
if (pManager) { |
2425 |
|
std::vector<InstrumentManager::instrument_id_t> IDs = |
2426 |
|
pManager->GetInstrumentFileContent(Filename); |
2427 |
|
// return a list of IDs of the instruments in the file |
2428 |
|
String s; |
2429 |
|
for (int j = 0; j < IDs.size(); j++) { |
2430 |
|
if (s.size()) s += ","; |
2431 |
|
s += ToString(IDs[j].Index); |
2432 |
|
} |
2433 |
|
result.Add(s); |
2434 |
|
// no more need to ask other engine types |
2435 |
|
bFound = true; |
2436 |
|
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
2437 |
|
} catch (Exception e) { |
2438 |
|
// NOOP, as exception is thrown if engine doesn't support file |
2439 |
|
} |
2440 |
|
if (pEngine) EngineFactory::Destroy(pEngine); |
2441 |
|
} |
2442 |
|
return result.Produce(); |
2443 |
|
} |
2444 |
|
|
2445 |
|
String LSCPServer::GetFileInstrumentInfo(String Filename, uint InstrumentID) { |
2446 |
|
LSCPResultSet result; |
2447 |
|
InstrumentManager::instrument_id_t id; |
2448 |
|
id.FileName = Filename; |
2449 |
|
id.Index = InstrumentID; |
2450 |
|
// try to find a sampler engine that can handle the file |
2451 |
|
bool bFound = false; |
2452 |
|
std::vector<String> engineTypes = EngineFactory::AvailableEngineTypes(); |
2453 |
|
for (int i = 0; !bFound && i < engineTypes.size(); i++) { |
2454 |
|
Engine* pEngine = NULL; |
2455 |
|
try { |
2456 |
|
pEngine = EngineFactory::Create(engineTypes[i]); |
2457 |
|
if (!pEngine) throw Exception("Internal error: could not create '" + engineTypes[i] + "' engine"); |
2458 |
|
InstrumentManager* pManager = pEngine->GetInstrumentManager(); |
2459 |
|
if (pManager) { |
2460 |
|
InstrumentManager::instrument_info_t info = |
2461 |
|
pManager->GetInstrumentInfo(id); |
2462 |
|
// return detailed informations about the file |
2463 |
|
result.Add("NAME", info.InstrumentName); |
2464 |
|
result.Add("FORMAT_NAME", engineTypes[i]); |
2465 |
|
result.Add("FORMAT_VERSION", info.FormatVersion); |
2466 |
|
result.Add("PRODUCT", info.Product); |
2467 |
|
result.Add("ARTISTS", info.Artists); |
2468 |
|
// no more need to ask other engine types |
2469 |
|
bFound = true; |
2470 |
|
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
2471 |
|
} catch (Exception e) { |
2472 |
|
// NOOP, as exception is thrown if engine doesn't support file |
2473 |
|
} |
2474 |
|
if (pEngine) EngineFactory::Destroy(pEngine); |
2475 |
|
} |
2476 |
|
return result.Produce(); |
2477 |
|
} |
2478 |
|
|
2479 |
/** |
/** |
2480 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
2481 |
* server for receiving event messages. |
* server for receiving event messages. |