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

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

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

revision 437 by schoenebeck, Fri Mar 4 22:54:11 2005 UTC revision 438 by persson, Wed Mar 9 22:12:15 2005 UTC
# Line 23  Line 23 
23    
24  #include "EngineChannel.h"  #include "EngineChannel.h"
25    
26  namespace LinuxSampler { namespace gig {      namespace LinuxSampler { namespace gig {
27    
28      EngineChannel::EngineChannel() {      EngineChannel::EngineChannel() {
29          pMIDIKeyInfo = new midi_key_info_t[128];          pMIDIKeyInfo = new midi_key_info_t[128];
30          pEngine      = NULL;          pEngine      = NULL;
31          pInstrument  = NULL;          pInstrument  = NULL;
32          pEventQueue  = new RingBuffer<Event>(MAX_EVENTS_PER_FRAGMENT, 0);                  pEventQueue  = new RingBuffer<Event>(MAX_EVENTS_PER_FRAGMENT, 0);
33          pActiveKeys  = new Pool<uint>(128);          pActiveKeys  = new Pool<uint>(128);
34          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
35              pMIDIKeyInfo[i].pActiveVoices  = NULL; // we allocate when we retrieve the right Engine object              pMIDIKeyInfo[i].pActiveVoices  = NULL; // we allocate when we retrieve the right Engine object
# Line 37  namespace LinuxSampler { namespace gig { Line 37  namespace LinuxSampler { namespace gig {
37              pMIDIKeyInfo[i].Active         = false;              pMIDIKeyInfo[i].Active         = false;
38              pMIDIKeyInfo[i].ReleaseTrigger = false;              pMIDIKeyInfo[i].ReleaseTrigger = false;
39              pMIDIKeyInfo[i].pEvents        = NULL; // we allocate when we retrieve the right Engine object              pMIDIKeyInfo[i].pEvents        = NULL; // we allocate when we retrieve the right Engine object
40                pMIDIKeyInfo[i].RoundRobinIndex = 0;
41          }          }
42          InstrumentIdx  = -1;          InstrumentIdx  = -1;
43          InstrumentStat = -1;          InstrumentStat = -1;
# Line 136  namespace LinuxSampler { namespace gig { Line 137  namespace LinuxSampler { namespace gig {
137      void EngineChannel::LoadInstrument() {      void EngineChannel::LoadInstrument() {
138    
139          if (pEngine) pEngine->DisableAndLock();          if (pEngine) pEngine->DisableAndLock();
140            
141          ResetInternal();          ResetInternal();
142            
143          // free old instrument          // free old instrument
144          if (pInstrument) {          if (pInstrument) {
145              // give old instrument back to instrument manager              // give old instrument back to instrument manager
# Line 221  namespace LinuxSampler { namespace gig { Line 222  namespace LinuxSampler { namespace gig {
222              DisconnectAudioOutputDevice();              DisconnectAudioOutputDevice();
223          }          }
224          pEngine = Engine::AcquireEngine(this, pAudioOut);          pEngine = Engine::AcquireEngine(this, pAudioOut);
225          ResetInternal();                  ResetInternal();
226          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
227              pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool);              pMIDIKeyInfo[i].pActiveVoices = new RTList<Voice>(pEngine->pVoicePool);
228              pMIDIKeyInfo[i].pEvents       = new RTList<Event>(pEngine->pEventPool);              pMIDIKeyInfo[i].pEvents       = new RTList<Event>(pEngine->pEventPool);
# Line 250  namespace LinuxSampler { namespace gig { Line 251  namespace LinuxSampler { namespace gig {
251              pEngine = NULL;              pEngine = NULL;
252              Engine::FreeEngine(this, oldAudioDevice);              Engine::FreeEngine(this, oldAudioDevice);
253              AudioDeviceChannelLeft  = -1;              AudioDeviceChannelLeft  = -1;
254              AudioDeviceChannelRight = -1;                          AudioDeviceChannelRight = -1;
255          }          }
256      }      }
257    
258      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {      void EngineChannel::SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) {
259          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");          if (!pEngine || !pEngine->pAudioOutputDevice) throw AudioOutputException("No audio output device connected yet.");
260            
261          AudioChannel* pChannel = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannel);          AudioChannel* pChannel = pEngine->pAudioOutputDevice->Channel(AudioDeviceChannel);
262          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));          if (!pChannel) throw AudioOutputException("Invalid audio output device channel " + ToString(AudioDeviceChannel));
263          switch (EngineAudioChannel) {          switch (EngineAudioChannel) {
# Line 297  namespace LinuxSampler { namespace gig { Line 298  namespace LinuxSampler { namespace gig {
298              event.Type                = Event::type_note_on;              event.Type                = Event::type_note_on;
299              event.Param.Note.Key      = Key;              event.Param.Note.Key      = Key;
300              event.Param.Note.Velocity = Velocity;              event.Param.Note.Velocity = Velocity;
301              event.pEngineChannel      = this;                          event.pEngineChannel      = this;
302              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);              if (this->pEventQueue->write_space() > 0) this->pEventQueue->push(&event);
303              else dmsg(1,("EngineChannel: Input event queue full!"));              else dmsg(1,("EngineChannel: Input event queue full!"));
304          }          }
# Line 329  namespace LinuxSampler { namespace gig { Line 330  namespace LinuxSampler { namespace gig {
330       *  @param Pitch - MIDI pitch value (-8192 ... +8191)       *  @param Pitch - MIDI pitch value (-8192 ... +8191)
331       */       */
332      void EngineChannel::SendPitchbend(int Pitch) {      void EngineChannel::SendPitchbend(int Pitch) {
333          if (pEngine) {                  if (pEngine) {
334              Event event             = pEngine->pEventGenerator->CreateEvent();              Event event             = pEngine->pEventGenerator->CreateEvent();
335              event.Type              = Event::type_pitchbend;              event.Type              = Event::type_pitchbend;
336              event.Param.Pitch.Pitch = Pitch;              event.Param.Pitch.Pitch = Pitch;
# Line 384  namespace LinuxSampler { namespace gig { Line 385  namespace LinuxSampler { namespace gig {
385    
386      int EngineChannel::InstrumentStatus() {      int EngineChannel::InstrumentStatus() {
387          return InstrumentStat;          return InstrumentStat;
388      }          }
389    
390  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.437  
changed lines
  Added in v.438

  ViewVC Help
Powered by ViewVC