84 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_info, "DB_INSTRUMENT_DIRECTORY_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_dir_info, "DB_INSTRUMENT_DIRECTORY_INFO"); |
85 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_count, "DB_INSTRUMENT_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_count, "DB_INSTRUMENT_COUNT"); |
86 |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instr_info, "DB_INSTRUMENT_INFO"); |
87 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_db_instrs_job_info, "DB_INSTRUMENTS_JOB_INFO"); |
88 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
89 |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
90 |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
165 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentInfoChanged(String Instr) { |
166 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, Instr)); |
167 |
} |
} |
168 |
|
|
169 |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
void LSCPServer::DbInstrumentsEventHandler::InstrumentNameChanged(String Instr, String NewName) { |
170 |
Instr = "'" + Instr + "'"; |
Instr = "'" + Instr + "'"; |
171 |
NewName = "'" + NewName + "'"; |
NewName = "'" + NewName + "'"; |
172 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instr_info, "NAME", Instr, NewName)); |
173 |
} |
} |
174 |
|
|
175 |
|
void LSCPServer::DbInstrumentsEventHandler::JobStatusChanged(int JobId) { |
176 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_db_instrs_job_info, JobId)); |
177 |
|
} |
178 |
#endif // HAVE_SQLITE3 |
#endif // HAVE_SQLITE3 |
179 |
|
|
180 |
|
|
2158 |
return result.Produce(); |
return result.Produce(); |
2159 |
} |
} |
2160 |
|
|
2161 |
|
String LSCPServer::EditSamplerChannelInstrument(uint uiSamplerChannel) { |
2162 |
|
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
2163 |
|
LSCPResultSet result; |
2164 |
|
try { |
2165 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2166 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2167 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2168 |
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
2169 |
|
Engine* pEngine = pEngineChannel->GetEngine(); |
2170 |
|
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
2171 |
|
if (!pInstrumentManager) throw Exception("Engine does not provide an instrument manager"); |
2172 |
|
InstrumentManager::instrument_id_t instrumentID; |
2173 |
|
instrumentID.FileName = pEngineChannel->InstrumentFileName(); |
2174 |
|
instrumentID.Index = pEngineChannel->InstrumentIndex(); |
2175 |
|
pInstrumentManager->LaunchInstrumentEditor(instrumentID); |
2176 |
|
} catch (Exception e) { |
2177 |
|
result.Error(e); |
2178 |
|
} |
2179 |
|
return result.Produce(); |
2180 |
|
} |
2181 |
|
|
2182 |
/** |
/** |
2183 |
* Will be called by the parser to reset a particular sampler channel. |
* Will be called by the parser to reset a particular sampler channel. |
2184 |
*/ |
*/ |
2438 |
return result.Produce(); |
return result.Produce(); |
2439 |
} |
} |
2440 |
|
|
2441 |
String LSCPServer::AddDbInstruments(String DbDir, String FilePath, int Index) { |
String LSCPServer::AddDbInstruments(String DbDir, String FilePath, int Index, bool bBackground) { |
2442 |
dmsg(2,("LSCPServer: AddDbInstruments(DbDir=%s,FilePath=%s,Index=%d)\n", DbDir.c_str(), FilePath.c_str(), Index)); |
dmsg(2,("LSCPServer: AddDbInstruments(DbDir=%s,FilePath=%s,Index=%d,bBackground=%d)\n", DbDir.c_str(), FilePath.c_str(), Index, bBackground)); |
|
LSCPResultSet result; |
|
|
#if HAVE_SQLITE3 |
|
|
try { |
|
|
InstrumentsDb::GetInstrumentsDb()->AddInstruments(DbDir, FilePath, Index); |
|
|
} catch (Exception e) { |
|
|
result.Error(e); |
|
|
} |
|
|
#else |
|
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
|
|
#endif |
|
|
return result.Produce(); |
|
|
} |
|
|
|
|
|
String LSCPServer::AddDbInstrumentsFlat(String DbDir, String FsDir) { |
|
|
dmsg(2,("LSCPServer: AddDbInstrumentsFlat(DbDir=%s,FilePath=%s)\n", DbDir.c_str(), FsDir.c_str())); |
|
2443 |
LSCPResultSet result; |
LSCPResultSet result; |
2444 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2445 |
try { |
try { |
2446 |
InstrumentsDb::GetInstrumentsDb()->AddInstrumentsRecursive(DbDir, FsDir, true); |
int id; |
2447 |
|
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
2448 |
|
id = db->AddInstruments(DbDir, FilePath, Index, bBackground); |
2449 |
|
if (bBackground) result = id; |
2450 |
} catch (Exception e) { |
} catch (Exception e) { |
2451 |
result.Error(e); |
result.Error(e); |
2452 |
} |
} |
2456 |
return result.Produce(); |
return result.Produce(); |
2457 |
} |
} |
2458 |
|
|
2459 |
String LSCPServer::AddDbInstrumentsNonrecursive(String DbDir, String FsDir) { |
String LSCPServer::AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground) { |
2460 |
dmsg(2,("LSCPServer: AddDbInstrumentsNonrecursive(DbDir=%s,FilePath=%s)\n", DbDir.c_str(), FsDir.c_str())); |
dmsg(2,("LSCPServer: AddDbInstruments(ScanMode=%s,DbDir=%s,FsDir=%s,bBackground=%d)\n", ScanMode.c_str(), DbDir.c_str(), FsDir.c_str(), bBackground)); |
2461 |
LSCPResultSet result; |
LSCPResultSet result; |
2462 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2463 |
try { |
try { |
2464 |
InstrumentsDb::GetInstrumentsDb()->AddInstrumentsNonrecursive(DbDir, FsDir); |
int id; |
2465 |
|
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
2466 |
|
if (ScanMode.compare("RECURSIVE") == 0) { |
2467 |
|
id = db->AddInstruments(RECURSIVE, DbDir, FsDir, bBackground); |
2468 |
|
} else if (ScanMode.compare("NON_RECURSIVE") == 0) { |
2469 |
|
id = db->AddInstruments(NON_RECURSIVE, DbDir, FsDir, bBackground); |
2470 |
|
} else if (ScanMode.compare("FLAT") == 0) { |
2471 |
|
id = db->AddInstruments(FLAT, DbDir, FsDir, bBackground); |
2472 |
|
} else { |
2473 |
|
throw Exception("Unknown scan mode: " + ScanMode); |
2474 |
|
} |
2475 |
|
|
2476 |
|
if (bBackground) result = id; |
2477 |
} catch (Exception e) { |
} catch (Exception e) { |
2478 |
result.Error(e); |
result.Error(e); |
2479 |
} |
} |
2558 |
} catch (Exception e) { |
} catch (Exception e) { |
2559 |
result.Error(e); |
result.Error(e); |
2560 |
} |
} |
2561 |
|
#else |
2562 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2563 |
|
#endif |
2564 |
|
return result.Produce(); |
2565 |
|
} |
2566 |
|
|
2567 |
|
String LSCPServer::GetDbInstrumentsJobInfo(int JobId) { |
2568 |
|
dmsg(2,("LSCPServer: GetDbInstrumentsJobInfo(JobId=%d)\n", JobId)); |
2569 |
|
LSCPResultSet result; |
2570 |
|
#if HAVE_SQLITE3 |
2571 |
|
try { |
2572 |
|
ScanJob job = InstrumentsDb::GetInstrumentsDb()->Jobs.GetJobById(JobId); |
2573 |
|
|
2574 |
|
result.Add("FILES_TOTAL", job.FilesTotal); |
2575 |
|
result.Add("FILES_SCANNED", job.FilesScanned); |
2576 |
|
result.Add("SCANNING", job.Scanning); |
2577 |
|
result.Add("STATUS", job.Status); |
2578 |
|
} catch (Exception e) { |
2579 |
|
result.Error(e); |
2580 |
|
} |
2581 |
#else |
#else |
2582 |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
2583 |
#endif |
#endif |