140 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
141 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
142 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
143 |
pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
144 |
|
pLoadInstrument->StartThread(); |
145 |
} |
} |
146 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
147 |
result.Error(e); |
result.Error(e); |
245 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
246 |
float Volume = 0; |
float Volume = 0; |
247 |
String InstrumentFileName = "NONE"; |
String InstrumentFileName = "NONE"; |
248 |
int InstrumentIndex = 0; |
int InstrumentIndex = -1; |
249 |
|
int InstrumentStatus = -1; |
250 |
|
|
251 |
if (pEngine) { |
if (pEngine) { |
252 |
EngineName = pEngine->EngineName(); |
EngineName = pEngine->EngineName(); |
253 |
Volume = pEngine->Volume(); |
Volume = pEngine->Volume(); |
254 |
int iIdx = pEngine->InstrumentIndex(); |
InstrumentStatus = pEngine->InstrumentStatus(); |
255 |
if (iIdx != -1) { |
InstrumentIndex = pEngine->InstrumentIndex(); |
256 |
|
if (InstrumentIndex != -1) |
257 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentFileName = pEngine->InstrumentFileName(); |
|
InstrumentIndex = iIdx; |
|
|
} |
|
258 |
} |
} |
259 |
|
|
260 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
267 |
|
|
268 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
269 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
270 |
|
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
271 |
|
|
272 |
//Some more hardcoded stuff for now to make GUI look good |
//Some more hardcoded stuff for now to make GUI look good |
273 |
result.Add("MIDI_INPUT_DEVICE", "0"); |
result.Add("MIDI_INPUT_DEVICE", "0"); |
332 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
333 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
334 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
335 |
if (!pEngine->DiskStreamSupported()) return "NA\r\n"; //FIXME: Update resultset class to support "NA" |
if (!pEngine->DiskStreamSupported()) |
336 |
switch (ResponseType) { |
result.Add("NA"); |
337 |
case fill_response_bytes: |
else { |
338 |
result.Add(pEngine->DiskStreamBufferFillBytes()); |
switch (ResponseType) { |
339 |
break; |
case fill_response_bytes: |
340 |
case fill_response_percentage: |
result.Add(pEngine->DiskStreamBufferFillBytes()); |
341 |
result.Add(pEngine->DiskStreamBufferFillPercentage()); |
break; |
342 |
break; |
case fill_response_percentage: |
343 |
default: |
result.Add(pEngine->DiskStreamBufferFillPercentage()); |
344 |
throw LinuxSamplerException("Unknown fill response type"); |
break; |
345 |
} |
default: |
346 |
|
throw LinuxSamplerException("Unknown fill response type"); |
347 |
|
} |
348 |
|
} |
349 |
} |
} |
350 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
351 |
result.Error(e); |
result.Error(e); |
698 |
dmsg(2,("LSCPServer: UnsubscribeNotification(SessionID=%s)\n", SessionID.c_str())); |
dmsg(2,("LSCPServer: UnsubscribeNotification(SessionID=%s)\n", SessionID.c_str())); |
699 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
700 |
} |
} |
701 |
|
|
702 |
|
|
703 |
|
// Instrument loader constructor. |
704 |
|
LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument) |
705 |
|
: Thread(false, 0, -4) |
706 |
|
{ |
707 |
|
this->pEngine = pEngine; |
708 |
|
this->Filename = Filename; |
709 |
|
this->uiInstrument = uiInstrument; |
710 |
|
} |
711 |
|
|
712 |
|
// Instrument loader process. |
713 |
|
int LSCPLoadInstrument::Main() |
714 |
|
{ |
715 |
|
try { |
716 |
|
pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
717 |
|
} |
718 |
|
|
719 |
|
catch (LinuxSamplerException e) { |
720 |
|
e.PrintMessage(); |
721 |
|
} |
722 |
|
|
723 |
|
// Always re-enable the engine. |
724 |
|
pEngine->Enable(); |
725 |
|
|
726 |
|
// FIXME: Shoot ourselves on the foot? |
727 |
|
delete this; |
728 |
|
} |