/[svn]/linuxsampler/trunk/src/Sampler.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/Sampler.cpp

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

revision 1934 by schoenebeck, Sun Jul 12 10:35:55 2009 UTC revision 1937 by schoenebeck, Sun Jul 12 19:52:20 2009 UTC
# Line 119  namespace LinuxSampler { Line 119  namespace LinuxSampler {
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    
# Line 142  namespace LinuxSampler { Line 145  namespace LinuxSampler {
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    
# Line 154  namespace LinuxSampler { Line 157  namespace LinuxSampler {
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
# Line 162  namespace LinuxSampler { Line 165  namespace LinuxSampler {
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;

Legend:
Removed from v.1934  
changed lines
  Added in v.1937

  ViewVC Help
Powered by ViewVC