/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDevice.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/midi/MidiInputDevice.cpp

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

revision 835 by persson, Mon Feb 6 18:07:17 2006 UTC revision 1305 by iliev, Mon Aug 27 07:51:28 2007 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2006 Christian Schoenebeck                        *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   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  *   *   it under the terms of the GNU General Public License as published by  *
# Line 23  Line 23 
23    
24  #include "MidiInputDevice.h"  #include "MidiInputDevice.h"
25    
26    #include "../../Sampler.h"
27    
28  namespace LinuxSampler {  namespace LinuxSampler {
29    
30  // *************** ParameterActive ***************  // *************** ParameterActive ***************
# Line 55  namespace LinuxSampler { Line 57  namespace LinuxSampler {
57          return true;          return true;
58      }      }
59    
60      void MidiInputDevice::ParameterActive::OnSetValue(bool b) throw (LinuxSamplerException) {      void MidiInputDevice::ParameterActive::OnSetValue(bool b) throw (Exception) {
61          if (b) ((MidiInputDevice*)pDevice)->Listen();          if (b) ((MidiInputDevice*)pDevice)->Listen();
62          else ((MidiInputDevice*)pDevice)->StopListen();          else ((MidiInputDevice*)pDevice)->StopListen();
63      }      }
# Line 97  namespace LinuxSampler { Line 99  namespace LinuxSampler {
99      }      }
100    
101      optional<int> MidiInputDevice::ParameterPorts::RangeMinAsInt(std::map<String,String> Parameters) {      optional<int> MidiInputDevice::ParameterPorts::RangeMinAsInt(std::map<String,String> Parameters) {
102          return optional<int>::nothing;          return 1;
103      }      }
104    
105      optional<int> MidiInputDevice::ParameterPorts::RangeMaxAsInt(std::map<String,String> Parameters) {      optional<int> MidiInputDevice::ParameterPorts::RangeMaxAsInt(std::map<String,String> Parameters) {
106          return optional<int>::nothing;          return 100;
107      }      }
108    
109      std::vector<int> MidiInputDevice::ParameterPorts::PossibilitiesAsInt(std::map<String,String> Parameters) {      std::vector<int> MidiInputDevice::ParameterPorts::PossibilitiesAsInt(std::map<String,String> Parameters) {
110          return std::vector<int>();          return std::vector<int>();
111      }      }
112    
113      void MidiInputDevice::ParameterPorts::OnSetValue(int i) throw (LinuxSamplerException) {      void MidiInputDevice::ParameterPorts::OnSetValue(int i) throw (Exception) {
114            MidiInputDevice* dev = static_cast<MidiInputDevice*> (pDevice);
115            Sampler* s = static_cast<Sampler*> (dev->pSampler);
116            std::map<uint, SamplerChannel*> channels = s->GetSamplerChannels();
117            std::map<uint, SamplerChannel*>::iterator iter = channels.begin();
118            for (; iter != channels.end(); iter++) {
119                SamplerChannel* chn = iter->second;
120                if (chn->GetMidiInputDevice() == NULL || chn->GetMidiInputDevice() != pDevice) {
121                    continue;
122                }
123                
124                int port = chn->GetMidiInputPort();
125                if (port >= i) {
126                    String err = "Sampler channel " + ToString(iter->first);
127                    err += " is still connected to MIDI port " + ToString(port);
128                    throw Exception(err);
129                }
130            }
131            
132          ((MidiInputDevice*)pDevice)->AcquirePorts(i);          ((MidiInputDevice*)pDevice)->AcquirePorts(i);
133      }      }
134    
# Line 153  namespace LinuxSampler { Line 173  namespace LinuxSampler {
173                   if (diff > 0) {        //We've got too many ports, remove one                   if (diff > 0) {        //We've got too many ports, remove one
174                           std::map<int,MidiInputPort*>::iterator portsIter = Ports.end();                           std::map<int,MidiInputPort*>::iterator portsIter = Ports.end();
175                           --portsIter;                           --portsIter;
                          Ports.erase(portsIter);  
176                           delete portsIter->second;                           delete portsIter->second;
177                             Ports.erase(portsIter);
178                           diff--;                           diff--;
179                   }                   }
180                   if (diff < 0) {       //We don't have enough ports, create one                   if (diff < 0) {       //We don't have enough ports, create one

Legend:
Removed from v.835  
changed lines
  Added in v.1305

  ViewVC Help
Powered by ViewVC