21 |
* MA 02111-1307 USA * |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
***************************************************************************/ |
23 |
|
|
24 |
|
#include <algorithm> |
25 |
|
#include <string> |
26 |
|
|
27 |
#include "lscpserver.h" |
#include "lscpserver.h" |
28 |
#include "lscpresultset.h" |
#include "lscpresultset.h" |
29 |
#include "lscpevent.h" |
#include "lscpevent.h" |
43 |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
#include "../drivers/audio/AudioOutputDeviceFactory.h" |
44 |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
#include "../drivers/midi/MidiInputDeviceFactory.h" |
45 |
|
|
46 |
|
namespace LinuxSampler { |
47 |
|
|
48 |
/** |
/** |
49 |
* Returns a copy of the given string where all special characters are |
* Returns a copy of the given string where all special characters are |
426 |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
std::set<EngineChannel*>::iterator itEnd = engineChannels.end(); |
427 |
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
for (; itEngineChannel != itEnd; ++itEngineChannel) { |
428 |
if ((*itEngineChannel)->StatusChanged()) { |
if ((*itEngineChannel)->StatusChanged()) { |
429 |
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->GetSamplerChannel()->Index())); |
430 |
} |
} |
431 |
|
|
432 |
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
433 |
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
434 |
if(fxs != NULL && fxs->IsInfoChanged()) { |
if(fxs != NULL && fxs->IsInfoChanged()) { |
435 |
int chn = (*itEngineChannel)->iSamplerChannelIndex; |
int chn = (*itEngineChannel)->GetSamplerChannel()->Index(); |
436 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, chn, fxs->Id())); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, chn, fxs->Id())); |
437 |
fxs->SetInfoChanged(false); |
fxs->SetInfoChanged(false); |
438 |
} |
} |
1135 |
dmsg(2,("LSCPServer: GetVoiceCount(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: GetVoiceCount(SamplerChannel=%d)\n", uiSamplerChannel)); |
1136 |
LSCPResultSet result; |
LSCPResultSet result; |
1137 |
try { |
try { |
1138 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine loaded on sampler channel"); |
|
1139 |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
1140 |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
result.Add(pEngineChannel->GetEngine()->VoiceCount()); |
1141 |
} |
} |
1153 |
dmsg(2,("LSCPServer: GetStreamCount(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: GetStreamCount(SamplerChannel=%d)\n", uiSamplerChannel)); |
1154 |
LSCPResultSet result; |
LSCPResultSet result; |
1155 |
try { |
try { |
1156 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
1157 |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
1158 |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
result.Add(pEngineChannel->GetEngine()->DiskStreamCount()); |
1159 |
} |
} |
1171 |
dmsg(2,("LSCPServer: GetBufferFill(ResponseType=%d, SamplerChannel=%d)\n", ResponseType, uiSamplerChannel)); |
dmsg(2,("LSCPServer: GetBufferFill(ResponseType=%d, SamplerChannel=%d)\n", ResponseType, uiSamplerChannel)); |
1172 |
LSCPResultSet result; |
LSCPResultSet result; |
1173 |
try { |
try { |
1174 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
1175 |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel"); |
1176 |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA"); |
1177 |
else { |
else { |
1849 |
dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", dVolume, uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetVolume(Volume=%f, SamplerChannel=%d)\n", dVolume, uiSamplerChannel)); |
1850 |
LSCPResultSet result; |
LSCPResultSet result; |
1851 |
try { |
try { |
1852 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
1853 |
pEngineChannel->Volume(dVolume); |
pEngineChannel->Volume(dVolume); |
1854 |
} |
} |
1855 |
catch (Exception e) { |
catch (Exception e) { |
1865 |
dmsg(2,("LSCPServer: SetChannelMute(bMute=%d,uiSamplerChannel=%d)\n",bMute,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetChannelMute(bMute=%d,uiSamplerChannel=%d)\n",bMute,uiSamplerChannel)); |
1866 |
LSCPResultSet result; |
LSCPResultSet result; |
1867 |
try { |
try { |
1868 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
1869 |
|
|
1870 |
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0); |
1871 |
else pEngineChannel->SetMute(1); |
else pEngineChannel->SetMute(1); |
1882 |
dmsg(2,("LSCPServer: SetChannelSolo(bSolo=%d,uiSamplerChannel=%d)\n",bSolo,uiSamplerChannel)); |
dmsg(2,("LSCPServer: SetChannelSolo(bSolo=%d,uiSamplerChannel=%d)\n",bSolo,uiSamplerChannel)); |
1883 |
LSCPResultSet result; |
LSCPResultSet result; |
1884 |
try { |
try { |
1885 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
1886 |
|
|
1887 |
bool oldSolo = pEngineChannel->GetSolo(); |
bool oldSolo = pEngineChannel->GetSolo(); |
1888 |
bool hadSoloChannel = HasSoloChannel(); |
bool hadSoloChannel = HasSoloChannel(); |
2002 |
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
2003 |
LSCPResultSet result; |
LSCPResultSet result; |
2004 |
try { |
try { |
2005 |
result.Add(MidiInstrumentMapper::Entries(MidiMapID).size()); |
result.Add(MidiInstrumentMapper::GetInstrumentCount(MidiMapID)); |
2006 |
} catch (Exception e) { |
} catch (Exception e) { |
2007 |
result.Error(e); |
result.Error(e); |
2008 |
} |
} |
2013 |
String LSCPServer::GetAllMidiInstrumentMappings() { |
String LSCPServer::GetAllMidiInstrumentMappings() { |
2014 |
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
2015 |
LSCPResultSet result; |
LSCPResultSet result; |
2016 |
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
try { |
2017 |
int totalMappings = 0; |
result.Add(MidiInstrumentMapper::GetInstrumentCount()); |
2018 |
for (int i = 0; i < maps.size(); i++) { |
} catch (Exception e) { |
2019 |
try { |
result.Error(e); |
|
totalMappings += MidiInstrumentMapper::Entries(maps[i]).size(); |
|
|
} catch (Exception e) { /*NOOP*/ } |
|
2020 |
} |
} |
|
result.Add(totalMappings); |
|
2021 |
return result.Produce(); |
return result.Produce(); |
2022 |
} |
} |
2023 |
|
|
2025 |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
2026 |
LSCPResultSet result; |
LSCPResultSet result; |
2027 |
try { |
try { |
2028 |
midi_prog_index_t idx; |
MidiInstrumentMapper::entry_t entry = MidiInstrumentMapper::GetEntry(MidiMapID, MidiBank, MidiProg); |
2029 |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
// convert the filename into the correct encoding as defined for LSCP |
2030 |
idx.midi_bank_lsb = MidiBank & 0x7f; |
// (especially in terms of special characters -> escape sequences) |
|
idx.midi_prog = MidiProg; |
|
|
|
|
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
|
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
|
|
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
|
|
else { // found |
|
|
|
|
|
// convert the filename into the correct encoding as defined for LSCP |
|
|
// (especially in terms of special characters -> escape sequences) |
|
2031 |
#if WIN32 |
#if WIN32 |
2032 |
const String instrumentFileName = Path::fromWindows(iter->second.InstrumentFile).toLscp(); |
const String instrumentFileName = Path::fromWindows(entry.InstrumentFile).toLscp(); |
2033 |
#else |
#else |
2034 |
// assuming POSIX |
// assuming POSIX |
2035 |
const String instrumentFileName = Path::fromPosix(iter->second.InstrumentFile).toLscp(); |
const String instrumentFileName = Path::fromPosix(entry.InstrumentFile).toLscp(); |
2036 |
#endif |
#endif |
2037 |
|
|
2038 |
result.Add("NAME", _escapeLscpResponse(iter->second.Name)); |
result.Add("NAME", _escapeLscpResponse(entry.Name)); |
2039 |
result.Add("ENGINE_NAME", iter->second.EngineName); |
result.Add("ENGINE_NAME", entry.EngineName); |
2040 |
result.Add("INSTRUMENT_FILE", instrumentFileName); |
result.Add("INSTRUMENT_FILE", instrumentFileName); |
2041 |
result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex); |
result.Add("INSTRUMENT_NR", (int) entry.InstrumentIndex); |
2042 |
String instrumentName; |
String instrumentName; |
2043 |
Engine* pEngine = EngineFactory::Create(iter->second.EngineName); |
Engine* pEngine = EngineFactory::Create(entry.EngineName); |
2044 |
if (pEngine) { |
if (pEngine) { |
2045 |
if (pEngine->GetInstrumentManager()) { |
if (pEngine->GetInstrumentManager()) { |
2046 |
InstrumentManager::instrument_id_t instrID; |
InstrumentManager::instrument_id_t instrID; |
2047 |
instrID.FileName = iter->second.InstrumentFile; |
instrID.FileName = entry.InstrumentFile; |
2048 |
instrID.Index = iter->second.InstrumentIndex; |
instrID.Index = entry.InstrumentIndex; |
2049 |
instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID); |
instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID); |
|
} |
|
|
EngineFactory::Destroy(pEngine); |
|
2050 |
} |
} |
2051 |
result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName)); |
EngineFactory::Destroy(pEngine); |
|
switch (iter->second.LoadMode) { |
|
|
case MidiInstrumentMapper::ON_DEMAND: |
|
|
result.Add("LOAD_MODE", "ON_DEMAND"); |
|
|
break; |
|
|
case MidiInstrumentMapper::ON_DEMAND_HOLD: |
|
|
result.Add("LOAD_MODE", "ON_DEMAND_HOLD"); |
|
|
break; |
|
|
case MidiInstrumentMapper::PERSISTENT: |
|
|
result.Add("LOAD_MODE", "PERSISTENT"); |
|
|
break; |
|
|
default: |
|
|
throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!"); |
|
|
} |
|
|
result.Add("VOLUME", iter->second.Volume); |
|
2052 |
} |
} |
2053 |
|
result.Add("INSTRUMENT_NAME", _escapeLscpResponse(instrumentName)); |
2054 |
|
switch (entry.LoadMode) { |
2055 |
|
case MidiInstrumentMapper::ON_DEMAND: |
2056 |
|
result.Add("LOAD_MODE", "ON_DEMAND"); |
2057 |
|
break; |
2058 |
|
case MidiInstrumentMapper::ON_DEMAND_HOLD: |
2059 |
|
result.Add("LOAD_MODE", "ON_DEMAND_HOLD"); |
2060 |
|
break; |
2061 |
|
case MidiInstrumentMapper::PERSISTENT: |
2062 |
|
result.Add("LOAD_MODE", "PERSISTENT"); |
2063 |
|
break; |
2064 |
|
default: |
2065 |
|
throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!"); |
2066 |
|
} |
2067 |
|
result.Add("VOLUME", entry.Volume); |
2068 |
} catch (Exception e) { |
} catch (Exception e) { |
2069 |
result.Error(e); |
result.Error(e); |
2070 |
} |
} |
2235 |
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
2236 |
LSCPResultSet result; |
LSCPResultSet result; |
2237 |
try { |
try { |
2238 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
2239 |
|
|
2240 |
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
2241 |
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
2414 |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: EditSamplerChannelInstrument(SamplerChannel=%d)\n", uiSamplerChannel)); |
2415 |
LSCPResultSet result; |
LSCPResultSet result; |
2416 |
try { |
try { |
2417 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
2418 |
if (pEngineChannel->InstrumentStatus() < 0) throw Exception("No instrument loaded to sampler channel"); |
if (pEngineChannel->InstrumentStatus() < 0) throw Exception("No instrument loaded to sampler channel"); |
2419 |
Engine* pEngine = pEngineChannel->GetEngine(); |
Engine* pEngine = pEngineChannel->GetEngine(); |
2420 |
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
InstrumentManager* pInstrumentManager = pEngine->GetInstrumentManager(); |
2429 |
return result.Produce(); |
return result.Produce(); |
2430 |
} |
} |
2431 |
|
|
2432 |
|
String LSCPServer::SendChannelMidiData(String MidiMsg, uint uiSamplerChannel, uint Arg1, uint Arg2) { |
2433 |
|
dmsg(2,("LSCPServer: SendChannelMidiData(MidiMsg=%s,uiSamplerChannel=%d,Arg1=%d,Arg2=%d)\n", MidiMsg.c_str(), uiSamplerChannel, Arg1, Arg2)); |
2434 |
|
LSCPResultSet result; |
2435 |
|
try { |
2436 |
|
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
2437 |
|
|
2438 |
|
if (Arg1 > 127 || Arg2 > 127) { |
2439 |
|
throw Exception("Invalid MIDI message"); |
2440 |
|
} |
2441 |
|
|
2442 |
|
VirtualMidiDevice* pMidiDevice = NULL; |
2443 |
|
std::vector<EventHandler::midi_listener_entry>::iterator iter = eventHandler.channelMidiListeners.begin(); |
2444 |
|
for (; iter != eventHandler.channelMidiListeners.end(); ++iter) { |
2445 |
|
if ((*iter).pEngineChannel == pEngineChannel) { |
2446 |
|
pMidiDevice = (*iter).pMidiListener; |
2447 |
|
break; |
2448 |
|
} |
2449 |
|
} |
2450 |
|
|
2451 |
|
if(pMidiDevice == NULL) throw Exception("Couldn't find virtual MIDI device"); |
2452 |
|
|
2453 |
|
if (MidiMsg == "NOTE_ON") { |
2454 |
|
pMidiDevice->SendNoteOnToDevice(Arg1, Arg2); |
2455 |
|
bool b = pMidiDevice->SendNoteOnToSampler(Arg1, Arg2); |
2456 |
|
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2457 |
|
} else if (MidiMsg == "NOTE_OFF") { |
2458 |
|
pMidiDevice->SendNoteOffToDevice(Arg1, Arg2); |
2459 |
|
bool b = pMidiDevice->SendNoteOffToSampler(Arg1, Arg2); |
2460 |
|
if (!b) throw Exception("MIDI event failed: " + MidiMsg + " " + ToString(Arg1) + " " + ToString(Arg2)); |
2461 |
|
} else { |
2462 |
|
throw Exception("Unknown MIDI message type: " + MidiMsg); |
2463 |
|
} |
2464 |
|
} catch (Exception e) { |
2465 |
|
result.Error(e); |
2466 |
|
} |
2467 |
|
return result.Produce(); |
2468 |
|
} |
2469 |
|
|
2470 |
/** |
/** |
2471 |
* Will be called by the parser to reset a particular sampler channel. |
* Will be called by the parser to reset a particular sampler channel. |
2472 |
*/ |
*/ |
2474 |
dmsg(2,("LSCPServer: ResetChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: ResetChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
2475 |
LSCPResultSet result; |
LSCPResultSet result; |
2476 |
try { |
try { |
2477 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel"); |
|
2478 |
pEngineChannel->Reset(); |
pEngineChannel->Reset(); |
2479 |
} |
} |
2480 |
catch (Exception e) { |
catch (Exception e) { |
2554 |
LSCPResultSet result; |
LSCPResultSet result; |
2555 |
try { |
try { |
2556 |
if (dVolume < 0) throw Exception("Volume may not be negative"); |
if (dVolume < 0) throw Exception("Volume may not be negative"); |
2557 |
GLOBAL_VOLUME = dVolume; // see common/global.cpp |
GLOBAL_VOLUME = dVolume; // see common/global_private.cpp |
2558 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOLUME", GLOBAL_VOLUME)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOLUME", GLOBAL_VOLUME)); |
2559 |
} catch (Exception e) { |
} catch (Exception e) { |
2560 |
result.Error(e); |
result.Error(e); |
2681 |
result.Add("FORMAT_VERSION", info.FormatVersion); |
result.Add("FORMAT_VERSION", info.FormatVersion); |
2682 |
result.Add("PRODUCT", info.Product); |
result.Add("PRODUCT", info.Product); |
2683 |
result.Add("ARTISTS", info.Artists); |
result.Add("ARTISTS", info.Artists); |
2684 |
|
|
2685 |
|
std::stringstream ss; |
2686 |
|
bool b = false; |
2687 |
|
for (int i = 0; i < 128; i++) { |
2688 |
|
if (info.KeyBindings[i]) { |
2689 |
|
if (b) ss << ','; |
2690 |
|
ss << i; b = true; |
2691 |
|
} |
2692 |
|
} |
2693 |
|
result.Add("KEY_BINDINGS", ss.str()); |
2694 |
|
|
2695 |
|
b = false; |
2696 |
|
std::stringstream ss2; |
2697 |
|
for (int i = 0; i < 128; i++) { |
2698 |
|
if (info.KeySwitchBindings[i]) { |
2699 |
|
if (b) ss2 << ','; |
2700 |
|
ss2 << i; b = true; |
2701 |
|
} |
2702 |
|
} |
2703 |
|
result.Add("KEYSWITCH_BINDINGS", ss2.str()); |
2704 |
// no more need to ask other engine types |
// no more need to ask other engine types |
2705 |
bFound = true; |
bFound = true; |
2706 |
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
} else dmsg(1,("Warning: engine '%s' does not provide an instrument manager\n", engineTypes[i].c_str())); |
2933 |
return result.Produce(); |
return result.Produce(); |
2934 |
} |
} |
2935 |
|
|
2936 |
String LSCPServer::AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground) { |
String LSCPServer::AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground, bool insDir) { |
2937 |
dmsg(2,("LSCPServer: AddDbInstruments(ScanMode=%s,DbDir=%s,FsDir=%s,bBackground=%d)\n", ScanMode.c_str(), DbDir.c_str(), FsDir.c_str(), bBackground)); |
dmsg(2,("LSCPServer: AddDbInstruments(ScanMode=%s,DbDir=%s,FsDir=%s,bBackground=%d,insDir=%d)\n", ScanMode.c_str(), DbDir.c_str(), FsDir.c_str(), bBackground, insDir)); |
2938 |
LSCPResultSet result; |
LSCPResultSet result; |
2939 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
2940 |
try { |
try { |
2941 |
int id; |
int id; |
2942 |
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
InstrumentsDb* db = InstrumentsDb::GetInstrumentsDb(); |
2943 |
if (ScanMode.compare("RECURSIVE") == 0) { |
if (ScanMode.compare("RECURSIVE") == 0) { |
2944 |
id = db->AddInstruments(RECURSIVE, DbDir, FsDir, bBackground); |
id = db->AddInstruments(RECURSIVE, DbDir, FsDir, bBackground, insDir); |
2945 |
} else if (ScanMode.compare("NON_RECURSIVE") == 0) { |
} else if (ScanMode.compare("NON_RECURSIVE") == 0) { |
2946 |
id = db->AddInstruments(NON_RECURSIVE, DbDir, FsDir, bBackground); |
id = db->AddInstruments(NON_RECURSIVE, DbDir, FsDir, bBackground, insDir); |
2947 |
} else if (ScanMode.compare("FLAT") == 0) { |
} else if (ScanMode.compare("FLAT") == 0) { |
2948 |
id = db->AddInstruments(FLAT, DbDir, FsDir, bBackground); |
id = db->AddInstruments(FLAT, DbDir, FsDir, bBackground, insDir); |
2949 |
} else { |
} else { |
2950 |
throw Exception("Unknown scan mode: " + ScanMode); |
throw Exception("Unknown scan mode: " + ScanMode); |
2951 |
} |
} |
3121 |
return result.Produce(); |
return result.Produce(); |
3122 |
} |
} |
3123 |
|
|
3124 |
|
String LSCPServer::SetDbInstrumentFilePath(String OldPath, String NewPath) { |
3125 |
|
dmsg(2,("LSCPServer: SetDbInstrumentFilePath(OldPath=%s,NewPath=%s)\n", OldPath.c_str(), NewPath.c_str())); |
3126 |
|
LSCPResultSet result; |
3127 |
|
#if HAVE_SQLITE3 |
3128 |
|
try { |
3129 |
|
InstrumentsDb::GetInstrumentsDb()->SetInstrumentFilePath(OldPath, NewPath); |
3130 |
|
} catch (Exception e) { |
3131 |
|
result.Error(e); |
3132 |
|
} |
3133 |
|
#else |
3134 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
3135 |
|
#endif |
3136 |
|
return result.Produce(); |
3137 |
|
} |
3138 |
|
|
3139 |
|
String LSCPServer::FindLostDbInstrumentFiles() { |
3140 |
|
dmsg(2,("LSCPServer: FindLostDbInstrumentFiles()\n")); |
3141 |
|
LSCPResultSet result; |
3142 |
|
#if HAVE_SQLITE3 |
3143 |
|
try { |
3144 |
|
String list; |
3145 |
|
StringListPtr pLostFiles = InstrumentsDb::GetInstrumentsDb()->FindLostInstrumentFiles(); |
3146 |
|
|
3147 |
|
for (int i = 0; i < pLostFiles->size(); i++) { |
3148 |
|
if (list != "") list += ","; |
3149 |
|
list += "'" + pLostFiles->at(i) + "'"; |
3150 |
|
} |
3151 |
|
|
3152 |
|
result.Add(list); |
3153 |
|
} catch (Exception e) { |
3154 |
|
result.Error(e); |
3155 |
|
} |
3156 |
|
#else |
3157 |
|
result.Error(String(DOESNT_HAVE_SQLITE3), 0); |
3158 |
|
#endif |
3159 |
|
return result.Produce(); |
3160 |
|
} |
3161 |
|
|
3162 |
String LSCPServer::FindDbInstrumentDirectories(String Dir, std::map<String,String> Parameters, bool Recursive) { |
String LSCPServer::FindDbInstrumentDirectories(String Dir, std::map<String,String> Parameters, bool Recursive) { |
3163 |
dmsg(2,("LSCPServer: FindDbInstrumentDirectories(Dir=%s)\n", Dir.c_str())); |
dmsg(2,("LSCPServer: FindDbInstrumentDirectories(Dir=%s)\n", Dir.c_str())); |
3164 |
LSCPResultSet result; |
LSCPResultSet result; |
3289 |
} |
} |
3290 |
return result.Produce(); |
return result.Produce(); |
3291 |
} |
} |
3292 |
|
|
3293 |
|
} |