--- linuxsampler/trunk/src/Sampler.cpp 2006/06/27 22:57:37 880 +++ linuxsampler/trunk/src/Sampler.cpp 2007/01/03 17:49:44 1008 @@ -3,20 +3,20 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005, 2006 Christian Schoenebeck * + * Copyright (C) 2005 - 2007 Christian Schoenebeck * * * - * This program is free software; you can redistribute it and/or modify * + * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * This program is distributed in the hope that it will be useful, * + * This library is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the Free Software * + * along with this library; if not, write to the Free Software * * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * * MA 02111-1307 USA * ***************************************************************************/ @@ -29,6 +29,7 @@ #include "engines/EngineChannelFactory.h" #include "drivers/audio/AudioOutputDeviceFactory.h" #include "drivers/midi/MidiInputDeviceFactory.h" +#include "drivers/midi/MidiInstrumentMapper.h" #include "network/lscpserver.h" namespace LinuxSampler { @@ -108,6 +109,8 @@ } void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) { + if(pAudioOutputDevice == pDevice) return; + // disconnect old device if (pAudioOutputDevice && pEngineChannel) { Engine* engine = pEngineChannel->GetEngine(); @@ -289,6 +292,14 @@ return AudioOutputDeviceFactory::AvailableDrivers(); } + std::vector Sampler::AvailableMidiInputDrivers() { + return MidiInputDeviceFactory::AvailableDrivers(); + } + + std::vector Sampler::AvailableEngineTypes() { + return EngineFactory::AvailableEngineTypes(); + } + AudioOutputDevice* Sampler::CreateAudioOutputDevice(String AudioDriver, std::map Parameters) throw (Exception) { // create new device AudioOutputDevice* pDevice = AudioOutputDeviceFactory::Create(AudioDriver, Parameters); @@ -301,6 +312,7 @@ } } + LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_count, AudioOutputDevices())); return pDevice; } @@ -337,6 +349,7 @@ // destroy and free device from memory delete pDevice; + LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_count, AudioOutputDevices())); break; } } @@ -359,6 +372,7 @@ // destroy and free device from memory delete pDevice; + LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_count, MidiInputDevices())); break; } } @@ -376,6 +390,7 @@ } } + LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_count, MidiInputDevices())); return pDevice; } @@ -429,6 +444,15 @@ std::cerr << "Sampler::Reset(): Exception occured while trying to delete all audio output devices, exiting.\n" << std::flush; exit(EXIT_FAILURE); } + + // delete MIDI instrument maps + try { + MidiInstrumentMapper::RemoveAllMaps(); + } + catch(...) { + std::cerr << "Sampler::Reset(): Exception occured while trying to delete all MIDI instrument maps, exiting.\n" << std::flush; + exit(EXIT_FAILURE); + } } } // namespace LinuxSampler