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

Diff of /linuxsampler/trunk/src/engines/sfz/Voice.cpp

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

revision 2252 by iliev, Sat Aug 20 14:01:36 2011 UTC revision 3054 by schoenebeck, Thu Dec 15 12:47:45 2016 UTC
# Line 4  Line 4 
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 - 2008 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *
7   *   Copyright (C) 2009 - 2011 Christian Schoenebeck and Grigor Iliev      *   *   Copyright (C) 2009 - 2015 Christian Schoenebeck and Grigor Iliev      *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   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 31  Line 31 
31    
32  namespace LinuxSampler { namespace sfz {  namespace LinuxSampler { namespace sfz {
33    
34      typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice;      typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoiceBase;
35      Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) {  
36        Voice::Voice(): SfzVoiceBase(&SignalRack), SignalRack(this) {
37          pEngine     = NULL;          pEngine     = NULL;
38            bEqSupport = true;
39      }      }
40    
41      Voice::~Voice() {      Voice::~Voice() {
# Line 57  namespace LinuxSampler { namespace sfz { Line 59  namespace LinuxSampler { namespace sfz {
59          si.ChannelCount     = pSample->GetChannelCount();          si.ChannelCount     = pSample->GetChannelCount();
60          si.FrameSize        = pSample->GetFrameSize();          si.FrameSize        = pSample->GetFrameSize();
61          si.BitDepth         = (pSample->GetFrameSize() / pSample->GetChannelCount()) * 8;          si.BitDepth         = (pSample->GetFrameSize() / pSample->GetChannelCount()) * 8;
62          si.TotalFrameCount  = pSample->GetTotalFrameCount();          si.TotalFrameCount  = (uint)pSample->GetTotalFrameCount();
63    
64          si.HasLoops       = pRegion->HasLoop();          si.HasLoops       = pRegion->HasLoop();
65          si.LoopStart      = pRegion->GetLoopStart();          si.LoopStart      = pRegion->GetLoopStart();
# Line 133  namespace LinuxSampler { namespace sfz { Line 135  namespace LinuxSampler { namespace sfz {
135      }      }
136    
137      double Voice::GetSampleAttenuation() {      double Voice::GetSampleAttenuation() {
138          return exp(LN_10_DIV_20 * pRegion->volume);          return exp(LN_10_DIV_20 * pRegion->volume) * pRegion->amplitude / 100;
139      }      }
140    
141      double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) {      double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) {
142          return pRegion->amp_velcurve[MIDIKeyVelocity];          float offset = -pRegion->amp_veltrack;
143            if (offset <= 0) offset += 100;
144            return (offset + pRegion->amp_veltrack * pRegion->amp_velcurve[MIDIKeyVelocity]) / 100;
145      }      }
146    
147      double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) {      double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) {
# Line 153  namespace LinuxSampler { namespace sfz { Line 157  namespace LinuxSampler { namespace sfz {
157          }*/ // TODO: ^^^          }*/ // TODO: ^^^
158      }      }
159    
160        void Voice::ProcessChannelPressureEvent(RTList<Event>::Iterator& itEvent) {
161            //TODO: ...
162        }
163    
164        void Voice::ProcessPolyphonicKeyPressureEvent(RTList<Event>::Iterator& itEvent) {
165            //TODO: ...
166        }
167    
168      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {      double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) {
169          /*float crossfadeVolume;          /*float crossfadeVolume;
170          switch (pRegion->AttenuationController.type) {          switch (pRegion->AttenuationController.type) {
# Line 253  namespace LinuxSampler { namespace sfz { Line 265  namespace LinuxSampler { namespace sfz {
265          float cutoff = *pRegion->cutoff;          float cutoff = *pRegion->cutoff;
266          cutoff *= RTMath::CentsToFreqRatioUnlimited(          cutoff *= RTMath::CentsToFreqRatioUnlimited(
267              MIDIKeyVelocity / 127.0f * pRegion->fil_veltrack +              MIDIKeyVelocity / 127.0f * pRegion->fil_veltrack +
268              (MIDIKey - pRegion->fil_keycenter) * pRegion->fil_keytrack);              (MIDIKey() - pRegion->fil_keycenter) * pRegion->fil_keytrack);
269          return cutoff;          return cutoff;
270      }      }
271    
# Line 269  namespace LinuxSampler { namespace sfz { Line 281  namespace LinuxSampler { namespace sfz {
281      }      }
282    
283      void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) {      void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) {
284          dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type));          dmsg(4,("Voice %p processGroupEvents event type=%d", (void*)this, itEvent->Type));
285          if (itEvent->Type == Event::type_control_change ||          if (itEvent->Type == Event::type_control_change ||
286              (Type & Voice::type_controller_triggered) ||              (Type & Voice::type_controller_triggered) ||
287              itEvent->Param.Note.Key != MIDIKey) {              itEvent->Param.Note.Key != HostKey()) {
288              dmsg(4,("Voice %x - kill", this));              dmsg(4,("Voice %p - kill", (void*)this));
289              if (pRegion->off_mode == ::sfz::OFF_NORMAL) {              if (pRegion->off_mode == ::sfz::OFF_NORMAL) {
290                  // turn off the voice by entering release envelope stage                  // turn off the voice by entering release envelope stage
291                  EnterReleaseStage();                  EnterReleaseStage();
# Line 295  namespace LinuxSampler { namespace sfz { Line 307  namespace LinuxSampler { namespace sfz {
307          }          }
308      }      }
309    
310        void Voice::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) {
311            SignalRack.CalculateFadeOutCoeff(FadeOutTime, SampleRate);
312        }
313    
314        int Voice::CalculatePan(uint8_t pan) {
315            // the value isn't limited to [0, 127] here, as this is done
316            // later in SignalUnit.CalculatePan
317            return pan + RgnInfo.Pan;
318        }
319    
320  }} // namespace LinuxSampler::sfz  }} // namespace LinuxSampler::sfz

Legend:
Removed from v.2252  
changed lines
  Added in v.3054

  ViewVC Help
Powered by ViewVC