/[svn]/linuxsampler/trunk/src/network/lscpserver.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/network/lscpserver.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 841 by persson, Sat Mar 4 16:23:53 2006 UTC revision 973 by schoenebeck, Fri Dec 15 21:40:27 2006 UTC
# Line 3  Line 3 
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                              *   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This library 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  *
# Line 322  bool LSCPServer::GetLSCPCommand( std::ve Line 322  bool LSCPServer::GetLSCPCommand( std::ve
322                                  continue; //Ignore CR                                  continue; //Ignore CR
323                          if (c == '\n') {                          if (c == '\n') {
324                                  LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket));                                  LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_misc, "Received \'" + bufferedCommands[socket] + "\' on socket", socket));
325                                  bufferedCommands[socket] += "\n";                                  bufferedCommands[socket] += "\r\n";
326                                  return true; //Complete command was read                                  return true; //Complete command was read
327                          }                          }
328                          bufferedCommands[socket] += c;                          bufferedCommands[socket] += c;
# Line 427  String LSCPServer::CreateAudioOutputDevi Line 427  String LSCPServer::CreateAudioOutputDevi
427          AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters);          AudioOutputDevice* pDevice = pSampler->CreateAudioOutputDevice(Driver, Parameters);
428          // search for the created device to get its index          // search for the created device to get its index
429          int index = GetAudioOutputDeviceIndex(pDevice);          int index = GetAudioOutputDeviceIndex(pDevice);
430          if (index == -1) throw LinuxSamplerException("Internal error: could not find created audio output device.");          if (index == -1) throw Exception("Internal error: could not find created audio output device.");
431          result = index; // success          result = index; // success
432      }      }
433      catch (LinuxSamplerException e) {      catch (Exception e) {
434          result.Error(e);          result.Error(e);
435      }      }
436      return result.Produce();      return result.Produce();
# Line 443  String LSCPServer::CreateMidiInputDevice Line 443  String LSCPServer::CreateMidiInputDevice
443          MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters);          MidiInputDevice* pDevice = pSampler->CreateMidiInputDevice(Driver, Parameters);
444          // search for the created device to get its index          // search for the created device to get its index
445          int index = GetMidiInputDeviceIndex(pDevice);          int index = GetMidiInputDeviceIndex(pDevice);
446          if (index == -1) throw LinuxSamplerException("Internal error: could not find created midi input device.");          if (index == -1) throw Exception("Internal error: could not find created midi input device.");
447          result = index; // success          result = index; // success
448      }      }
449      catch (LinuxSamplerException e) {      catch (Exception e) {
450          result.Error(e);          result.Error(e);
451      }      }
452      return result.Produce();      return result.Produce();
# Line 457  String LSCPServer::DestroyAudioOutputDev Line 457  String LSCPServer::DestroyAudioOutputDev
457      LSCPResultSet result;      LSCPResultSet result;
458      try {      try {
459          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
460          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + ".");
461          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
462          pSampler->DestroyAudioOutputDevice(pDevice);          pSampler->DestroyAudioOutputDevice(pDevice);
463      }      }
464      catch (LinuxSamplerException e) {      catch (Exception e) {
465          result.Error(e);          result.Error(e);
466      }      }
467      return result.Produce();      return result.Produce();
# Line 472  String LSCPServer::DestroyMidiInputDevic Line 472  String LSCPServer::DestroyMidiInputDevic
472      LSCPResultSet result;      LSCPResultSet result;
473      try {      try {
474          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
475          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + ".");
476          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
477          pSampler->DestroyMidiInputDevice(pDevice);          pSampler->DestroyMidiInputDevice(pDevice);
478      }      }
479      catch (LinuxSamplerException e) {      catch (Exception e) {
480          result.Error(e);          result.Error(e);
481      }      }
482      return result.Produce();      return result.Produce();
# Line 490  String LSCPServer::LoadInstrument(String Line 490  String LSCPServer::LoadInstrument(String
490      LSCPResultSet result;      LSCPResultSet result;
491      try {      try {
492          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
493          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
494          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
495          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel yet");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel yet");
496          if (!pSamplerChannel->GetAudioOutputDevice())          if (!pSamplerChannel->GetAudioOutputDevice())
497              throw LinuxSamplerException("No audio output device connected to sampler channel");              throw Exception("No audio output device connected to sampler channel");
498          if (bBackground) {          if (bBackground) {
499              InstrumentLoader.StartNewLoad(Filename, uiInstrument, pEngineChannel);              InstrumentManager::instrument_id_t id;
500                id.FileName = Filename;
501                id.Index    = uiInstrument;
502                InstrumentManager::LoadInstrumentInBackground(id, pEngineChannel);
503          }          }
504          else {          else {
505              // tell the engine channel which instrument to load              // tell the engine channel which instrument to load
# Line 505  String LSCPServer::LoadInstrument(String Line 508  String LSCPServer::LoadInstrument(String
508              pEngineChannel->LoadInstrument();              pEngineChannel->LoadInstrument();
509          }          }
510      }      }
511      catch (LinuxSamplerException e) {      catch (Exception e) {
512           result.Error(e);           result.Error(e);
513      }      }
514      return result.Produce();      return result.Produce();
# Line 520  String LSCPServer::SetEngineType(String Line 523  String LSCPServer::SetEngineType(String
523      LSCPResultSet result;      LSCPResultSet result;
524      try {      try {
525          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
526          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
527          LockRTNotify();          LockRTNotify();
528          pSamplerChannel->SetEngineType(EngineName);          pSamplerChannel->SetEngineType(EngineName);
529          if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1);          if(HasSoloChannel()) pSamplerChannel->GetEngineChannel()->SetMute(-1);
530          UnlockRTNotify();          UnlockRTNotify();
531      }      }
532      catch (LinuxSamplerException e) {      catch (Exception e) {
533           result.Error(e);           result.Error(e);
534      }      }
535      return result.Produce();      return result.Produce();
# Line 588  String LSCPServer::RemoveChannel(uint ui Line 591  String LSCPServer::RemoveChannel(uint ui
591   */   */
592  String LSCPServer::GetAvailableEngines() {  String LSCPServer::GetAvailableEngines() {
593      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));      dmsg(2,("LSCPServer: GetAvailableEngines()\n"));
594      LSCPResultSet result("1");      LSCPResultSet result;
595        try {
596            int n = EngineFactory::AvailableEngineTypes().size();
597            result.Add(n);
598        }
599        catch (Exception e) {
600            result.Error(e);
601        }
602      return result.Produce();      return result.Produce();
603  }  }
604    
# Line 597  String LSCPServer::GetAvailableEngines() Line 607  String LSCPServer::GetAvailableEngines()
607   */   */
608  String LSCPServer::ListAvailableEngines() {  String LSCPServer::ListAvailableEngines() {
609      dmsg(2,("LSCPServer: ListAvailableEngines()\n"));      dmsg(2,("LSCPServer: ListAvailableEngines()\n"));
610      LSCPResultSet result("\'GIG\'");      LSCPResultSet result;
611        try {
612            String s = EngineFactory::AvailableEngineTypesAsString();
613            result.Add(s);
614        }
615        catch (Exception e) {
616            result.Error(e);
617        }
618      return result.Produce();      return result.Produce();
619  }  }
620    
# Line 615  String LSCPServer::GetEngineInfo(String Line 632  String LSCPServer::GetEngineInfo(String
632          result.Add("VERSION",     pEngine->Version());          result.Add("VERSION",     pEngine->Version());
633          EngineFactory::Destroy(pEngine);          EngineFactory::Destroy(pEngine);
634      }      }
635      catch (LinuxSamplerException e) {      catch (Exception e) {
636           result.Error(e);           result.Error(e);
637      }      }
638      UnlockRTNotify();      UnlockRTNotify();
# Line 631  String LSCPServer::GetChannelInfo(uint u Line 648  String LSCPServer::GetChannelInfo(uint u
648      LSCPResultSet result;      LSCPResultSet result;
649      try {      try {
650          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
651          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
652          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
653    
654          //Defaults values          //Defaults values
# Line 645  String LSCPServer::GetChannelInfo(uint u Line 662  String LSCPServer::GetChannelInfo(uint u
662          String AudioRouting;          String AudioRouting;
663          int Mute = 0;          int Mute = 0;
664          bool Solo = false;          bool Solo = false;
665            String MidiInstrumentMap;
666    
667          if (pEngineChannel) {          if (pEngineChannel) {
668              EngineName          = pEngineChannel->EngineName();              EngineName          = pEngineChannel->EngineName();
# Line 662  String LSCPServer::GetChannelInfo(uint u Line 680  String LSCPServer::GetChannelInfo(uint u
680              }              }
681              Mute = pEngineChannel->GetMute();              Mute = pEngineChannel->GetMute();
682              Solo = pEngineChannel->GetSolo();              Solo = pEngineChannel->GetSolo();
683                if (pEngineChannel->UsesNoMidiInstrumentMap())
684                    MidiInstrumentMap = "NONE";
685                else if (pEngineChannel->UsesDefaultMidiInstrumentMap())
686                    MidiInstrumentMap = "DEFAULT";
687                else
688                    MidiInstrumentMap = ToString(pEngineChannel->GetMidiInstrumentMap());
689          }          }
690    
691          result.Add("ENGINE_NAME", EngineName);          result.Add("ENGINE_NAME", EngineName);
# Line 683  String LSCPServer::GetChannelInfo(uint u Line 707  String LSCPServer::GetChannelInfo(uint u
707          result.Add("INSTRUMENT_STATUS", InstrumentStatus);          result.Add("INSTRUMENT_STATUS", InstrumentStatus);
708          result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false"));          result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false"));
709          result.Add("SOLO", Solo);          result.Add("SOLO", Solo);
710            result.Add("MIDI_INSTRUMENT_MAP", MidiInstrumentMap);
711      }      }
712      catch (LinuxSamplerException e) {      catch (Exception e) {
713           result.Error(e);           result.Error(e);
714      }      }
715      return result.Produce();      return result.Produce();
# Line 699  String LSCPServer::GetVoiceCount(uint ui Line 724  String LSCPServer::GetVoiceCount(uint ui
724      LSCPResultSet result;      LSCPResultSet result;
725      try {      try {
726          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
727          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
728          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
729          if (!pEngineChannel) throw LinuxSamplerException("No engine loaded on sampler channel");          if (!pEngineChannel) throw Exception("No engine loaded on sampler channel");
730          if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");          if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel");
731          result.Add(pEngineChannel->GetEngine()->VoiceCount());          result.Add(pEngineChannel->GetEngine()->VoiceCount());
732      }      }
733      catch (LinuxSamplerException e) {      catch (Exception e) {
734           result.Error(e);           result.Error(e);
735      }      }
736      return result.Produce();      return result.Produce();
# Line 720  String LSCPServer::GetStreamCount(uint u Line 745  String LSCPServer::GetStreamCount(uint u
745      LSCPResultSet result;      LSCPResultSet result;
746      try {      try {
747          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
748          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
749          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
750          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
751          if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");          if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel");
752          result.Add(pEngineChannel->GetEngine()->DiskStreamCount());          result.Add(pEngineChannel->GetEngine()->DiskStreamCount());
753      }      }
754      catch (LinuxSamplerException e) {      catch (Exception e) {
755           result.Error(e);           result.Error(e);
756      }      }
757      return result.Produce();      return result.Produce();
# Line 741  String LSCPServer::GetBufferFill(fill_re Line 766  String LSCPServer::GetBufferFill(fill_re
766      LSCPResultSet result;      LSCPResultSet result;
767      try {      try {
768          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
769          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
770          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
771          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
772          if (!pEngineChannel->GetEngine()) throw LinuxSamplerException("No audio output device connected to sampler channel");          if (!pEngineChannel->GetEngine()) throw Exception("No audio output device connected to sampler channel");
773          if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA");          if (!pEngineChannel->GetEngine()->DiskStreamSupported()) result.Add("NA");
774          else {          else {
775              switch (ResponseType) {              switch (ResponseType) {
# Line 755  String LSCPServer::GetBufferFill(fill_re Line 780  String LSCPServer::GetBufferFill(fill_re
780                      result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage());                      result.Add(pEngineChannel->GetEngine()->DiskStreamBufferFillPercentage());
781                      break;                      break;
782                  default:                  default:
783                      throw LinuxSamplerException("Unknown fill response type");                      throw Exception("Unknown fill response type");
784              }              }
785          }          }
786      }      }
787      catch (LinuxSamplerException e) {      catch (Exception e) {
788           result.Error(e);           result.Error(e);
789      }      }
790      return result.Produce();      return result.Produce();
# Line 772  String LSCPServer::GetAvailableAudioOutp Line 797  String LSCPServer::GetAvailableAudioOutp
797          int n = AudioOutputDeviceFactory::AvailableDrivers().size();          int n = AudioOutputDeviceFactory::AvailableDrivers().size();
798          result.Add(n);          result.Add(n);
799      }      }
800      catch (LinuxSamplerException e) {      catch (Exception e) {
801          result.Error(e);          result.Error(e);
802      }      }
803      return result.Produce();      return result.Produce();
# Line 785  String LSCPServer::ListAvailableAudioOut Line 810  String LSCPServer::ListAvailableAudioOut
810          String s = AudioOutputDeviceFactory::AvailableDriversAsString();          String s = AudioOutputDeviceFactory::AvailableDriversAsString();
811          result.Add(s);          result.Add(s);
812      }      }
813      catch (LinuxSamplerException e) {      catch (Exception e) {
814          result.Error(e);          result.Error(e);
815      }      }
816      return result.Produce();      return result.Produce();
# Line 798  String LSCPServer::GetAvailableMidiInput Line 823  String LSCPServer::GetAvailableMidiInput
823          int n = MidiInputDeviceFactory::AvailableDrivers().size();          int n = MidiInputDeviceFactory::AvailableDrivers().size();
824          result.Add(n);          result.Add(n);
825      }      }
826      catch (LinuxSamplerException e) {      catch (Exception e) {
827          result.Error(e);          result.Error(e);
828      }      }
829      return result.Produce();      return result.Produce();
# Line 811  String LSCPServer::ListAvailableMidiInpu Line 836  String LSCPServer::ListAvailableMidiInpu
836          String s = MidiInputDeviceFactory::AvailableDriversAsString();          String s = MidiInputDeviceFactory::AvailableDriversAsString();
837          result.Add(s);          result.Add(s);
838      }      }
839      catch (LinuxSamplerException e) {      catch (Exception e) {
840          result.Error(e);          result.Error(e);
841      }      }
842      return result.Produce();      return result.Produce();
# Line 835  String LSCPServer::GetMidiInputDriverInf Line 860  String LSCPServer::GetMidiInputDriverInf
860              result.Add("PARAMETERS", s);              result.Add("PARAMETERS", s);
861          }          }
862      }      }
863      catch (LinuxSamplerException e) {      catch (Exception e) {
864          result.Error(e);          result.Error(e);
865      }      }
866      return result.Produce();      return result.Produce();
# Line 859  String LSCPServer::GetAudioOutputDriverI Line 884  String LSCPServer::GetAudioOutputDriverI
884              result.Add("PARAMETERS", s);              result.Add("PARAMETERS", s);
885          }          }
886      }      }
887      catch (LinuxSamplerException e) {      catch (Exception e) {
888          result.Error(e);          result.Error(e);
889      }      }
890      return result.Produce();      return result.Produce();
# Line 886  String LSCPServer::GetMidiInputDriverPar Line 911  String LSCPServer::GetMidiInputDriverPar
911          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);
912          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);
913      }      }
914      catch (LinuxSamplerException e) {      catch (Exception e) {
915          result.Error(e);          result.Error(e);
916      }      }
917      return result.Produce();      return result.Produce();
# Line 913  String LSCPServer::GetAudioOutputDriverP Line 938  String LSCPServer::GetAudioOutputDriverP
938          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);          if (oRangeMax)      result.Add("RANGE_MAX",     *oRangeMax);
939          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);          if (oPossibilities) result.Add("POSSIBILITIES", *oPossibilities);
940      }      }
941      catch (LinuxSamplerException e) {      catch (Exception e) {
942          result.Error(e);          result.Error(e);
943      }      }
944      return result.Produce();      return result.Produce();
# Line 926  String LSCPServer::GetAudioOutputDeviceC Line 951  String LSCPServer::GetAudioOutputDeviceC
951          uint count = pSampler->AudioOutputDevices();          uint count = pSampler->AudioOutputDevices();
952          result.Add(count); // success          result.Add(count); // success
953      }      }
954      catch (LinuxSamplerException e) {      catch (Exception e) {
955          result.Error(e);          result.Error(e);
956      }      }
957      return result.Produce();      return result.Produce();
# Line 939  String LSCPServer::GetMidiInputDeviceCou Line 964  String LSCPServer::GetMidiInputDeviceCou
964          uint count = pSampler->MidiInputDevices();          uint count = pSampler->MidiInputDevices();
965          result.Add(count); // success          result.Add(count); // success
966      }      }
967      catch (LinuxSamplerException e) {      catch (Exception e) {
968          result.Error(e);          result.Error(e);
969      }      }
970      return result.Produce();      return result.Produce();
# Line 958  String LSCPServer::GetAudioOutputDevices Line 983  String LSCPServer::GetAudioOutputDevices
983          }          }
984          result.Add(s);          result.Add(s);
985      }      }
986      catch (LinuxSamplerException e) {      catch (Exception e) {
987          result.Error(e);          result.Error(e);
988      }      }
989      return result.Produce();      return result.Produce();
# Line 977  String LSCPServer::GetMidiInputDevices() Line 1002  String LSCPServer::GetMidiInputDevices()
1002          }          }
1003          result.Add(s);          result.Add(s);
1004      }      }
1005      catch (LinuxSamplerException e) {      catch (Exception e) {
1006          result.Error(e);          result.Error(e);
1007      }      }
1008      return result.Produce();      return result.Produce();
# Line 988  String LSCPServer::GetAudioOutputDeviceI Line 1013  String LSCPServer::GetAudioOutputDeviceI
1013      LSCPResultSet result;      LSCPResultSet result;
1014      try {      try {
1015          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1016          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + ".");
1017          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
1018          result.Add("DRIVER", pDevice->Driver());          result.Add("DRIVER", pDevice->Driver());
1019          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
# Line 997  String LSCPServer::GetAudioOutputDeviceI Line 1022  String LSCPServer::GetAudioOutputDeviceI
1022              result.Add(iter->first, iter->second->Value());              result.Add(iter->first, iter->second->Value());
1023          }          }
1024      }      }
1025      catch (LinuxSamplerException e) {      catch (Exception e) {
1026          result.Error(e);          result.Error(e);
1027      }      }
1028      return result.Produce();      return result.Produce();
# Line 1008  String LSCPServer::GetMidiInputDeviceInf Line 1033  String LSCPServer::GetMidiInputDeviceInf
1033      LSCPResultSet result;      LSCPResultSet result;
1034      try {      try {
1035          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1036          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1037          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1038          result.Add("DRIVER", pDevice->Driver());          result.Add("DRIVER", pDevice->Driver());
1039          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
# Line 1017  String LSCPServer::GetMidiInputDeviceInf Line 1042  String LSCPServer::GetMidiInputDeviceInf
1042              result.Add(iter->first, iter->second->Value());              result.Add(iter->first, iter->second->Value());
1043          }          }
1044      }      }
1045      catch (LinuxSamplerException e) {      catch (Exception e) {
1046          result.Error(e);          result.Error(e);
1047      }      }
1048      return result.Produce();      return result.Produce();
# Line 1028  String LSCPServer::GetMidiInputPortInfo( Line 1053  String LSCPServer::GetMidiInputPortInfo(
1053      try {      try {
1054          // get MIDI input device          // get MIDI input device
1055          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1056          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1057          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1058    
1059          // get MIDI port          // get MIDI port
1060          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);
1061          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");          if (!pMidiInputPort) throw Exception("There is no MIDI input port with index " + ToString(PortIndex) + ".");
1062    
1063          // return the values of all MIDI port parameters          // return the values of all MIDI port parameters
1064          std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();
# Line 1042  String LSCPServer::GetMidiInputPortInfo( Line 1067  String LSCPServer::GetMidiInputPortInfo(
1067              result.Add(iter->first, iter->second->Value());              result.Add(iter->first, iter->second->Value());
1068          }          }
1069      }      }
1070      catch (LinuxSamplerException e) {      catch (Exception e) {
1071          result.Error(e);          result.Error(e);
1072      }      }
1073      return result.Produce();      return result.Produce();
# Line 1054  String LSCPServer::GetAudioOutputChannel Line 1079  String LSCPServer::GetAudioOutputChannel
1079      try {      try {
1080          // get audio output device          // get audio output device
1081          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1082          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + ".");
1083          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
1084    
1085          // get audio channel          // get audio channel
1086          AudioChannel* pChannel = pDevice->Channel(ChannelId);          AudioChannel* pChannel = pDevice->Channel(ChannelId);
1087          if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + ".");          if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + ".");
1088    
1089          // return the values of all audio channel parameters          // return the values of all audio channel parameters
1090          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();
# Line 1068  String LSCPServer::GetAudioOutputChannel Line 1093  String LSCPServer::GetAudioOutputChannel
1093              result.Add(iter->first, iter->second->Value());              result.Add(iter->first, iter->second->Value());
1094          }          }
1095      }      }
1096      catch (LinuxSamplerException e) {      catch (Exception e) {
1097          result.Error(e);          result.Error(e);
1098      }      }
1099      return result.Produce();      return result.Produce();
# Line 1080  String LSCPServer::GetMidiInputPortParam Line 1105  String LSCPServer::GetMidiInputPortParam
1105      try {      try {
1106          // get MIDI input device          // get MIDI input device
1107          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1108          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no midi input device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw Exception("There is no midi input device with index " + ToString(DeviceId) + ".");
1109          MidiInputDevice* pDevice = devices[DeviceId];          MidiInputDevice* pDevice = devices[DeviceId];
1110    
1111          // get midi port          // get midi port
1112          MidiInputPort* pPort = pDevice->GetPort(PortId);          MidiInputPort* pPort = pDevice->GetPort(PortId);
1113          if (!pPort) throw LinuxSamplerException("Midi input device does not have port " + ToString(PortId) + ".");          if (!pPort) throw Exception("Midi input device does not have port " + ToString(PortId) + ".");
1114    
1115          // get desired port parameter          // get desired port parameter
1116          std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pPort->PortParameters();
1117          if (!parameters.count(ParameterName)) throw LinuxSamplerException("Midi port does not provide a parameter '" + ParameterName + "'.");          if (!parameters.count(ParameterName)) throw Exception("Midi port does not provide a parameter '" + ParameterName + "'.");
1118          DeviceRuntimeParameter* pParameter = parameters[ParameterName];          DeviceRuntimeParameter* pParameter = parameters[ParameterName];
1119    
1120          // return all fields of this audio channel parameter          // return all fields of this audio channel parameter
# Line 1101  String LSCPServer::GetMidiInputPortParam Line 1126  String LSCPServer::GetMidiInputPortParam
1126          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
1127          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
1128      }      }
1129      catch (LinuxSamplerException e) {      catch (Exception e) {
1130          result.Error(e);          result.Error(e);
1131      }      }
1132      return result.Produce();      return result.Produce();
# Line 1113  String LSCPServer::GetAudioOutputChannel Line 1138  String LSCPServer::GetAudioOutputChannel
1138      try {      try {
1139          // get audio output device          // get audio output device
1140          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1141          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + ".");
1142          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
1143    
1144          // get audio channel          // get audio channel
1145          AudioChannel* pChannel = pDevice->Channel(ChannelId);          AudioChannel* pChannel = pDevice->Channel(ChannelId);
1146          if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + ".");          if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + ".");
1147    
1148          // get desired audio channel parameter          // get desired audio channel parameter
1149          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();
1150          if (!parameters.count(ParameterName)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParameterName + "'.");          if (!parameters.count(ParameterName)) throw Exception("Audio channel does not provide a parameter '" + ParameterName + "'.");
1151          DeviceRuntimeParameter* pParameter = parameters[ParameterName];          DeviceRuntimeParameter* pParameter = parameters[ParameterName];
1152    
1153          // return all fields of this audio channel parameter          // return all fields of this audio channel parameter
# Line 1134  String LSCPServer::GetAudioOutputChannel Line 1159  String LSCPServer::GetAudioOutputChannel
1159          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());          if (pParameter->RangeMax())      result.Add("RANGE_MAX",     *pParameter->RangeMax());
1160          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());          if (pParameter->Possibilities()) result.Add("POSSIBILITIES", *pParameter->Possibilities());
1161      }      }
1162      catch (LinuxSamplerException e) {      catch (Exception e) {
1163          result.Error(e);          result.Error(e);
1164      }      }
1165      return result.Produce();      return result.Produce();
# Line 1146  String LSCPServer::SetAudioOutputChannel Line 1171  String LSCPServer::SetAudioOutputChannel
1171      try {      try {
1172          // get audio output device          // get audio output device
1173          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1174          if (!devices.count(DeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceId) + ".");          if (!devices.count(DeviceId)) throw Exception("There is no audio output device with index " + ToString(DeviceId) + ".");
1175          AudioOutputDevice* pDevice = devices[DeviceId];          AudioOutputDevice* pDevice = devices[DeviceId];
1176    
1177          // get audio channel          // get audio channel
1178          AudioChannel* pChannel = pDevice->Channel(ChannelId);          AudioChannel* pChannel = pDevice->Channel(ChannelId);
1179          if (!pChannel) throw LinuxSamplerException("Audio output device does not have audio channel " + ToString(ChannelId) + ".");          if (!pChannel) throw Exception("Audio output device does not have audio channel " + ToString(ChannelId) + ".");
1180    
1181          // get desired audio channel parameter          // get desired audio channel parameter
1182          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pChannel->ChannelParameters();
1183          if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio channel does not provide a parameter '" + ParamKey + "'.");          if (!parameters.count(ParamKey)) throw Exception("Audio channel does not provide a parameter '" + ParamKey + "'.");
1184          DeviceRuntimeParameter* pParameter = parameters[ParamKey];          DeviceRuntimeParameter* pParameter = parameters[ParamKey];
1185    
1186          // set new channel parameter value          // set new channel parameter value
1187          pParameter->SetValue(ParamVal);          pParameter->SetValue(ParamVal);
1188      }      }
1189      catch (LinuxSamplerException e) {      catch (Exception e) {
1190          result.Error(e);          result.Error(e);
1191      }      }
1192      return result.Produce();      return result.Produce();
# Line 1172  String LSCPServer::SetAudioOutputDeviceP Line 1197  String LSCPServer::SetAudioOutputDeviceP
1197      LSCPResultSet result;      LSCPResultSet result;
1198      try {      try {
1199          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint,AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1200          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no audio output device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no audio output device with index " + ToString(DeviceIndex) + ".");
1201          AudioOutputDevice* pDevice = devices[DeviceIndex];          AudioOutputDevice* pDevice = devices[DeviceIndex];
1202          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
1203          if (!parameters.count(ParamKey)) throw LinuxSamplerException("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");          if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");
1204          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1205      }      }
1206      catch (LinuxSamplerException e) {      catch (Exception e) {
1207          result.Error(e);          result.Error(e);
1208      }      }
1209      return result.Produce();      return result.Produce();
# Line 1189  String LSCPServer::SetMidiInputDevicePar Line 1214  String LSCPServer::SetMidiInputDevicePar
1214      LSCPResultSet result;      LSCPResultSet result;
1215      try {      try {
1216          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1217          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1218          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1219          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();          std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters();
1220          if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");          if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'");
1221          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1222      }      }
1223      catch (LinuxSamplerException e) {      catch (Exception e) {
1224          result.Error(e);          result.Error(e);
1225      }      }
1226      return result.Produce();      return result.Produce();
# Line 1207  String LSCPServer::SetMidiInputPortParam Line 1232  String LSCPServer::SetMidiInputPortParam
1232      try {      try {
1233          // get MIDI input device          // get MIDI input device
1234          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint,MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1235          if (!devices.count(DeviceIndex)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");          if (!devices.count(DeviceIndex)) throw Exception("There is no MIDI input device with index " + ToString(DeviceIndex) + ".");
1236          MidiInputDevice* pDevice = devices[DeviceIndex];          MidiInputDevice* pDevice = devices[DeviceIndex];
1237    
1238          // get MIDI port          // get MIDI port
1239          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);          MidiInputPort* pMidiInputPort = pDevice->GetPort(PortIndex);
1240          if (!pMidiInputPort) throw LinuxSamplerException("There is no MIDI input port with index " + ToString(PortIndex) + ".");          if (!pMidiInputPort) throw Exception("There is no MIDI input port with index " + ToString(PortIndex) + ".");
1241    
1242          // set port parameter value          // set port parameter value
1243          std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();          std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters();
1244          if (!parameters.count(ParamKey)) throw LinuxSamplerException("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'");          if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'");
1245          parameters[ParamKey]->SetValue(ParamVal);          parameters[ParamKey]->SetValue(ParamVal);
1246      }      }
1247      catch (LinuxSamplerException e) {      catch (Exception e) {
1248          result.Error(e);          result.Error(e);
1249      }      }
1250      return result.Produce();      return result.Produce();
# Line 1234  String LSCPServer::SetAudioOutputChannel Line 1259  String LSCPServer::SetAudioOutputChannel
1259      LSCPResultSet result;      LSCPResultSet result;
1260      try {      try {
1261          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1262          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1263          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1264          if (!pEngineChannel) throw LinuxSamplerException("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel));          if (!pEngineChannel) throw Exception("No engine type yet assigned to sampler channel " + ToString(uiSamplerChannel));
1265          if (!pSamplerChannel->GetAudioOutputDevice()) throw LinuxSamplerException("No audio output device connected to sampler channel " + ToString(uiSamplerChannel));          if (!pSamplerChannel->GetAudioOutputDevice()) throw Exception("No audio output device connected to sampler channel " + ToString(uiSamplerChannel));
1266          pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel);          pEngineChannel->SetOutputChannel(ChannelAudioOutputChannel, AudioOutputDeviceInputChannel);
1267      }      }
1268      catch (LinuxSamplerException e) {      catch (Exception e) {
1269           result.Error(e);           result.Error(e);
1270      }      }
1271      return result.Produce();      return result.Produce();
# Line 1252  String LSCPServer::SetAudioOutputDevice( Line 1277  String LSCPServer::SetAudioOutputDevice(
1277      LockRTNotify();      LockRTNotify();
1278      try {      try {
1279          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1280          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1281          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();          std::map<uint, AudioOutputDevice*> devices = pSampler->GetAudioOutputDevices();
1282          if (!devices.count(AudioDeviceId)) throw LinuxSamplerException("There is no audio output device with index " + ToString(AudioDeviceId));          if (!devices.count(AudioDeviceId)) throw Exception("There is no audio output device with index " + ToString(AudioDeviceId));
1283          AudioOutputDevice* pDevice = devices[AudioDeviceId];          AudioOutputDevice* pDevice = devices[AudioDeviceId];
1284          pSamplerChannel->SetAudioOutputDevice(pDevice);          pSamplerChannel->SetAudioOutputDevice(pDevice);
1285      }      }
1286      catch (LinuxSamplerException e) {      catch (Exception e) {
1287           result.Error(e);           result.Error(e);
1288      }      }
1289      UnlockRTNotify();      UnlockRTNotify();
# Line 1271  String LSCPServer::SetAudioOutputType(St Line 1296  String LSCPServer::SetAudioOutputType(St
1296      LockRTNotify();      LockRTNotify();
1297      try {      try {
1298          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1299          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1300          // Driver type name aliasing...          // Driver type name aliasing...
1301          if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA";          if (AudioOutputDriver == "Alsa") AudioOutputDriver = "ALSA";
1302          if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK";          if (AudioOutputDriver == "Jack") AudioOutputDriver = "JACK";
# Line 1293  String LSCPServer::SetAudioOutputType(St Line 1318  String LSCPServer::SetAudioOutputType(St
1318          }          }
1319          // Must have a device...          // Must have a device...
1320          if (pDevice == NULL)          if (pDevice == NULL)
1321              throw LinuxSamplerException("Internal error: could not create audio output device.");              throw Exception("Internal error: could not create audio output device.");
1322          // Set it as the current channel device...          // Set it as the current channel device...
1323          pSamplerChannel->SetAudioOutputDevice(pDevice);          pSamplerChannel->SetAudioOutputDevice(pDevice);
1324      }      }
1325      catch (LinuxSamplerException e) {      catch (Exception e) {
1326           result.Error(e);           result.Error(e);
1327      }      }
1328      UnlockRTNotify();      UnlockRTNotify();
# Line 1309  String LSCPServer::SetMIDIInputPort(uint Line 1334  String LSCPServer::SetMIDIInputPort(uint
1334      LSCPResultSet result;      LSCPResultSet result;
1335      try {      try {
1336          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1337          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1338          pSamplerChannel->SetMidiInputPort(MIDIPort);          pSamplerChannel->SetMidiInputPort(MIDIPort);
1339      }      }
1340      catch (LinuxSamplerException e) {      catch (Exception e) {
1341           result.Error(e);           result.Error(e);
1342      }      }
1343      return result.Produce();      return result.Produce();
# Line 1323  String LSCPServer::SetMIDIInputChannel(u Line 1348  String LSCPServer::SetMIDIInputChannel(u
1348      LSCPResultSet result;      LSCPResultSet result;
1349      try {      try {
1350          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1351          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1352          pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel);          pSamplerChannel->SetMidiInputChannel((midi_chan_t) MIDIChannel);
1353      }      }
1354      catch (LinuxSamplerException e) {      catch (Exception e) {
1355           result.Error(e);           result.Error(e);
1356      }      }
1357      return result.Produce();      return result.Produce();
# Line 1337  String LSCPServer::SetMIDIInputDevice(ui Line 1362  String LSCPServer::SetMIDIInputDevice(ui
1362      LSCPResultSet result;      LSCPResultSet result;
1363      try {      try {
1364          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1365          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1366          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices = pSampler->GetMidiInputDevices();
1367          if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));          if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId));
1368          MidiInputDevice* pDevice = devices[MIDIDeviceId];          MidiInputDevice* pDevice = devices[MIDIDeviceId];
1369          pSamplerChannel->SetMidiInputDevice(pDevice);          pSamplerChannel->SetMidiInputDevice(pDevice);
1370      }      }
1371      catch (LinuxSamplerException e) {      catch (Exception e) {
1372           result.Error(e);           result.Error(e);
1373      }      }
1374      return result.Produce();      return result.Produce();
# Line 1354  String LSCPServer::SetMIDIInputType(Stri Line 1379  String LSCPServer::SetMIDIInputType(Stri
1379      LSCPResultSet result;      LSCPResultSet result;
1380      try {      try {
1381          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1382          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1383          // Driver type name aliasing...          // Driver type name aliasing...
1384          if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA";          if (MidiInputDriver == "Alsa") MidiInputDriver = "ALSA";
1385          // Check if there's one MIDI input device already created          // Check if there's one MIDI input device already created
# Line 1378  String LSCPServer::SetMIDIInputType(Stri Line 1403  String LSCPServer::SetMIDIInputType(Stri
1403          }          }
1404          // Must have a device...          // Must have a device...
1405          if (pDevice == NULL)          if (pDevice == NULL)
1406              throw LinuxSamplerException("Internal error: could not create MIDI input device.");              throw Exception("Internal error: could not create MIDI input device.");
1407          // Set it as the current channel device...          // Set it as the current channel device...
1408          pSamplerChannel->SetMidiInputDevice(pDevice);          pSamplerChannel->SetMidiInputDevice(pDevice);
1409      }      }
1410      catch (LinuxSamplerException e) {      catch (Exception e) {
1411           result.Error(e);           result.Error(e);
1412      }      }
1413      return result.Produce();      return result.Produce();
# Line 1397  String LSCPServer::SetMIDIInput(uint MID Line 1422  String LSCPServer::SetMIDIInput(uint MID
1422      LSCPResultSet result;      LSCPResultSet result;
1423      try {      try {
1424          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1425          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1426          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();          std::map<uint, MidiInputDevice*> devices =  pSampler->GetMidiInputDevices();
1427          if (!devices.count(MIDIDeviceId)) throw LinuxSamplerException("There is no MIDI input device with index " + ToString(MIDIDeviceId));          if (!devices.count(MIDIDeviceId)) throw Exception("There is no MIDI input device with index " + ToString(MIDIDeviceId));
1428          MidiInputDevice* pDevice = devices[MIDIDeviceId];          MidiInputDevice* pDevice = devices[MIDIDeviceId];
1429          pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel);          pSamplerChannel->SetMidiInput(pDevice, MIDIPort, (midi_chan_t) MIDIChannel);
1430      }      }
1431      catch (LinuxSamplerException e) {      catch (Exception e) {
1432           result.Error(e);           result.Error(e);
1433      }      }
1434      return result.Produce();      return result.Produce();
# Line 1418  String LSCPServer::SetVolume(double dVol Line 1443  String LSCPServer::SetVolume(double dVol
1443      LSCPResultSet result;      LSCPResultSet result;
1444      try {      try {
1445          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1446          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1447          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1448          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
1449          pEngineChannel->Volume(dVolume);          pEngineChannel->Volume(dVolume);
1450      }      }
1451      catch (LinuxSamplerException e) {      catch (Exception e) {
1452           result.Error(e);           result.Error(e);
1453      }      }
1454      return result.Produce();      return result.Produce();
# Line 1437  String LSCPServer::SetChannelMute(bool b Line 1462  String LSCPServer::SetChannelMute(bool b
1462      LSCPResultSet result;      LSCPResultSet result;
1463      try {      try {
1464          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1465          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1466    
1467          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1468          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
1469    
1470          if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0);          if(!bMute) pEngineChannel->SetMute((HasSoloChannel() && !pEngineChannel->GetSolo()) ? -1 : 0);
1471          else pEngineChannel->SetMute(1);          else pEngineChannel->SetMute(1);
1472      } catch (LinuxSamplerException e) {      } catch (Exception e) {
1473          result.Error(e);          result.Error(e);
1474      }      }
1475      return result.Produce();      return result.Produce();
# Line 1458  String LSCPServer::SetChannelSolo(bool b Line 1483  String LSCPServer::SetChannelSolo(bool b
1483      LSCPResultSet result;      LSCPResultSet result;
1484      try {      try {
1485          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1486          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1487    
1488          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1489          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
1490    
1491          bool oldSolo = pEngineChannel->GetSolo();          bool oldSolo = pEngineChannel->GetSolo();
1492          bool hadSoloChannel = HasSoloChannel();          bool hadSoloChannel = HasSoloChannel();
# Line 1477  String LSCPServer::SetChannelSolo(bool b Line 1502  String LSCPServer::SetChannelSolo(bool b
1502              if(!HasSoloChannel()) UnmuteChannels();              if(!HasSoloChannel()) UnmuteChannels();
1503              else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1);              else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1);
1504          }          }
1505      } catch (LinuxSamplerException e) {      } catch (Exception e) {
1506          result.Error(e);          result.Error(e);
1507      }      }
1508      return result.Produce();      return result.Produce();
# Line 1530  void  LSCPServer::UnmuteChannels() { Line 1555  void  LSCPServer::UnmuteChannels() {
1555      }      }
1556  }  }
1557    
1558    String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name) {
1559        dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n"));
1560    
1561        midi_prog_index_t idx;
1562        idx.midi_bank_msb = (MidiBank >> 7) & 0x7f;
1563        idx.midi_bank_lsb = MidiBank & 0x7f;
1564        idx.midi_prog     = MidiProg;
1565    
1566        MidiInstrumentMapper::entry_t entry;
1567        entry.EngineName      = EngineType;
1568        entry.InstrumentFile  = InstrumentFile;
1569        entry.InstrumentIndex = InstrumentIndex;
1570        entry.LoadMode        = LoadMode;
1571        entry.Volume          = Volume;
1572        entry.Name            = Name;
1573    
1574        LSCPResultSet result;
1575        try {
1576            // PERSISTENT mapping commands might bloock for a long time, so in
1577            // that case we add/replace the mapping in another thread
1578            bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT);
1579            MidiInstrumentMapper::AddOrReplaceEntry(MidiMapID, idx, entry, bInBackground);
1580        } catch (Exception e) {
1581            result.Error(e);
1582        }
1583        return result.Produce();
1584    }
1585    
1586    String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) {
1587        dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n"));
1588    
1589        midi_prog_index_t idx;
1590        idx.midi_bank_msb = (MidiBank >> 7) & 0x7f;
1591        idx.midi_bank_lsb = MidiBank & 0x7f;
1592        idx.midi_prog     = MidiProg;
1593    
1594        LSCPResultSet result;
1595        try {
1596            MidiInstrumentMapper::RemoveEntry(MidiMapID, idx);
1597        } catch (Exception e) {
1598            result.Error(e);
1599        }
1600        return result.Produce();
1601    }
1602    
1603    String LSCPServer::GetMidiInstrumentMappings(uint MidiMapID) {
1604        dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n"));
1605        LSCPResultSet result;
1606        try {
1607            result.Add(MidiInstrumentMapper::Entries(MidiMapID).size());
1608        } catch (Exception e) {
1609            result.Error(e);
1610        }
1611        return result.Produce();
1612    }
1613    
1614    
1615    String LSCPServer::GetAllMidiInstrumentMappings() {
1616        dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n"));
1617        LSCPResultSet result;
1618        std::vector<int> maps = MidiInstrumentMapper::Maps();
1619        int totalMappings = 0;
1620        for (int i = 0; i < maps.size(); i++) {
1621            try {
1622                totalMappings += MidiInstrumentMapper::Entries(maps[i]).size();
1623            } catch (Exception e) { /*NOOP*/ }
1624        }
1625        result.Add(totalMappings);
1626        return result.Produce();
1627    }
1628    
1629    String LSCPServer::GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) {
1630        dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n"));
1631        LSCPResultSet result;
1632        try {
1633            midi_prog_index_t idx;
1634            idx.midi_bank_msb = (MidiBank >> 7) & 0x7f;
1635            idx.midi_bank_lsb = MidiBank & 0x7f;
1636            idx.midi_prog     = MidiProg;
1637    
1638            std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID);
1639            std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx);
1640            if (iter == mappings.end()) result.Error("there is no map entry with that index");
1641            else { // found
1642                result.Add("NAME", iter->second.Name);
1643                result.Add("ENGINE_NAME", iter->second.EngineName);
1644                result.Add("INSTRUMENT_FILE", iter->second.InstrumentFile);
1645                result.Add("INSTRUMENT_NR", (int) iter->second.InstrumentIndex);
1646                String instrumentName;
1647                Engine* pEngine = EngineFactory::Create(iter->second.EngineName);
1648                if (pEngine) {
1649                    if (pEngine->GetInstrumentManager()) {
1650                        InstrumentManager::instrument_id_t instrID;
1651                        instrID.FileName = iter->second.InstrumentFile;
1652                        instrID.Index    = iter->second.InstrumentIndex;
1653                        instrumentName = pEngine->GetInstrumentManager()->GetInstrumentName(instrID);
1654                    }
1655                    EngineFactory::Destroy(pEngine);
1656                }
1657                result.Add("INSTRUMENT_NAME", instrumentName);
1658                switch (iter->second.LoadMode) {
1659                    case MidiInstrumentMapper::ON_DEMAND:
1660                        result.Add("LOAD_MODE", "ON_DEMAND");
1661                        break;
1662                    case MidiInstrumentMapper::ON_DEMAND_HOLD:
1663                        result.Add("LOAD_MODE", "ON_DEMAND_HOLD");
1664                        break;
1665                    case MidiInstrumentMapper::PERSISTENT:
1666                        result.Add("LOAD_MODE", "PERSISTENT");
1667                        break;
1668                    default:
1669                        throw Exception("entry reflects invalid LOAD_MODE, consider this as a bug!");
1670                }
1671                result.Add("VOLUME", iter->second.Volume);
1672            }
1673        } catch (Exception e) {
1674            result.Error(e);
1675        }
1676        return result.Produce();
1677    }
1678    
1679    String LSCPServer::ListMidiInstrumentMappings(uint MidiMapID) {
1680        dmsg(2,("LSCPServer: ListMidiInstrumentMappings()\n"));
1681        LSCPResultSet result;
1682        try {
1683            String s;
1684            std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID);
1685            std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin();
1686            for (; iter != mappings.end(); iter++) {
1687                if (s.size()) s += ",";
1688                s += "{" + ToString(MidiMapID) + ","
1689                         + ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + ","
1690                         + ToString(int(iter->first.midi_prog)) + "}";
1691            }
1692            result.Add(s);
1693        } catch (Exception e) {
1694            result.Error(e);
1695        }
1696        return result.Produce();
1697    }
1698    
1699    String LSCPServer::ListAllMidiInstrumentMappings() {
1700        dmsg(2,("LSCPServer: ListAllMidiInstrumentMappings()\n"));
1701        LSCPResultSet result;
1702        try {
1703            std::vector<int> maps = MidiInstrumentMapper::Maps();
1704            String s;
1705            for (int i = 0; i < maps.size(); i++) {
1706                std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(maps[i]);
1707                std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin();
1708                for (; iter != mappings.end(); iter++) {
1709                    if (s.size()) s += ",";
1710                    s += "{" + ToString(maps[i]) + ","
1711                             + ToString((int(iter->first.midi_bank_msb) << 7) & int(iter->first.midi_bank_lsb)) + ","
1712                             + ToString(int(iter->first.midi_prog)) + "}";
1713                }
1714            }
1715            result.Add(s);
1716        } catch (Exception e) {
1717            result.Error(e);
1718        }
1719        return result.Produce();
1720    }
1721    
1722    String LSCPServer::ClearMidiInstrumentMappings(uint MidiMapID) {
1723        dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n"));
1724        LSCPResultSet result;
1725        try {
1726            MidiInstrumentMapper::RemoveAllEntries(MidiMapID);
1727        } catch (Exception e) {
1728            result.Error(e);
1729        }
1730        return result.Produce();
1731    }
1732    
1733    String LSCPServer::ClearAllMidiInstrumentMappings() {
1734        dmsg(2,("LSCPServer: ClearAllMidiInstrumentMappings()\n"));
1735        LSCPResultSet result;
1736        try {
1737            std::vector<int> maps = MidiInstrumentMapper::Maps();
1738            for (int i = 0; i < maps.size(); i++)
1739                MidiInstrumentMapper::RemoveAllEntries(maps[i]);
1740        } catch (Exception e) {
1741            result.Error(e);
1742        }
1743        return result.Produce();
1744    }
1745    
1746    String LSCPServer::AddMidiInstrumentMap(String MapName) {
1747        dmsg(2,("LSCPServer: AddMidiInstrumentMap()\n"));
1748        LSCPResultSet result;
1749        try {
1750            int MapID = MidiInstrumentMapper::AddMap(MapName);
1751            result = LSCPResultSet(MapID);
1752        } catch (Exception e) {
1753            result.Error(e);
1754        }
1755        return result.Produce();
1756    }
1757    
1758    String LSCPServer::RemoveMidiInstrumentMap(uint MidiMapID) {
1759        dmsg(2,("LSCPServer: RemoveMidiInstrumentMap()\n"));
1760        LSCPResultSet result;
1761        try {
1762            MidiInstrumentMapper::RemoveMap(MidiMapID);
1763        } catch (Exception e) {
1764            result.Error(e);
1765        }
1766        return result.Produce();
1767    }
1768    
1769    String LSCPServer::RemoveAllMidiInstrumentMaps() {
1770        dmsg(2,("LSCPServer: RemoveAllMidiInstrumentMaps()\n"));
1771        LSCPResultSet result;
1772        try {
1773            MidiInstrumentMapper::RemoveAllMaps();
1774        } catch (Exception e) {
1775            result.Error(e);
1776        }
1777        return result.Produce();
1778    }
1779    
1780    String LSCPServer::GetMidiInstrumentMaps() {
1781        dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n"));
1782        LSCPResultSet result;
1783        try {
1784            result.Add(MidiInstrumentMapper::Maps().size());
1785        } catch (Exception e) {
1786            result.Error(e);
1787        }
1788        return result.Produce();
1789    }
1790    
1791    String LSCPServer::ListMidiInstrumentMaps() {
1792        dmsg(2,("LSCPServer: ListMidiInstrumentMaps()\n"));
1793        LSCPResultSet result;
1794        try {
1795            std::vector<int> maps = MidiInstrumentMapper::Maps();
1796            String sList;
1797            for (int i = 0; i < maps.size(); i++) {
1798                if (sList != "") sList += ",";
1799                sList += ToString(maps[i]);
1800            }
1801            result.Add(sList);
1802        } catch (Exception e) {
1803            result.Error(e);
1804        }
1805        return result.Produce();
1806    }
1807    
1808    String LSCPServer::GetMidiInstrumentMap(uint MidiMapID) {
1809        dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n"));
1810        LSCPResultSet result;
1811        try {
1812            result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID));
1813        } catch (Exception e) {
1814            result.Error(e);
1815        }
1816        return result.Produce();
1817    }
1818    
1819    String LSCPServer::SetMidiInstrumentMapName(uint MidiMapID, String NewName) {
1820        dmsg(2,("LSCPServer: SetMidiInstrumentMapName()\n"));
1821        LSCPResultSet result;
1822        try {
1823            MidiInstrumentMapper::RenameMap(MidiMapID, NewName);
1824        } catch (Exception e) {
1825            result.Error(e);
1826        }
1827        return result.Produce();
1828    }
1829    
1830    /**
1831     * Set the MIDI instrument map the given sampler channel shall use for
1832     * handling MIDI program change messages. There are the following two
1833     * special (negative) values:
1834     *
1835     *    - (-1) :  set to NONE (ignore program changes)
1836     *    - (-2) :  set to DEFAULT map
1837     */
1838    String LSCPServer::SetChannelMap(uint uiSamplerChannel, int MidiMapID) {
1839        dmsg(2,("LSCPServer: SetChannelMap()\n"));
1840        LSCPResultSet result;
1841        try {
1842            SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1843            if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1844    
1845            EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1846            if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet");
1847    
1848            if      (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone();
1849            else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault();
1850            else                      pEngineChannel->SetMidiInstrumentMap(MidiMapID);
1851        } catch (Exception e) {
1852            result.Error(e);
1853        }
1854        return result.Produce();
1855    }
1856    
1857  /**  /**
1858   * Will be called by the parser to reset a particular sampler channel.   * Will be called by the parser to reset a particular sampler channel.
1859   */   */
# Line 1538  String LSCPServer::ResetChannel(uint uiS Line 1862  String LSCPServer::ResetChannel(uint uiS
1862      LSCPResultSet result;      LSCPResultSet result;
1863      try {      try {
1864          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);          SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel);
1865          if (!pSamplerChannel) throw LinuxSamplerException("Invalid sampler channel number " + ToString(uiSamplerChannel));          if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel));
1866          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
1867          if (!pEngineChannel) throw LinuxSamplerException("No engine type assigned to sampler channel");          if (!pEngineChannel) throw Exception("No engine type assigned to sampler channel");
1868          pEngineChannel->Reset();          pEngineChannel->Reset();
1869      }      }
1870      catch (LinuxSamplerException e) {      catch (Exception e) {
1871           result.Error(e);           result.Error(e);
1872      }      }
1873      return result.Produce();      return result.Produce();
# Line 1568  String LSCPServer::GetServerInfo() { Line 1892  String LSCPServer::GetServerInfo() {
1892      LSCPResultSet result;      LSCPResultSet result;
1893      result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler");      result.Add("DESCRIPTION", "LinuxSampler - modular, streaming capable sampler");
1894      result.Add("VERSION", VERSION);      result.Add("VERSION", VERSION);
1895      result.Add("PROTOCOL_VERSION", "1.0");      result.Add("PROTOCOL_VERSION", ToString(LSCP_RELEASE_MAJOR) + "." + ToString(LSCP_RELEASE_MINOR));
1896      return result.Produce();      return result.Produce();
1897  }  }
1898    
# Line 1660  String LSCPServer::SetEcho(yyparse_param Line 1984  String LSCPServer::SetEcho(yyparse_param
1984      try {      try {
1985          if      (boolean_value == 0) pSession->bVerbose = false;          if      (boolean_value == 0) pSession->bVerbose = false;
1986          else if (boolean_value == 1) pSession->bVerbose = true;          else if (boolean_value == 1) pSession->bVerbose = true;
1987          else throw LinuxSamplerException("Not a boolean value, must either be 0 or 1");          else throw Exception("Not a boolean value, must either be 0 or 1");
1988      }      }
1989      catch (LinuxSamplerException e) {      catch (Exception e) {
1990           result.Error(e);           result.Error(e);
1991      }      }
1992      return result.Produce();      return result.Produce();

Legend:
Removed from v.841  
changed lines
  Added in v.973

  ViewVC Help
Powered by ViewVC