1 |
schoenebeck |
53 |
/*************************************************************************** |
2 |
|
|
* * |
3 |
|
|
* LinuxSampler - modular, streaming capable sampler * |
4 |
|
|
* * |
5 |
schoenebeck |
61 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
schoenebeck |
411 |
* Copyright (C) 2005 Christian Schoenebeck * |
7 |
schoenebeck |
53 |
* * |
8 |
|
|
* This program is free software; you can redistribute it and/or modify * |
9 |
|
|
* 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 * |
11 |
|
|
* (at your option) any later version. * |
12 |
|
|
* * |
13 |
|
|
* This program is distributed in the hope that it will be useful, * |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
16 |
|
|
* GNU General Public License for more details. * |
17 |
|
|
* * |
18 |
|
|
* You should have received a copy of the GNU General Public License * |
19 |
|
|
* along with this program; if not, write to the Free Software * |
20 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, * |
21 |
|
|
* MA 02111-1307 USA * |
22 |
|
|
***************************************************************************/ |
23 |
|
|
|
24 |
schoenebeck |
123 |
#include <sstream> |
25 |
|
|
|
26 |
schoenebeck |
53 |
#include "Sampler.h" |
27 |
|
|
|
28 |
iliev |
778 |
#include "engines/EngineFactory.h" |
29 |
schoenebeck |
411 |
#include "engines/EngineChannelFactory.h" |
30 |
schoenebeck |
203 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
31 |
|
|
#include "drivers/midi/MidiInputDeviceFactory.h" |
32 |
senkov |
359 |
#include "network/lscpserver.h" |
33 |
schoenebeck |
53 |
|
34 |
|
|
namespace LinuxSampler { |
35 |
|
|
|
36 |
|
|
// ****************************************************************** |
37 |
|
|
// * SamplerChannel |
38 |
|
|
|
39 |
|
|
SamplerChannel::SamplerChannel(Sampler* pS) { |
40 |
|
|
pSampler = pS; |
41 |
schoenebeck |
411 |
pEngineChannel = NULL; |
42 |
schoenebeck |
675 |
pAudioOutputDevice = NULL; |
43 |
capela |
159 |
pMidiInputDevice = NULL; |
44 |
schoenebeck |
675 |
iMidiPort = 0; |
45 |
|
|
midiChannel = midi_chan_all; |
46 |
schoenebeck |
53 |
iIndex = -1; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
SamplerChannel::~SamplerChannel() { |
50 |
schoenebeck |
411 |
if (pEngineChannel) { |
51 |
schoenebeck |
675 |
MidiInputPort* pMidiInputPort = (pEngineChannel) ? pEngineChannel->GetMidiInputPort() : __GetMidiInputDevicePort(GetMidiInputChannel()); |
52 |
schoenebeck |
411 |
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
53 |
schoenebeck |
420 |
if (pEngineChannel) { |
54 |
|
|
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
55 |
schoenebeck |
660 |
EngineChannelFactory::Destroy(pEngineChannel); |
56 |
schoenebeck |
420 |
} |
57 |
schoenebeck |
53 |
} |
58 |
|
|
} |
59 |
|
|
|
60 |
schoenebeck |
411 |
void SamplerChannel::SetEngineType(String EngineType) throw (LinuxSamplerException) { |
61 |
|
|
dmsg(2,("SamplerChannel: Assigning engine type...")); |
62 |
schoenebeck |
53 |
|
63 |
schoenebeck |
411 |
// create new engine channel |
64 |
|
|
EngineChannel* pNewEngineChannel = EngineChannelFactory::Create(EngineType); |
65 |
|
|
if (!pNewEngineChannel) throw LinuxSamplerException("Unknown engine type"); |
66 |
schoenebeck |
53 |
|
67 |
schoenebeck |
660 |
//FIXME: hack to allow fast retrieval of engine channel's sampler channel index |
68 |
|
|
pNewEngineChannel->iSamplerChannelIndex = Index(); |
69 |
|
|
|
70 |
capela |
159 |
// dereference midi input port. |
71 |
schoenebeck |
675 |
MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
72 |
|
|
// disconnect old engine channel |
73 |
schoenebeck |
411 |
if (pEngineChannel) { |
74 |
|
|
if (pMidiInputPort) pMidiInputPort->Disconnect(pEngineChannel); |
75 |
schoenebeck |
412 |
if (pAudioOutputDevice) pEngineChannel->DisconnectAudioOutputDevice(); |
76 |
schoenebeck |
660 |
EngineChannelFactory::Destroy(pEngineChannel); |
77 |
schoenebeck |
53 |
} |
78 |
|
|
|
79 |
schoenebeck |
411 |
// connect new engine channel |
80 |
schoenebeck |
675 |
if (pMidiInputPort) pMidiInputPort->Connect(pNewEngineChannel, GetMidiInputChannel()); |
81 |
schoenebeck |
412 |
if (pAudioOutputDevice) { |
82 |
|
|
pNewEngineChannel->Connect(pAudioOutputDevice); |
83 |
|
|
pAudioOutputDevice->Connect(pNewEngineChannel->GetEngine()); |
84 |
|
|
} |
85 |
schoenebeck |
675 |
pEngineChannel = pNewEngineChannel; |
86 |
|
|
|
87 |
|
|
// from now on get MIDI device and port from EngineChannel object |
88 |
|
|
this->pMidiInputDevice = NULL; |
89 |
|
|
this->iMidiPort = 0; |
90 |
|
|
|
91 |
iliev |
730 |
pEngineChannel->StatusChanged(true); |
92 |
|
|
|
93 |
schoenebeck |
64 |
dmsg(2,("OK\n")); |
94 |
schoenebeck |
53 |
} |
95 |
|
|
|
96 |
schoenebeck |
123 |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) { |
97 |
schoenebeck |
53 |
// disconnect old device |
98 |
schoenebeck |
412 |
if (pAudioOutputDevice && pEngineChannel) pEngineChannel->DisconnectAudioOutputDevice(); |
99 |
schoenebeck |
53 |
// connect new device |
100 |
|
|
pAudioOutputDevice = pDevice; |
101 |
schoenebeck |
412 |
if (pEngineChannel) { |
102 |
|
|
pEngineChannel->Connect(pAudioOutputDevice); |
103 |
|
|
pAudioOutputDevice->Connect(pEngineChannel->GetEngine()); |
104 |
|
|
} |
105 |
schoenebeck |
53 |
} |
106 |
|
|
|
107 |
capela |
159 |
void SamplerChannel::SetMidiInputDevice(MidiInputDevice* pDevice) { |
108 |
schoenebeck |
675 |
SetMidiInput(pDevice, 0, GetMidiInputChannel()); |
109 |
capela |
159 |
} |
110 |
schoenebeck |
203 |
|
111 |
capela |
159 |
void SamplerChannel::SetMidiInputPort(int MidiPort) { |
112 |
schoenebeck |
675 |
SetMidiInput(GetMidiInputDevice(), MidiPort, GetMidiInputChannel()); |
113 |
capela |
159 |
} |
114 |
schoenebeck |
203 |
|
115 |
schoenebeck |
675 |
void SamplerChannel::SetMidiInputChannel(midi_chan_t MidiChannel) { |
116 |
|
|
SetMidiInput(GetMidiInputDevice(), GetMidiInputPort(), MidiChannel); |
117 |
capela |
159 |
} |
118 |
schoenebeck |
203 |
|
119 |
schoenebeck |
675 |
void SamplerChannel::SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel) { |
120 |
|
|
if (!pDevice) throw LinuxSamplerException("No MIDI input device assigned."); |
121 |
|
|
|
122 |
|
|
// get old and new midi input port |
123 |
|
|
MidiInputPort* pOldMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort()); |
124 |
|
|
MidiInputPort* pNewMidiInputPort = pDevice->GetPort(iMidiPort); |
125 |
|
|
|
126 |
capela |
159 |
// disconnect old device port |
127 |
schoenebeck |
675 |
if (pOldMidiInputPort && pEngineChannel) pOldMidiInputPort->Disconnect(pEngineChannel); |
128 |
|
|
// remember new device, port and channel if not engine channel yet created |
129 |
|
|
if (!pEngineChannel) { |
130 |
|
|
this->pMidiInputDevice = pDevice; |
131 |
|
|
this->iMidiPort = iMidiPort; |
132 |
|
|
this->midiChannel = MidiChannel; |
133 |
|
|
} |
134 |
|
|
|
135 |
capela |
159 |
// connect new device port |
136 |
schoenebeck |
675 |
if (pNewMidiInputPort && pEngineChannel) pNewMidiInputPort->Connect(pEngineChannel, MidiChannel); |
137 |
capela |
159 |
// Ooops. |
138 |
schoenebeck |
675 |
if (pNewMidiInputPort == NULL) |
139 |
schoenebeck |
221 |
throw LinuxSamplerException("There is no MIDI input port with index " + ToString(iMidiPort) + "."); |
140 |
schoenebeck |
53 |
} |
141 |
|
|
|
142 |
schoenebeck |
411 |
EngineChannel* SamplerChannel::GetEngineChannel() { |
143 |
|
|
return pEngineChannel; |
144 |
schoenebeck |
53 |
} |
145 |
|
|
|
146 |
schoenebeck |
675 |
midi_chan_t SamplerChannel::GetMidiInputChannel() { |
147 |
|
|
if (pEngineChannel) this->midiChannel = pEngineChannel->MidiChannel(); |
148 |
capela |
159 |
return this->midiChannel; |
149 |
schoenebeck |
53 |
} |
150 |
|
|
|
151 |
capela |
159 |
int SamplerChannel::GetMidiInputPort() { |
152 |
schoenebeck |
675 |
MidiInputPort* pMidiInputPort = (pEngineChannel) ? pEngineChannel->GetMidiInputPort() : NULL; |
153 |
|
|
if (pMidiInputPort) this->iMidiPort = (int) pMidiInputPort->GetPortNumber(); |
154 |
|
|
return iMidiPort; |
155 |
capela |
159 |
} |
156 |
|
|
|
157 |
schoenebeck |
53 |
AudioOutputDevice* SamplerChannel::GetAudioOutputDevice() { |
158 |
|
|
return pAudioOutputDevice; |
159 |
|
|
} |
160 |
|
|
|
161 |
senkov |
155 |
MidiInputDevice* SamplerChannel::GetMidiInputDevice() { |
162 |
schoenebeck |
675 |
if (pEngineChannel) |
163 |
|
|
pMidiInputDevice = (pEngineChannel->GetMidiInputPort()) ? pEngineChannel->GetMidiInputPort()->GetDevice() : NULL; |
164 |
capela |
159 |
return pMidiInputDevice; |
165 |
senkov |
155 |
} |
166 |
|
|
|
167 |
schoenebeck |
53 |
uint SamplerChannel::Index() { |
168 |
|
|
if (iIndex >= 0) return iIndex; |
169 |
|
|
|
170 |
schoenebeck |
209 |
Sampler::SamplerChannelMap::iterator iter = pSampler->mSamplerChannels.begin(); |
171 |
|
|
for (; iter != pSampler->mSamplerChannels.end(); iter++) { |
172 |
|
|
if (iter->second == this) { |
173 |
|
|
iIndex = iter->first; |
174 |
|
|
return iIndex; |
175 |
schoenebeck |
53 |
} |
176 |
|
|
} |
177 |
|
|
|
178 |
schoenebeck |
209 |
throw LinuxSamplerException("Internal error: SamplerChannel index not found"); |
179 |
schoenebeck |
53 |
} |
180 |
|
|
|
181 |
schoenebeck |
675 |
MidiInputPort* SamplerChannel::__GetMidiInputDevicePort(int iMidiPort) { |
182 |
schoenebeck |
221 |
MidiInputPort* pMidiInputPort = NULL; |
183 |
schoenebeck |
675 |
MidiInputDevice* pMidiInputDevice = GetMidiInputDevice(); |
184 |
capela |
159 |
if (pMidiInputDevice) |
185 |
schoenebeck |
221 |
pMidiInputPort = pMidiInputDevice->GetPort(iMidiPort); |
186 |
capela |
159 |
return pMidiInputPort; |
187 |
|
|
} |
188 |
schoenebeck |
53 |
|
189 |
schoenebeck |
212 |
|
190 |
|
|
|
191 |
schoenebeck |
53 |
// ****************************************************************** |
192 |
|
|
// * Sampler |
193 |
|
|
|
194 |
|
|
Sampler::Sampler() { |
195 |
|
|
} |
196 |
|
|
|
197 |
|
|
Sampler::~Sampler() { |
198 |
schoenebeck |
212 |
Reset(); |
199 |
schoenebeck |
53 |
} |
200 |
|
|
|
201 |
|
|
uint Sampler::SamplerChannels() { |
202 |
schoenebeck |
209 |
return mSamplerChannels.size(); |
203 |
schoenebeck |
53 |
} |
204 |
|
|
|
205 |
|
|
SamplerChannel* Sampler::AddSamplerChannel() { |
206 |
schoenebeck |
209 |
// if there's no sampler channel yet |
207 |
|
|
if (!mSamplerChannels.size()) { |
208 |
|
|
SamplerChannel* pChannel = new SamplerChannel(this); |
209 |
|
|
mSamplerChannels[0] = pChannel; |
210 |
schoenebeck |
556 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, 1)); |
211 |
schoenebeck |
209 |
return pChannel; |
212 |
|
|
} |
213 |
|
|
|
214 |
|
|
// get the highest used sampler channel index |
215 |
|
|
uint lastIndex = (--(mSamplerChannels.end()))->first; |
216 |
|
|
|
217 |
|
|
// check if we reached the index limit |
218 |
|
|
if (lastIndex + 1 < lastIndex) { |
219 |
|
|
// search for an unoccupied sampler channel index starting from 0 |
220 |
|
|
for (uint i = 0; i < lastIndex; i++) { |
221 |
|
|
if (mSamplerChannels.find(i) != mSamplerChannels.end()) continue; |
222 |
|
|
// we found an unused index, so insert the new channel there |
223 |
|
|
SamplerChannel* pChannel = new SamplerChannel(this); |
224 |
|
|
mSamplerChannels[i] = pChannel; |
225 |
schoenebeck |
556 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, i)); |
226 |
schoenebeck |
209 |
return pChannel; |
227 |
|
|
} |
228 |
|
|
throw LinuxSamplerException("Internal error: could not find unoccupied sampler channel index."); |
229 |
|
|
} |
230 |
|
|
|
231 |
|
|
// we have not reached the index limit so we just add the channel past the highest index |
232 |
schoenebeck |
53 |
SamplerChannel* pChannel = new SamplerChannel(this); |
233 |
schoenebeck |
209 |
mSamplerChannels[lastIndex + 1] = pChannel; |
234 |
schoenebeck |
556 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, lastIndex + 1)); |
235 |
schoenebeck |
53 |
return pChannel; |
236 |
|
|
} |
237 |
|
|
|
238 |
|
|
SamplerChannel* Sampler::GetSamplerChannel(uint uiSamplerChannel) { |
239 |
schoenebeck |
209 |
return (mSamplerChannels.find(uiSamplerChannel) != mSamplerChannels.end()) ? mSamplerChannels[uiSamplerChannel] : NULL; |
240 |
schoenebeck |
53 |
} |
241 |
|
|
|
242 |
schoenebeck |
209 |
std::map<uint, SamplerChannel*> Sampler::GetSamplerChannels() { |
243 |
|
|
return mSamplerChannels; |
244 |
|
|
} |
245 |
|
|
|
246 |
schoenebeck |
53 |
void Sampler::RemoveSamplerChannel(SamplerChannel* pSamplerChannel) { |
247 |
schoenebeck |
209 |
SamplerChannelMap::iterator iterChan = mSamplerChannels.begin(); |
248 |
|
|
for (; iterChan != mSamplerChannels.end(); iterChan++) { |
249 |
|
|
if (iterChan->second == pSamplerChannel) { |
250 |
|
|
mSamplerChannels.erase(iterChan); |
251 |
schoenebeck |
53 |
delete pSamplerChannel; |
252 |
schoenebeck |
556 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, mSamplerChannels.size())); |
253 |
schoenebeck |
53 |
return; |
254 |
|
|
} |
255 |
|
|
} |
256 |
|
|
} |
257 |
|
|
|
258 |
|
|
void Sampler::RemoveSamplerChannel(uint uiSamplerChannel) { |
259 |
|
|
SamplerChannel* pChannel = GetSamplerChannel(uiSamplerChannel); |
260 |
|
|
if (!pChannel) return; |
261 |
|
|
RemoveSamplerChannel(pChannel); |
262 |
|
|
} |
263 |
|
|
|
264 |
schoenebeck |
123 |
std::vector<String> Sampler::AvailableAudioOutputDrivers() { |
265 |
|
|
return AudioOutputDeviceFactory::AvailableDrivers(); |
266 |
|
|
} |
267 |
schoenebeck |
53 |
|
268 |
schoenebeck |
123 |
AudioOutputDevice* Sampler::CreateAudioOutputDevice(String AudioDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
269 |
schoenebeck |
53 |
// create new device |
270 |
schoenebeck |
123 |
AudioOutputDevice* pDevice = AudioOutputDeviceFactory::Create(AudioDriver, Parameters); |
271 |
schoenebeck |
53 |
|
272 |
schoenebeck |
64 |
// add new audio device to the audio device list |
273 |
schoenebeck |
123 |
for (uint i = 0; ; i++) { // seek for a free place starting from the beginning |
274 |
|
|
if (!mAudioOutputDevices[i]) { |
275 |
|
|
mAudioOutputDevices[i] = pDevice; |
276 |
|
|
break; |
277 |
|
|
} |
278 |
|
|
} |
279 |
schoenebeck |
64 |
|
280 |
schoenebeck |
53 |
return pDevice; |
281 |
|
|
} |
282 |
|
|
|
283 |
schoenebeck |
123 |
uint Sampler::AudioOutputDevices() { |
284 |
|
|
return mAudioOutputDevices.size(); |
285 |
schoenebeck |
53 |
} |
286 |
|
|
|
287 |
senkov |
155 |
uint Sampler::MidiInputDevices() { |
288 |
|
|
return mMidiInputDevices.size(); |
289 |
|
|
} |
290 |
|
|
|
291 |
schoenebeck |
123 |
std::map<uint, AudioOutputDevice*> Sampler::GetAudioOutputDevices() { |
292 |
|
|
return mAudioOutputDevices; |
293 |
|
|
} |
294 |
|
|
|
295 |
senkov |
155 |
std::map<uint, MidiInputDevice*> Sampler::GetMidiInputDevices() { |
296 |
|
|
return mMidiInputDevices; |
297 |
|
|
} |
298 |
|
|
|
299 |
schoenebeck |
123 |
void Sampler::DestroyAudioOutputDevice(AudioOutputDevice* pDevice) throw (LinuxSamplerException) { |
300 |
|
|
AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin(); |
301 |
|
|
for (; iter != mAudioOutputDevices.end(); iter++) { |
302 |
|
|
if (iter->second == pDevice) { |
303 |
|
|
// check if there are still sampler engines connected to this device |
304 |
|
|
for (uint i = 0; i < SamplerChannels(); i++) |
305 |
|
|
if (GetSamplerChannel(i)->GetAudioOutputDevice() == pDevice) throw LinuxSamplerException("Sampler channel " + ToString(i) + " is still connected to the audio output device."); |
306 |
|
|
|
307 |
|
|
// disable device |
308 |
|
|
pDevice->Stop(); |
309 |
|
|
|
310 |
|
|
// destroy and free device from memory |
311 |
|
|
delete pDevice; |
312 |
|
|
} |
313 |
|
|
} |
314 |
persson |
835 |
// remove devices from the device list |
315 |
|
|
mAudioOutputDevices.clear(); |
316 |
schoenebeck |
123 |
} |
317 |
|
|
|
318 |
senkov |
155 |
void Sampler::DestroyMidiInputDevice(MidiInputDevice* pDevice) throw (LinuxSamplerException) { |
319 |
|
|
MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); |
320 |
|
|
for (; iter != mMidiInputDevices.end(); iter++) { |
321 |
|
|
if (iter->second == pDevice) { |
322 |
|
|
// check if there are still sampler engines connected to this device |
323 |
|
|
for (uint i = 0; i < SamplerChannels(); i++) |
324 |
|
|
if (GetSamplerChannel(i)->GetMidiInputDevice() == pDevice) throw LinuxSamplerException("Sampler channel " + ToString(i) + " is still connected to the midi input device."); |
325 |
schoenebeck |
53 |
|
326 |
senkov |
155 |
// disable device |
327 |
|
|
pDevice->StopListen(); |
328 |
|
|
|
329 |
|
|
// destroy and free device from memory |
330 |
|
|
delete pDevice; |
331 |
|
|
} |
332 |
schoenebeck |
53 |
} |
333 |
persson |
835 |
// remove devices from the device list |
334 |
|
|
mMidiInputDevices.clear(); |
335 |
senkov |
155 |
} |
336 |
schoenebeck |
53 |
|
337 |
senkov |
155 |
MidiInputDevice* Sampler::CreateMidiInputDevice(String MidiDriver, std::map<String,String> Parameters) throw (LinuxSamplerException) { |
338 |
|
|
// create new device |
339 |
schoenebeck |
551 |
MidiInputDevice* pDevice = MidiInputDeviceFactory::Create(MidiDriver, Parameters, this); |
340 |
senkov |
155 |
|
341 |
|
|
// add new device to the midi device list |
342 |
|
|
for (uint i = 0; ; i++) { // seek for a free place starting from the beginning |
343 |
|
|
if (!mMidiInputDevices[i]) { |
344 |
|
|
mMidiInputDevices[i] = pDevice; |
345 |
|
|
break; |
346 |
|
|
} |
347 |
|
|
} |
348 |
schoenebeck |
64 |
|
349 |
schoenebeck |
53 |
return pDevice; |
350 |
|
|
} |
351 |
|
|
|
352 |
iliev |
778 |
int Sampler::GetVoiceCount() { |
353 |
|
|
int count = 0; |
354 |
|
|
std::set<Engine*>::iterator it = EngineFactory::EngineInstances().begin(); |
355 |
|
|
|
356 |
|
|
for(; it != EngineFactory::EngineInstances().end(); it++) { |
357 |
|
|
count += (*it)->VoiceCount(); |
358 |
|
|
} |
359 |
|
|
|
360 |
|
|
return count; |
361 |
|
|
} |
362 |
|
|
|
363 |
schoenebeck |
212 |
void Sampler::Reset() { |
364 |
|
|
// delete sampler channels |
365 |
|
|
try { |
366 |
senkov |
329 |
while (true) { |
367 |
|
|
SamplerChannelMap::iterator iter = mSamplerChannels.begin(); |
368 |
|
|
if (iter == mSamplerChannels.end()) break; |
369 |
|
|
RemoveSamplerChannel(iter->second); |
370 |
schoenebeck |
212 |
} |
371 |
|
|
} |
372 |
|
|
catch(...) { |
373 |
|
|
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all sampler channels, exiting.\n" << std::flush; |
374 |
|
|
exit(EXIT_FAILURE); |
375 |
|
|
} |
376 |
|
|
|
377 |
|
|
// delete midi input devices |
378 |
|
|
try { |
379 |
senkov |
329 |
while (true) { |
380 |
|
|
MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin(); |
381 |
|
|
if (iter == mMidiInputDevices.end()) break; |
382 |
|
|
DestroyMidiInputDevice(iter->second); |
383 |
schoenebeck |
212 |
} |
384 |
|
|
} |
385 |
|
|
catch(...) { |
386 |
|
|
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all MIDI input devices, exiting.\n" << std::flush; |
387 |
|
|
exit(EXIT_FAILURE); |
388 |
|
|
} |
389 |
|
|
|
390 |
|
|
// delete audio output devices |
391 |
|
|
try { |
392 |
senkov |
329 |
while (true) { |
393 |
|
|
AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin(); |
394 |
|
|
if (iter == mAudioOutputDevices.end()) break; |
395 |
|
|
DestroyAudioOutputDevice(iter->second); |
396 |
schoenebeck |
212 |
} |
397 |
|
|
} |
398 |
|
|
catch(...) { |
399 |
|
|
std::cerr << "Sampler::Reset(): Exception occured while trying to delete all audio output devices, exiting.\n" << std::flush; |
400 |
|
|
exit(EXIT_FAILURE); |
401 |
|
|
} |
402 |
|
|
} |
403 |
|
|
|
404 |
schoenebeck |
53 |
} // namespace LinuxSampler |