/[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 212 by schoenebeck, Wed Jul 28 14:17:29 2004 UTC revision 329 by senkov, Tue Dec 28 09:43:04 2004 UTC
# Line 39  namespace LinuxSampler { Line 39  namespace LinuxSampler {
39          pMidiInputDevice   = NULL;          pMidiInputDevice   = NULL;
40          pAudioOutputDevice = NULL;          pAudioOutputDevice = NULL;
41          midiPort           = 0;          midiPort           = 0;
42          midiChannel        = MidiInputDevice::MidiInputPort::midi_chan_all;          midiChannel        = MidiInputPort::midi_chan_all;
43          iIndex             = -1;          iIndex             = -1;
44      }      }
45    
46      SamplerChannel::~SamplerChannel() {      SamplerChannel::~SamplerChannel() {
47          if (pEngine) {          if (pEngine) {
48              MidiInputDevice::MidiInputPort *pMidiInputPort = GetMidiInputDevicePort(this->midiPort);              MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort);
49              if (pMidiInputPort) pMidiInputPort->Disconnect(pEngine);              if (pMidiInputPort) pMidiInputPort->Disconnect(pEngine);
50              if (pAudioOutputDevice) pAudioOutputDevice->Disconnect(pEngine);              if (pAudioOutputDevice) pAudioOutputDevice->Disconnect(pEngine);
51              delete pEngine;              delete pEngine;
# Line 66  namespace LinuxSampler { Line 66  namespace LinuxSampler {
66          }          }
67    
68          // dereference midi input port.          // dereference midi input port.
69          MidiInputDevice::MidiInputPort *pMidiInputPort = GetMidiInputDevicePort(this->midiPort);          MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort);
70          // disconnect old engine          // disconnect old engine
71          if (pEngine) {          if (pEngine) {
72              if (pMidiInputPort) pMidiInputPort->Disconnect(pEngine);              if (pMidiInputPort) pMidiInputPort->Disconnect(pEngine);
# Line 97  namespace LinuxSampler { Line 97  namespace LinuxSampler {
97         SetMidiInput(pMidiInputDevice, MidiPort, this->midiChannel);         SetMidiInput(pMidiInputDevice, MidiPort, this->midiChannel);
98      }      }
99    
100      void SamplerChannel::SetMidiInputChannel(MidiInputDevice::MidiInputPort::midi_chan_t MidiChannel) {      void SamplerChannel::SetMidiInputChannel(MidiInputPort::midi_chan_t MidiChannel) {
101         SetMidiInput(pMidiInputDevice, this->midiPort, MidiChannel);         SetMidiInput(pMidiInputDevice, this->midiPort, MidiChannel);
102      }      }
103    
104      void SamplerChannel::SetMidiInput(MidiInputDevice* pDevice, int MidiPort, MidiInputDevice::MidiInputPort::midi_chan_t MidiChannel) {      void SamplerChannel::SetMidiInput(MidiInputDevice* pDevice, int iMidiPort, MidiInputPort::midi_chan_t MidiChannel) {
105          // dereference old midi input port.          // dereference old midi input port.
106          MidiInputDevice::MidiInputPort *pMidiInputPort = GetMidiInputDevicePort(this->midiPort);          MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort);
107          // disconnect old device port          // disconnect old device port
108          if (pMidiInputPort && pEngine) pMidiInputPort->Disconnect(pEngine);          if (pMidiInputPort && pEngine) pMidiInputPort->Disconnect(pEngine);
109          // new device, port and channel          // new device, port and channel
110          pMidiInputDevice = pDevice;          pMidiInputDevice = pDevice;
111          this->midiPort = MidiPort;          this->midiPort = iMidiPort;
112          this->midiChannel = MidiChannel;          this->midiChannel = MidiChannel;
113          // connect new device port          // connect new device port
114          pMidiInputPort = GetMidiInputDevicePort(this->midiPort);          pMidiInputPort = GetMidiInputDevicePort(this->midiPort);
115          if (pMidiInputPort && pEngine) pMidiInputPort->Connect(pEngine, MidiChannel);          if (pMidiInputPort && pEngine) pMidiInputPort->Connect(pEngine, MidiChannel);
116          // Ooops.          // Ooops.
117          if (pMidiInputPort == NULL)          if (pMidiInputPort == NULL)
118              throw LinuxSamplerException("There is no MIDI input port with index " + ToString(MidiPort) + ".");              throw LinuxSamplerException("There is no MIDI input port with index " + ToString(iMidiPort) + ".");
119      }      }
120    
121      Engine* SamplerChannel::GetEngine() {      Engine* SamplerChannel::GetEngine() {
122          return pEngine;          return pEngine;
123      }      }
124    
125      MidiInputDevice::MidiInputPort::midi_chan_t SamplerChannel::GetMidiInputChannel() {      MidiInputPort::midi_chan_t SamplerChannel::GetMidiInputChannel() {
126          return this->midiChannel;          return this->midiChannel;
127      }      }
128    
129      int SamplerChannel::GetMidiInputPort() {      int SamplerChannel::GetMidiInputPort() {
130          MidiInputDevice::MidiInputPort *pMidiInputPort = GetMidiInputDevicePort(this->midiPort);          MidiInputPort* pMidiInputPort = GetMidiInputDevicePort(this->midiPort);
131          return (pMidiInputPort ? (int) pMidiInputPort->GetPortNumber() : -1);          return (pMidiInputPort ? (int) pMidiInputPort->GetPortNumber() : -1);
132      }      }
133    
# Line 153  namespace LinuxSampler { Line 153  namespace LinuxSampler {
153          throw LinuxSamplerException("Internal error: SamplerChannel index not found");          throw LinuxSamplerException("Internal error: SamplerChannel index not found");
154      }      }
155    
156      MidiInputDevice::MidiInputPort* SamplerChannel::GetMidiInputDevicePort(int MidiPort) {      MidiInputPort* SamplerChannel::GetMidiInputDevicePort(int iMidiPort) {
157          MidiInputDevice::MidiInputPort *pMidiInputPort = NULL;          MidiInputPort* pMidiInputPort = NULL;
158          if (pMidiInputDevice)          if (pMidiInputDevice)
159              pMidiInputPort = pMidiInputDevice->GetPort(MidiPort);              pMidiInputPort = pMidiInputDevice->GetPort(iMidiPort);
160          return pMidiInputPort;          return pMidiInputPort;
161      }      }
162    
# Line 324  namespace LinuxSampler { Line 324  namespace LinuxSampler {
324      void Sampler::Reset() {      void Sampler::Reset() {
325          // delete sampler channels          // delete sampler channels
326          try {          try {
327              SamplerChannelMap::iterator iter = mSamplerChannels.begin();              while (true) {
328              for (; iter != mSamplerChannels.end(); iter++) {                      SamplerChannelMap::iterator iter = mSamplerChannels.begin();
329                  RemoveSamplerChannel(iter->second);                      if (iter == mSamplerChannels.end()) break;
330                        RemoveSamplerChannel(iter->second);
331              }              }
332          }          }
333          catch(...) {          catch(...) {
# Line 336  namespace LinuxSampler { Line 337  namespace LinuxSampler {
337    
338          // delete midi input devices          // delete midi input devices
339          try {          try {
340              MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin();              while (true) {
341              for (; iter != mMidiInputDevices.end(); iter++) {                      MidiInputDeviceMap::iterator iter = mMidiInputDevices.begin();
342                  DestroyMidiInputDevice(iter->second);                      if (iter == mMidiInputDevices.end()) break;
343                        DestroyMidiInputDevice(iter->second);
344              }              }
345          }          }
346          catch(...) {          catch(...) {
# Line 348  namespace LinuxSampler { Line 350  namespace LinuxSampler {
350    
351          // delete audio output devices          // delete audio output devices
352          try {          try {
353              AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin();              while (true) {
354              for (; iter != mAudioOutputDevices.end(); iter++) {                      AudioOutputDeviceMap::iterator iter = mAudioOutputDevices.begin();
355                  DestroyAudioOutputDevice(iter->second);                      if (iter == mAudioOutputDevices.end()) break;
356                        DestroyAudioOutputDevice(iter->second);
357              }              }
358          }          }
359          catch(...) {          catch(...) {

Legend:
Removed from v.212  
changed lines
  Added in v.329

  ViewVC Help
Powered by ViewVC