/[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 554 by schoenebeck, Thu May 19 19:25:14 2005 UTC revision 675 by schoenebeck, Wed Jun 22 22:09:28 2005 UTC
# Line 49  namespace LinuxSampler { namespace gig { Line 49  namespace LinuxSampler { namespace gig {
49          InstrumentStat = -1;          InstrumentStat = -1;
50          AudioDeviceChannelLeft  = -1;          AudioDeviceChannelLeft  = -1;
51          AudioDeviceChannelRight = -1;          AudioDeviceChannelRight = -1;
52            pMidiInputPort = NULL;
53            midiChannel = midi_chan_all;
54            ResetControllers();
55      }      }
56    
57      EngineChannel::~EngineChannel() {      EngineChannel::~EngineChannel() {
# Line 60  namespace LinuxSampler { namespace gig { Line 63  namespace LinuxSampler { namespace gig {
63      }      }
64    
65      /**      /**
66         * Implementation of virtual method from abstract EngineChannel interface.
67         * This method will periodically be polled (e.g. by the LSCP server) to
68         * check if some engine channel parameter has changed since the last
69         * StatusChanged() call.
70         *
71         * This method can also be used to mark the engine channel as changed
72         * from outside, e.g. by a MIDI input device. The optional argument
73         * \a nNewStatus can be used for this.
74         *
75         * TODO: This "poll method" is just a lazy solution and might be
76         *       replaced in future.
77         * @param bNewStatus - (optional, default: false) sets the new status flag
78         * @returns true if engine channel status has changed since last
79         *          StatusChanged() call
80         */
81        bool EngineChannel::StatusChanged(bool bNewStatus) {
82            bool b = bStatusChanged;
83            bStatusChanged = bNewStatus;
84            return b;
85        }
86    
87        void EngineChannel::Reset() {
88            if (pEngine) pEngine->DisableAndLock();
89            ResetInternal();
90            ResetControllers();
91            if (pEngine) {
92                pEngine->Enable();
93                pEngine->Reset();
94            }
95        }
96    
97        /**
98       * This method is not thread safe!       * This method is not thread safe!
99       */       */
100      void EngineChannel::ResetInternal() {      void EngineChannel::ResetInternal() {
         Pitch               = 0;  
         SustainPedal        = false;  
         GlobalVolume        = 1.0;  
         GlobalPanLeft       = 1.0f;  
         GlobalPanRight      = 1.0f;  
101          CurrentKeyDimension = 0;          CurrentKeyDimension = 0;
102    
         ResetControllers();  
   
103          // reset key info          // reset key info
104          for (uint i = 0; i < 128; i++) {          for (uint i = 0; i < 128; i++) {
105              if (pMIDIKeyInfo[i].pActiveVoices)              if (pMIDIKeyInfo[i].pActiveVoices)
# Line 96  namespace LinuxSampler { namespace gig { Line 124  namespace LinuxSampler { namespace gig {
124          pEventQueue->init();          pEventQueue->init();
125    
126          if (pEngine) pEngine->ResetInternal();          if (pEngine) pEngine->ResetInternal();
127    
128            // status of engine channel has changed, so set notify flag
129            bStatusChanged = true;
130      }      }
131    
132      LinuxSampler::Engine* EngineChannel::GetEngine() {      LinuxSampler::Engine* EngineChannel::GetEngine() {
# Line 208  namespace LinuxSampler { namespace gig { Line 239  namespace LinuxSampler { namespace gig {
239      void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) {      void EngineChannel::ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg) {
240          this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument())          this->pInstrument = pNewResource; //TODO: there are couple of engine parameters we should update here as well if the instrument was updated (see LoadInstrument())
241          if (pEngine) pEngine->Enable();          if (pEngine) pEngine->Enable();
242            bStatusChanged = true; // status of engine has changed, so set notify flag
243      }      }
244    
245      /**      /**
# Line 219  namespace LinuxSampler { namespace gig { Line 251  namespace LinuxSampler { namespace gig {
251      void EngineChannel::OnResourceProgress(float fProgress) {      void EngineChannel::OnResourceProgress(float fProgress) {
252          this->InstrumentStat = int(fProgress * 100.0f);          this->InstrumentStat = int(fProgress * 100.0f);
253          dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat));          dmsg(7,("gig::EngineChannel: progress %d%", InstrumentStat));
254            bStatusChanged = true; // status of engine has changed, so set notify flag
255      }      }
256    
257      void EngineChannel::Connect(AudioOutputDevice* pAudioOut) {      void EngineChannel::Connect(AudioOutputDevice* pAudioOut) {
# Line 309  namespace LinuxSampler { namespace gig { Line 342  namespace LinuxSampler { namespace gig {
342          }          }
343      }      }
344    
345        void EngineChannel::Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) {
346            if (!pMidiPort || pMidiPort == this->pMidiInputPort) return;
347            DisconnectMidiInputPort();
348            this->pMidiInputPort = pMidiPort;
349            this->midiChannel    = MidiChannel;
350            pMidiPort->Connect(this, MidiChannel);
351        }
352    
353        void EngineChannel::DisconnectMidiInputPort() {
354            MidiInputPort* pOldPort = this->pMidiInputPort;
355            this->pMidiInputPort = NULL;
356            if (pOldPort) pOldPort->Disconnect(this);
357        }
358    
359        MidiInputPort* EngineChannel::GetMidiInputPort() {
360            return pMidiInputPort;
361        }
362    
363        midi_chan_t EngineChannel::MidiChannel() {
364            return midiChannel;
365        }
366    
367      /**      /**
368       *  Will be called by the MIDIIn Thread to let the audio thread trigger a new       *  Will be called by the MIDIIn Thread to let the audio thread trigger a new
369       *  voice for the given key.       *  voice for the given key.
# Line 400  namespace LinuxSampler { namespace gig { Line 455  namespace LinuxSampler { namespace gig {
455      }      }
456    
457      void EngineChannel::ResetControllers() {      void EngineChannel::ResetControllers() {
458            Pitch          = 0;
459            SustainPedal   = false;
460            GlobalVolume   = 1.0;
461            GlobalPanLeft  = 1.0f;
462            GlobalPanRight = 1.0f;
463          // set all MIDI controller values to zero          // set all MIDI controller values to zero
464          memset(ControllerTable, 0x00, 128);          memset(ControllerTable, 0x00, 128);
465      }      }
# Line 446  namespace LinuxSampler { namespace gig { Line 506  namespace LinuxSampler { namespace gig {
506    
507      void EngineChannel::Volume(float f) {      void EngineChannel::Volume(float f) {
508          GlobalVolume = f;          GlobalVolume = f;
509            bStatusChanged = true; // status of engine channel has changed, so set notify flag
510      }      }
511    
512      uint EngineChannel::Channels() {      uint EngineChannel::Channels() {
# Line 471  namespace LinuxSampler { namespace gig { Line 532  namespace LinuxSampler { namespace gig {
532      String EngineChannel::EngineName() {      String EngineChannel::EngineName() {
533          return LS_GIG_ENGINE_NAME;          return LS_GIG_ENGINE_NAME;
534      }      }
535        
536  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.554  
changed lines
  Added in v.675

  ViewVC Help
Powered by ViewVC