132 |
/** |
/** |
133 |
* Will be called by the parser to load an instrument. |
* Will be called by the parser to load an instrument. |
134 |
*/ |
*/ |
135 |
String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel) { |
String LSCPServer::LoadInstrument(String Filename, uint uiInstrument, uint uiSamplerChannel, bool bBackground) { |
136 |
dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel)); |
dmsg(2,("LSCPServer: LoadInstrument(Filename=%s,Instrument=%d,SamplerChannel=%d)\n", Filename.c_str(), uiInstrument, uiSamplerChannel)); |
137 |
LSCPResultSet result; |
LSCPResultSet result; |
138 |
try { |
try { |
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); |
if (bBackground) { |
144 |
|
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
145 |
|
pLoadInstrument->StartThread(); |
146 |
|
} |
147 |
|
else pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
148 |
} |
} |
149 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
150 |
result.Error(e); |
result.Error(e); |
248 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
249 |
float Volume = 0; |
float Volume = 0; |
250 |
String InstrumentFileName = "NONE"; |
String InstrumentFileName = "NONE"; |
251 |
int InstrumentIndex = 0; |
int InstrumentIndex = -1; |
252 |
|
int InstrumentStatus = -1; |
253 |
|
|
254 |
if (pEngine) { |
if (pEngine) { |
255 |
EngineName = pEngine->EngineName(); |
EngineName = pEngine->EngineName(); |
256 |
Volume = pEngine->Volume(); |
Volume = pEngine->Volume(); |
257 |
int iIdx = pEngine->InstrumentIndex(); |
InstrumentStatus = pEngine->InstrumentStatus(); |
258 |
if (iIdx != -1) { |
InstrumentIndex = pEngine->InstrumentIndex(); |
259 |
|
if (InstrumentIndex != -1) |
260 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentFileName = pEngine->InstrumentFileName(); |
|
InstrumentIndex = iIdx; |
|
|
} |
|
261 |
} |
} |
262 |
|
|
263 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
270 |
|
|
271 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
272 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
273 |
|
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
274 |
|
|
275 |
//Some more hardcoded stuff for now to make GUI look good |
//Some more hardcoded stuff for now to make GUI look good |
276 |
result.Add("MIDI_INPUT_DEVICE", "0"); |
result.Add("MIDI_INPUT_DEVICE", "0"); |
585 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
586 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
587 |
// FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers) |
// FIXME: workaround until MIDI driver configuration is implemented (using a Factory class for the MIDI input drivers then, like its already done for audio output drivers) |
588 |
if (MidiInputDriver != "ALSA") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
if (MidiInputDriver != "Alsa") throw LinuxSamplerException("Unknown MIDI input driver '" + MidiInputDriver + "'."); |
589 |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
MidiInputDevice::type_t MidiInputType = MidiInputDevice::type_alsa; |
590 |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
pSamplerChannel->SetMidiInputDevice(MidiInputType); |
591 |
} |
} |
688 |
* 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 |
689 |
* server for receiving event messages. |
* server for receiving event messages. |
690 |
*/ |
*/ |
691 |
String LSCPServer::SubscribeNotification(uint UDPPort) { |
String LSCPServer::SubscribeNotification(event_t Event) { |
692 |
dmsg(2,("LSCPServer: SubscribeNotification(UDPPort=%d)\n", UDPPort)); |
dmsg(2,("LSCPServer: SubscribeNotification(Event=%d)\n", Event)); |
693 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
694 |
} |
} |
695 |
|
|
697 |
* Will be called by the parser to unsubscribe a client on the server |
* Will be called by the parser to unsubscribe a client on the server |
698 |
* for not receiving further event messages. |
* for not receiving further event messages. |
699 |
*/ |
*/ |
700 |
String LSCPServer::UnsubscribeNotification(String SessionID) { |
String LSCPServer::UnsubscribeNotification(event_t Event) { |
701 |
dmsg(2,("LSCPServer: UnsubscribeNotification(SessionID=%s)\n", SessionID.c_str())); |
dmsg(2,("LSCPServer: UnsubscribeNotification(Event=%d)\n", Event)); |
702 |
return "ERR:0:Not implemented yet.\r\n"; |
return "ERR:0:Not implemented yet.\r\n"; |
703 |
} |
} |
704 |
|
|
705 |
|
|
706 |
|
// Instrument loader constructor. |
707 |
|
LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument) |
708 |
|
: Thread(false, 0, -4) |
709 |
|
{ |
710 |
|
this->pEngine = pEngine; |
711 |
|
this->Filename = Filename; |
712 |
|
this->uiInstrument = uiInstrument; |
713 |
|
} |
714 |
|
|
715 |
|
// Instrument loader process. |
716 |
|
int LSCPLoadInstrument::Main() |
717 |
|
{ |
718 |
|
try { |
719 |
|
pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
720 |
|
} |
721 |
|
|
722 |
|
catch (LinuxSamplerException e) { |
723 |
|
e.PrintMessage(); |
724 |
|
} |
725 |
|
|
726 |
|
// Always re-enable the engine. |
727 |
|
pEngine->Enable(); |
728 |
|
|
729 |
|
// FIXME: Shoot ourselves on the foot? |
730 |
|
delete this; |
731 |
|
} |