3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
|
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
10 |
* the Free Software Foundation; either version 2 of the License, or * |
* the Free Software Foundation; either version 2 of the License, or * |
11 |
* (at your option) any later version. * |
* (at your option) any later version. * |
12 |
* * |
* * |
13 |
* This program is distributed in the hope that it will be useful, * |
* This library is distributed in the hope that it will be useful, * |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
* GNU General Public License for more details. * |
* GNU General Public License for more details. * |
17 |
* * |
* * |
18 |
* You should have received a copy of the GNU General Public License * |
* You should have received a copy of the GNU General Public License * |
19 |
* along with this program; if not, write to the Free Software * |
* along with this library; if not, write to the Free Software * |
20 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
* MA 02111-1307 USA * |
* MA 02111-1307 USA * |
22 |
***************************************************************************/ |
***************************************************************************/ |
51 |
Mutex LSCPServer::NotifyMutex = Mutex(); |
Mutex LSCPServer::NotifyMutex = Mutex(); |
52 |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
Mutex LSCPServer::NotifyBufferMutex = Mutex(); |
53 |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
Mutex LSCPServer::SubscriptionMutex = Mutex(); |
54 |
|
Mutex LSCPServer::RTNotifyMutex = Mutex(); |
55 |
|
|
56 |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(false, 0, -4) { |
LSCPServer::LSCPServer(Sampler* pSampler) : Thread(true, false, 0, -4) { |
57 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
58 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channels, "CHANNELS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channels, "CHANNELS"); |
59 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
205 |
NotifyMutex.Unlock(); |
NotifyMutex.Unlock(); |
206 |
} |
} |
207 |
|
|
208 |
|
int LSCPServer::EventSubscribers( std::list<LSCPEvent::event_t> events ) { |
209 |
|
int subs = 0; |
210 |
|
SubscriptionMutex.Lock(); |
211 |
|
for( std::list<LSCPEvent::event_t>::iterator iter = events.begin(); |
212 |
|
iter != events.end(); iter++) |
213 |
|
{ |
214 |
|
subs += eventSubscriptions.count(*iter); |
215 |
|
} |
216 |
|
SubscriptionMutex.Unlock(); |
217 |
|
return subs; |
218 |
|
} |
219 |
|
|
220 |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
void LSCPServer::SendLSCPNotify( LSCPEvent event ) { |
221 |
SubscriptionMutex.Lock(); |
SubscriptionMutex.Lock(); |
222 |
if (eventSubscriptions.count(event.GetType()) == 0) { |
if (eventSubscriptions.count(event.GetType()) == 0) { |
446 |
LSCPResultSet result; |
LSCPResultSet result; |
447 |
try { |
try { |
448 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
449 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
450 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
451 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
452 |
if (!pSamplerChannel->GetAudioOutputDevice()) |
if (!pSamplerChannel->GetAudioOutputDevice()) |
453 |
throw LinuxSamplerException("No audio output device on channel"); |
throw LinuxSamplerException("No audio output device connected to sampler channel"); |
454 |
if (bBackground) { |
if (bBackground) { |
455 |
LSCPLoadInstrument *pLoadInstrument = new LSCPLoadInstrument(pEngine, Filename.c_str(), uiInstrument); |
InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngine); |
456 |
pLoadInstrument->StartThread(); |
} |
457 |
|
else { |
458 |
|
// tell the engine which instrument to load |
459 |
|
pEngine->PrepareLoadInstrument(Filename.c_str(), uiInstrument); |
460 |
|
// actually start to load the instrument (blocks until completed) |
461 |
|
pEngine->LoadInstrument(); |
462 |
} |
} |
|
else pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
|
463 |
} |
} |
464 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
465 |
result.Error(e); |
result.Error(e); |
478 |
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
if ((EngineName == "GigEngine") || (EngineName == "gig")) type = Engine::type_gig; |
479 |
else throw LinuxSamplerException("Unknown engine type"); |
else throw LinuxSamplerException("Unknown engine type"); |
480 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
481 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
482 |
|
LockRTNotify(); |
483 |
pSamplerChannel->LoadEngine(type); |
pSamplerChannel->LoadEngine(type); |
484 |
|
UnlockRTNotify(); |
485 |
} |
} |
486 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
487 |
result.Error(e); |
result.Error(e); |
532 |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
String LSCPServer::RemoveChannel(uint uiSamplerChannel) { |
533 |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
dmsg(2,("LSCPServer: RemoveChannel(SamplerChannel=%d)\n", uiSamplerChannel)); |
534 |
LSCPResultSet result; |
LSCPResultSet result; |
535 |
|
LockRTNotify(); |
536 |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
pSampler->RemoveSamplerChannel(uiSamplerChannel); |
537 |
|
UnlockRTNotify(); |
538 |
return result.Produce(); |
return result.Produce(); |
539 |
} |
} |
540 |
|
|
577 |
LSCPResultSet result; |
LSCPResultSet result; |
578 |
try { |
try { |
579 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
580 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
581 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
582 |
|
|
583 |
//Defaults values |
//Defaults values |
584 |
String EngineName = "NONE"; |
String EngineName = "NONE"; |
585 |
float Volume = 0.0f; |
float Volume = 0.0f; |
586 |
String InstrumentFileName = "NONE"; |
String InstrumentFileName = "NONE"; |
587 |
|
String InstrumentName = "NONE"; |
588 |
int InstrumentIndex = -1; |
int InstrumentIndex = -1; |
589 |
int InstrumentStatus = -1; |
int InstrumentStatus = -1; |
590 |
int AudioOutputChannels = 0; |
int AudioOutputChannels = 0; |
597 |
InstrumentStatus = pEngine->InstrumentStatus(); |
InstrumentStatus = pEngine->InstrumentStatus(); |
598 |
InstrumentIndex = pEngine->InstrumentIndex(); |
InstrumentIndex = pEngine->InstrumentIndex(); |
599 |
if (InstrumentIndex != -1) |
if (InstrumentIndex != -1) |
600 |
|
{ |
601 |
InstrumentFileName = pEngine->InstrumentFileName(); |
InstrumentFileName = pEngine->InstrumentFileName(); |
602 |
|
InstrumentName = pEngine->InstrumentName(); |
603 |
|
} |
604 |
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
for (int chan = 0; chan < pEngine->Channels(); chan++) { |
605 |
if (AudioRouting != "") AudioRouting += ","; |
if (AudioRouting != "") AudioRouting += ","; |
606 |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
AudioRouting += ToString(pEngine->OutputChannel(chan)); |
622 |
|
|
623 |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
result.Add("INSTRUMENT_FILE", InstrumentFileName); |
624 |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
result.Add("INSTRUMENT_NR", InstrumentIndex); |
625 |
|
result.Add("INSTRUMENT_NAME", InstrumentName); |
626 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
627 |
} |
} |
628 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
640 |
LSCPResultSet result; |
LSCPResultSet result; |
641 |
try { |
try { |
642 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
643 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
644 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
645 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
646 |
result.Add(pEngine->VoiceCount()); |
result.Add(pEngine->VoiceCount()); |
647 |
} |
} |
648 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
660 |
LSCPResultSet result; |
LSCPResultSet result; |
661 |
try { |
try { |
662 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
663 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
664 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
665 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
666 |
result.Add(pEngine->DiskStreamCount()); |
result.Add(pEngine->DiskStreamCount()); |
667 |
} |
} |
668 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
680 |
LSCPResultSet result; |
LSCPResultSet result; |
681 |
try { |
try { |
682 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
683 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
684 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
685 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
686 |
if (!pEngine->DiskStreamSupported()) |
if (!pEngine->DiskStreamSupported()) |
687 |
result.Add("NA"); |
result.Add("NA"); |
688 |
else { |
else { |
972 |
|
|
973 |
// get audio channel |
// get audio channel |
974 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
975 |
if (!pChannel) throw LinuxSamplerException("Audio ouotput device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
976 |
|
|
977 |
// return the values of all audio channel parameters |
// return the values of all audio channel parameters |
978 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1031 |
|
|
1032 |
// get audio channel |
// get audio channel |
1033 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1034 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1035 |
|
|
1036 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1037 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1064 |
|
|
1065 |
// get audio channel |
// get audio channel |
1066 |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
AudioChannel* pChannel = pDevice->Channel(ChannelId); |
1067 |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have channel " + ToString(ChannelId) + "."); |
if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + "."); |
1068 |
|
|
1069 |
// get desired audio channel parameter |
// get desired audio channel parameter |
1070 |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters(); |
1147 |
LSCPResultSet result; |
LSCPResultSet result; |
1148 |
try { |
try { |
1149 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1150 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1151 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1152 |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
if (!pEngine) throw LinuxSamplerException("No engine deployed on sampler channel " + ToString(uiSamplerChannel)); |
1153 |
|
if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel)); |
1154 |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
pEngine->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel); |
1155 |
} |
} |
1156 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1164 |
LSCPResultSet result; |
LSCPResultSet result; |
1165 |
try { |
try { |
1166 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1167 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1168 |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices(); |
1169 |
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId)); |
1170 |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
AudioOutputDevice* pDevice = devices[AudioDeviceId]; |
1181 |
LSCPResultSet result; |
LSCPResultSet result; |
1182 |
try { |
try { |
1183 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1184 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1185 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1186 |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA"; |
1187 |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK"; |
1218 |
LSCPResultSet result; |
LSCPResultSet result; |
1219 |
try { |
try { |
1220 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1221 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1222 |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
pSamplerChannel->SetMidiInputPort(MIDIPort); |
1223 |
} |
} |
1224 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1232 |
LSCPResultSet result; |
LSCPResultSet result; |
1233 |
try { |
try { |
1234 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1235 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1236 |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
pSamplerChannel->SetMidiInputChannel((MidiInputPort::midi_chan_t) MIDIChannel); |
1237 |
} |
} |
1238 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1246 |
LSCPResultSet result; |
LSCPResultSet result; |
1247 |
try { |
try { |
1248 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1249 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1250 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1251 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1252 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1263 |
LSCPResultSet result; |
LSCPResultSet result; |
1264 |
try { |
try { |
1265 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1266 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1267 |
// Driver type name aliasing... |
// Driver type name aliasing... |
1268 |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA"; |
1269 |
// Check if there's one MIDI input device already created |
// Check if there's one MIDI input device already created |
1306 |
LSCPResultSet result; |
LSCPResultSet result; |
1307 |
try { |
try { |
1308 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1309 |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid channel number " + ToString(uiSamplerChannel)); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1310 |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices(); |
1311 |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId)); |
1312 |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
MidiInputDevice* pDevice = devices[MIDIDeviceId]; |
1327 |
LSCPResultSet result; |
LSCPResultSet result; |
1328 |
try { |
try { |
1329 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1330 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1331 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1332 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1333 |
pEngine->Volume(dVolume); |
pEngine->Volume(dVolume); |
1334 |
} |
} |
1335 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1346 |
LSCPResultSet result; |
LSCPResultSet result; |
1347 |
try { |
try { |
1348 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1349 |
if (!pSamplerChannel) throw LinuxSamplerException("Index out of bounds"); |
if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1350 |
Engine* pEngine = pSamplerChannel->GetEngine(); |
Engine* pEngine = pSamplerChannel->GetEngine(); |
1351 |
if (!pEngine) throw LinuxSamplerException("No engine loaded on channel"); |
if (!pEngine) throw LinuxSamplerException("No engine loaded on sampler channel"); |
1352 |
pEngine->Reset(); |
pEngine->Reset(); |
1353 |
} |
} |
1354 |
catch (LinuxSamplerException e) { |
catch (LinuxSamplerException e) { |
1411 |
} |
} |
1412 |
return result.Produce(); |
return result.Produce(); |
1413 |
} |
} |
|
|
|
|
// Instrument loader constructor. |
|
|
LSCPLoadInstrument::LSCPLoadInstrument(Engine* pEngine, String Filename, uint uiInstrument) |
|
|
: Thread(false, 0, -4) |
|
|
{ |
|
|
this->pEngine = pEngine; |
|
|
this->Filename = Filename; |
|
|
this->uiInstrument = uiInstrument; |
|
|
} |
|
|
|
|
|
// Instrument loader process. |
|
|
int LSCPLoadInstrument::Main() |
|
|
{ |
|
|
try { |
|
|
pEngine->LoadInstrument(Filename.c_str(), uiInstrument); |
|
|
} |
|
|
|
|
|
catch (LinuxSamplerException e) { |
|
|
e.PrintMessage(); |
|
|
} |
|
|
|
|
|
// Always re-enable the engine. |
|
|
pEngine->Enable(); |
|
|
|
|
|
// FIXME: Shoot ourselves on the foot? |
|
|
delete this; |
|
|
} |
|