119 |
dmsg(2,("OK\n")); |
dmsg(2,("OK\n")); |
120 |
} |
} |
121 |
|
|
122 |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) { |
void SamplerChannel::SetAudioOutputDevice(AudioOutputDevice* pDevice) throw (Exception) { |
123 |
if(pAudioOutputDevice == pDevice) return; |
if(pAudioOutputDevice == pDevice) return; |
124 |
|
|
125 |
// disconnect old device |
// disconnect old device |
126 |
if (pAudioOutputDevice && pEngineChannel) { |
if (pAudioOutputDevice && pEngineChannel) { |
127 |
|
if (!pAudioOutputDevice->isAutonomousDevice()) |
128 |
|
throw Exception("The audio output device '" + pAudioOutputDevice->Driver() + "' cannot be dropped from this sampler channel!"); |
129 |
|
|
130 |
Engine* engine = pEngineChannel->GetEngine(); |
Engine* engine = pEngineChannel->GetEngine(); |
131 |
pAudioOutputDevice->Disconnect(engine); |
pAudioOutputDevice->Disconnect(engine); |
132 |
|
|
145 |
} |
} |
146 |
} |
} |
147 |
|
|
148 |
void SamplerChannel::SetMidiInputDevice(MidiInputDevice* pDevice) { |
void SamplerChannel::SetMidiInputDevice(MidiInputDevice* pDevice) throw (Exception) { |
149 |
SetMidiInput(pDevice, 0, GetMidiInputChannel()); |
SetMidiInput(pDevice, 0, GetMidiInputChannel()); |
150 |
} |
} |
151 |
|
|
152 |
void SamplerChannel::SetMidiInputPort(int MidiPort) { |
void SamplerChannel::SetMidiInputPort(int MidiPort) throw (Exception) { |
153 |
SetMidiInput(GetMidiInputDevice(), MidiPort, GetMidiInputChannel()); |
SetMidiInput(GetMidiInputDevice(), MidiPort, GetMidiInputChannel()); |
154 |
} |
} |
155 |
|
|
157 |
SetMidiInput(GetMidiInputDevice(), GetMidiInputPort(), MidiChannel); |
SetMidiInput(GetMidiInputDevice(), GetMidiInputPort(), MidiChannel); |
158 |
} |
} |
159 |
|
|
160 |
void SamplerChannel::SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel) { |
void SamplerChannel::SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, midi_chan_t MidiChannel) throw (Exception) { |
161 |
if (!pDevice) throw Exception("No MIDI input device assigned."); |
if (!pDevice) throw Exception("No MIDI input device assigned."); |
162 |
|
|
163 |
// get old and new midi input port |
// get old and new midi input port |
165 |
MidiInputPort* pNewMidiInputPort = pDevice->GetPort(iMidiPort); |
MidiInputPort* pNewMidiInputPort = pDevice->GetPort(iMidiPort); |
166 |
|
|
167 |
// disconnect old device port |
// disconnect old device port |
168 |
if (pOldMidiInputPort && pEngineChannel) pOldMidiInputPort->Disconnect(pEngineChannel); |
if (pOldMidiInputPort && pEngineChannel) { |
169 |
|
MidiInputDevice* pOldDevice = pOldMidiInputPort->GetDevice(); |
170 |
|
if (pOldMidiInputPort != pNewMidiInputPort && |
171 |
|
pOldDevice && !pOldDevice->isAutonomousDevice() |
172 |
|
) throw Exception("The MIDI input port '" + pOldDevice->Driver() + "' cannot be altered on this sampler channel!"); |
173 |
|
|
174 |
|
pOldMidiInputPort->Disconnect(pEngineChannel); |
175 |
|
} |
176 |
|
|
177 |
// remember new device, port and channel if not engine channel yet created |
// remember new device, port and channel if not engine channel yet created |
178 |
if (!pEngineChannel) { |
if (!pEngineChannel) { |
179 |
this->pMidiInputDevice = pDevice; |
this->pMidiInputDevice = pDevice; |