/[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 1695 by schoenebeck, Sat Feb 16 01:09:33 2008 UTC revision 1777 by persson, Mon Sep 15 16:58:10 2008 UTC
# Line 32  Line 32 
32  #include "drivers/audio/AudioOutputDeviceFactory.h"  #include "drivers/audio/AudioOutputDeviceFactory.h"
33  #include "drivers/midi/MidiInputDeviceFactory.h"  #include "drivers/midi/MidiInputDeviceFactory.h"
34  #include "drivers/midi/MidiInstrumentMapper.h"  #include "drivers/midi/MidiInstrumentMapper.h"
35    #include "common/Features.h"
36    #include "network/lscpserver.h"
37    
38  namespace LinuxSampler {  namespace LinuxSampler {
39    
# Line 82  namespace LinuxSampler { Line 84  namespace LinuxSampler {
84          EngineChannel* pNewEngineChannel = EngineChannelFactory::Create(EngineType);          EngineChannel* pNewEngineChannel = EngineChannelFactory::Create(EngineType);
85          if (!pNewEngineChannel) throw Exception("Unknown engine type");          if (!pNewEngineChannel) throw Exception("Unknown engine type");
86    
87          //FIXME: hack to allow fast retrieval of engine channel's sampler channel index          pNewEngineChannel->SetSamplerChannel(this);
         pNewEngineChannel->iSamplerChannelIndex = Index();  
88    
89          // dereference midi input port.          // dereference midi input port.
90          MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort());          MidiInputPort* pMidiInputPort = __GetMidiInputDevicePort(GetMidiInputPort());
# Line 215  namespace LinuxSampler { Line 216  namespace LinuxSampler {
216          throw Exception("Internal error: SamplerChannel index not found");          throw Exception("Internal error: SamplerChannel index not found");
217      }      }
218    
219        Sampler* SamplerChannel::GetSampler() {
220            return pSampler;
221        }
222    
223      void SamplerChannel::AddEngineChangeListener(EngineChangeListener* l) {      void SamplerChannel::AddEngineChangeListener(EngineChangeListener* l) {
224          llEngineChangeListeners.AddListener(l);          llEngineChangeListeners.AddListener(l);
225      }      }
# Line 545  namespace LinuxSampler { Line 550  namespace LinuxSampler {
550          for (; iter != mAudioOutputDevices.end(); iter++) {          for (; iter != mAudioOutputDevices.end(); iter++) {
551              if (iter->second == pDevice) {              if (iter->second == pDevice) {
552                  // check if there are still sampler engines connected to this device                  // check if there are still sampler engines connected to this device
553                  for (uint i = 0; i < SamplerChannels(); i++)                  for (SamplerChannelMap::iterator iterChan = mSamplerChannels.begin();
554                      if (GetSamplerChannel(i)->GetAudioOutputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the audio output device.");                       iterChan != mSamplerChannels.end(); iterChan++)
555                        if (iterChan->second->GetAudioOutputDevice() == pDevice) throw Exception("Sampler channel " + ToString(iterChan->first) + " is still connected to the audio output device.");
556    
557                  // disable device                  // disable device
558                  pDevice->Stop();                  pDevice->Stop();
# Line 568  namespace LinuxSampler { Line 574  namespace LinuxSampler {
574          for (; iter != mMidiInputDevices.end(); iter++) {          for (; iter != mMidiInputDevices.end(); iter++) {
575              if (iter->second == pDevice) {              if (iter->second == pDevice) {
576                  // check if there are still sampler engines connected to this device                  // check if there are still sampler engines connected to this device
577                  for (uint i = 0; i < SamplerChannels(); i++)                  for (SamplerChannelMap::iterator iterChan = mSamplerChannels.begin();
578                      if (GetSamplerChannel(i)->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(i) + " is still connected to the midi input device.");                       iterChan != mSamplerChannels.end(); iterChan++)
579                        if (iterChan->second->GetMidiInputDevice() == pDevice) throw Exception("Sampler channel " + ToString(iterChan->first) + " is still connected to the midi input device.");
580    
581                  fireMidiDeviceToBeDestroyed(pDevice);                  fireMidiDeviceToBeDestroyed(pDevice);
582    
# Line 680  namespace LinuxSampler { Line 687  namespace LinuxSampler {
687          InstrumentEditorFactory::ClosePlugins();          InstrumentEditorFactory::ClosePlugins();
688      }      }
689    
690        bool Sampler::EnableDenormalsAreZeroMode() {
691            Features::detect();
692            return Features::enableDenormalsAreZeroMode();
693        }
694    
695        void Sampler::fireStatistics() {
696            static const LSCPEvent::event_t eventsArr[] = {
697                LSCPEvent::event_voice_count, LSCPEvent::event_stream_count,
698                LSCPEvent::event_buffer_fill, LSCPEvent::event_total_voice_count
699            };
700            static const std::list<LSCPEvent::event_t> events(eventsArr, eventsArr + 4);
701    
702            if (LSCPServer::EventSubscribers(events))
703            {
704                LSCPServer::LockRTNotify();
705                std::map<uint,SamplerChannel*> channels = GetSamplerChannels();
706                std::map<uint,SamplerChannel*>::iterator iter = channels.begin();
707                for (; iter != channels.end(); iter++) {
708                    SamplerChannel* pSamplerChannel = iter->second;
709                    EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
710                    if (!pEngineChannel) continue;
711                    Engine* pEngine = pEngineChannel->GetEngine();
712                    if (!pEngine) continue;
713                    fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount());
714                    fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount());
715                    fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage());
716                    fireTotalStreamCountChanged(GetDiskStreamCount());
717                    fireTotalVoiceCountChanged(GetVoiceCount());
718                }
719                LSCPServer::UnlockRTNotify();
720            }
721        }
722    
723  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.1695  
changed lines
  Added in v.1777

  ViewVC Help
Powered by ViewVC