/[svn]/linuxsampler/trunk/src/engines/EngineChannel.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/EngineChannel.cpp

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

revision 973 by schoenebeck, Fri Dec 15 21:40:27 2006 UTC revision 1761 by iliev, Fri Aug 29 15:42:06 2008 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, 2006 Christian Schoenebeck                        *   *   Copyright (C) 2005 - 2007 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 25  Line 25 
25    
26  #include <algorithm>  #include <algorithm>
27    
28    #include "../Sampler.h"
29    #include "../common/global_private.h"
30  #include "../drivers/midi/MidiInstrumentMapper.h"  #include "../drivers/midi/MidiInstrumentMapper.h"
31    
32  #define NO_MIDI_INSTRUMENT_MAP          -1  #define NO_MIDI_INSTRUMENT_MAP          -1
# Line 40  namespace LinuxSampler { Line 42  namespace LinuxSampler {
42          uiMidiProgram = 0;          uiMidiProgram = 0;
43          bProgramChangeReceived = bMidiBankMsbReceived = bMidiBankLsbReceived = false;          bProgramChangeReceived = bMidiBankMsbReceived = bMidiBankLsbReceived = false;
44          iMidiInstrumentMap = NO_MIDI_INSTRUMENT_MAP;          iMidiInstrumentMap = NO_MIDI_INSTRUMENT_MAP;
45            uiVoiceCount = 0;
46            uiDiskStreamCount = 0;
47            pSamplerChannel = NULL;
48            ResetMidiRpnController();
49      }      }
50    
51      void EngineChannel::SetMute(int state) throw (Exception) {      void EngineChannel::SetMute(int state) throw (Exception) {
# Line 143  namespace LinuxSampler { Line 149  namespace LinuxSampler {
149      }      }
150    
151      void EngineChannel::SetMidiInstrumentMapToNone() {      void EngineChannel::SetMidiInstrumentMapToNone() {
152            if (iMidiInstrumentMap == NO_MIDI_INSTRUMENT_MAP) return;
153          iMidiInstrumentMap = NO_MIDI_INSTRUMENT_MAP;          iMidiInstrumentMap = NO_MIDI_INSTRUMENT_MAP;
154            StatusChanged(true);
155      }      }
156    
157      void EngineChannel::SetMidiInstrumentMapToDefault() {      void EngineChannel::SetMidiInstrumentMapToDefault() {
158            if (iMidiInstrumentMap == DEFAULT_MIDI_INSTRUMENT_MAP) return;
159          iMidiInstrumentMap = DEFAULT_MIDI_INSTRUMENT_MAP;          iMidiInstrumentMap = DEFAULT_MIDI_INSTRUMENT_MAP;
160            StatusChanged(true);
161      }      }
162    
163      void EngineChannel::SetMidiInstrumentMap(int MidiMap) throw (Exception) {      void EngineChannel::SetMidiInstrumentMap(int MidiMap) throw (Exception) {
164            if (iMidiInstrumentMap == MidiMap) return;
165    
166          // check if given map actually exists in the MIDI instrument mapper          // check if given map actually exists in the MIDI instrument mapper
167          std::vector<int> maps = MidiInstrumentMapper::Maps();          std::vector<int> maps = MidiInstrumentMapper::Maps();
168          if (find(maps.begin(), maps.end(), MidiMap) == maps.end())          if (find(maps.begin(), maps.end(), MidiMap) == maps.end())
169              throw Exception("MIDI instrument map doesn't exist");              throw Exception("MIDI instrument map doesn't exist");
170          iMidiInstrumentMap = MidiMap; // assign the new map ID          iMidiInstrumentMap = MidiMap; // assign the new map ID
171            StatusChanged(true);
172        }
173    
174        void EngineChannel::SetMidiRpnControllerMsb(uint8_t CtrlMSB) {
175            uiMidiRpnMsb = CtrlMSB;
176            bMidiRpnReceived = true;
177        }
178    
179        void EngineChannel::SetMidiRpnControllerLsb(uint8_t CtrlLSB) {
180            uiMidiRpnLsb = CtrlLSB;
181            bMidiRpnReceived = true;
182        }
183    
184        void EngineChannel::ResetMidiRpnController() {
185            uiMidiRpnMsb = uiMidiRpnLsb = 0;
186            bMidiRpnReceived = false;
187        }
188    
189        int EngineChannel::GetMidiRpnController() {
190            return (bMidiRpnReceived) ? (uiMidiRpnMsb << 8) | uiMidiRpnLsb : -1;
191        }
192    
193        uint EngineChannel::GetVoiceCount() {
194            return uiVoiceCount;
195        }
196        
197        void EngineChannel::SetVoiceCount(uint Voices) {
198            uiVoiceCount = Voices;
199        }
200    
201        uint EngineChannel::GetDiskStreamCount() {
202            return uiDiskStreamCount;
203        }
204        
205        void EngineChannel::SetDiskStreamCount(uint Streams) {
206            uiDiskStreamCount = Streams;
207        }
208        
209        SamplerChannel* EngineChannel::GetSamplerChannel() {
210            if(pSamplerChannel == NULL) {
211                std::cerr << "EngineChannel::GetSamplerChannel(): pSamplerChannel is NULL, this is a bug!\n" << std::flush;
212            }
213            return pSamplerChannel;
214        }
215    
216        void EngineChannel::SetSamplerChannel(SamplerChannel* pChannel) {
217            pSamplerChannel = pChannel;
218        }
219    
220        Sampler* EngineChannel::GetSampler() {
221            if (GetSamplerChannel() == NULL) return NULL;
222            return GetSamplerChannel()->GetSampler();
223        }
224    
225        void EngineChannel::AddFxSendCountListener(FxSendCountListener* l) {
226            llFxSendCountListeners.AddListener(l);
227        }
228    
229        void EngineChannel::RemoveFxSendCountListener(FxSendCountListener* l) {
230            llFxSendCountListeners.RemoveListener(l);
231        }
232    
233        void EngineChannel::RemoveAllFxSendCountListeners() {
234            llFxSendCountListeners.RemoveAllListeners();
235        }
236    
237        void EngineChannel::fireFxSendCountChanged(int ChannelId, int NewCount) {
238            for (int i = 0; i < llFxSendCountListeners.GetListenerCount(); i++) {
239                llFxSendCountListeners.GetListener(i)->FxSendCountChanged(ChannelId, NewCount);
240            }
241      }      }
242    
243  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.973  
changed lines
  Added in v.1761

  ViewVC Help
Powered by ViewVC