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

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

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

revision 3017 by schoenebeck, Wed Oct 19 12:28:40 2016 UTC revision 3615 by schoenebeck, Tue Oct 1 09:49:08 2019 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 - 2015 Christian Schoenebeck and Grigor Iliev      *   *   Copyright (C) 2009 Christian Schoenebeck and Grigor Iliev             *
8     *   Copyright (C) 2010 - 2017 Christian Schoenebeck and Andreas Persson   *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   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 58  namespace LinuxSampler { namespace gig { Line 59  namespace LinuxSampler { namespace gig {
59          si.ChannelCount     = pSample->Channels;          si.ChannelCount     = pSample->Channels;
60          si.FrameSize        = pSample->FrameSize;          si.FrameSize        = pSample->FrameSize;
61          si.BitDepth         = pSample->BitDepth;          si.BitDepth         = pSample->BitDepth;
62          si.TotalFrameCount  = pSample->SamplesTotal;          si.TotalFrameCount  = (uint)pSample->SamplesTotal;
63    
64          si.HasLoops       = pRegion->SampleLoops;          si.HasLoops       = pRegion->SampleLoops;
65          si.LoopStart      = (si.HasLoops) ? pRegion->pSampleLoops[0].LoopStart  : 0;          si.LoopStart      = (si.HasLoops) ? pRegion->pSampleLoops[0].LoopStart  : 0;
# Line 273  namespace LinuxSampler { namespace gig { Line 274  namespace LinuxSampler { namespace gig {
274          }          }
275          if (bLFO1Enabled) {          if (bLFO1Enabled) {
276              pLFO1->trigger(pRegion->LFO1Frequency,              pLFO1->trigger(pRegion->LFO1Frequency,
277                             start_level_min,                             LFO::start_level_mid, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
278                             lfo1_internal_depth,                             lfo1_internal_depth,
279                             pRegion->LFO1ControlDepth,                             pRegion->LFO1ControlDepth,
280                             pRegion->LFO1FlipPhase,                             pRegion->LFO1FlipPhase,
281                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
282              pLFO1->update(pLFO1->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO1->ExtController] : 0);              pLFO1->updateByMIDICtrlValue(pLFO1->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO1->ExtController] : 0);
283                pLFO1->setScriptDepthFactor(
284                    pNote->Override.AmpLFODepth.Value,
285                    pNote->Override.AmpLFODepth.Final
286                );
287                if (pNote->Override.AmpLFOFreq.isFinal())
288                    pLFO1->setScriptFrequencyFinal(
289                        pNote->Override.AmpLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE
290                    );
291                else
292                    pLFO1->setScriptFrequencyFactor(
293                        pNote->Override.AmpLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE
294                    );
295          }          }
296      }      }
297    
# Line 317  namespace LinuxSampler { namespace gig { Line 330  namespace LinuxSampler { namespace gig {
330          }          }
331          if (bLFO2Enabled) {          if (bLFO2Enabled) {
332              pLFO2->trigger(pRegion->LFO2Frequency,              pLFO2->trigger(pRegion->LFO2Frequency,
333                             start_level_max,                             LFO::start_level_mid, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
334                             lfo2_internal_depth,                             lfo2_internal_depth,
335                             pRegion->LFO2ControlDepth,                             pRegion->LFO2ControlDepth,
336                             pRegion->LFO2FlipPhase,                             pRegion->LFO2FlipPhase,
337                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
338              pLFO2->update(pLFO2->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO2->ExtController] : 0);              pLFO2->updateByMIDICtrlValue(pLFO2->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO2->ExtController] : 0);
339                pLFO2->setScriptDepthFactor(
340                    pNote->Override.CutoffLFODepth.Value,
341                    pNote->Override.CutoffLFODepth.Final
342                );
343                if (pNote->Override.CutoffLFOFreq.isFinal())
344                    pLFO2->setScriptFrequencyFinal(pNote->Override.CutoffLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
345                else
346                    pLFO2->setScriptFrequencyFactor(pNote->Override.CutoffLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
347          }          }
348      }      }
349    
# Line 361  namespace LinuxSampler { namespace gig { Line 382  namespace LinuxSampler { namespace gig {
382          }          }
383          if (bLFO3Enabled) {          if (bLFO3Enabled) {
384              pLFO3->trigger(pRegion->LFO3Frequency,              pLFO3->trigger(pRegion->LFO3Frequency,
385                             start_level_mid,                             LFO::start_level_max, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
386                             lfo3_internal_depth,                             lfo3_internal_depth,
387                             pRegion->LFO3ControlDepth,                             pRegion->LFO3ControlDepth,
388                             false,                             false,
389                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
390              pLFO3->update(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);              pLFO3->updateByMIDICtrlValue(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);
391                pLFO3->setScriptDepthFactor(
392                    pNote->Override.PitchLFODepth.Value,
393                    pNote->Override.PitchLFODepth.Final
394                );
395                if (pNote->Override.PitchLFOFreq.isFinal())
396                    pLFO3->setScriptFrequencyFinal(pNote->Override.PitchLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
397                else
398                    pLFO3->setScriptFrequencyFactor(pNote->Override.PitchLFOFreq.Value, pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
399          }          }
400      }      }
401    
# Line 461  namespace LinuxSampler { namespace gig { Line 490  namespace LinuxSampler { namespace gig {
490      }      }
491    
492      void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {      void Voice::TriggerEG1(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
493            EG1.setStateOptions(
494                pRegion->EG1Options.AttackCancel,
495                pRegion->EG1Options.AttackHoldCancel,
496                pRegion->EG1Options.Decay1Cancel,
497                pRegion->EG1Options.Decay2Cancel,
498                pRegion->EG1Options.ReleaseCancel
499            );
500          EG1.trigger(pRegion->EG1PreAttack,          EG1.trigger(pRegion->EG1PreAttack,
501                      RTMath::Max(pRegion->EG1Attack, 0.0316) * egInfo.Attack,                      (pNote && pNote->Override.Attack.isFinal()) ?
502                            pNote->Override.Attack.Value :
503                            RTMath::Max(pRegion->EG1Attack, 0.0316) * egInfo.Attack,
504                      pRegion->EG1Hold,                      pRegion->EG1Hold,
505                      pRegion->EG1Decay1 * egInfo.Decay * velrelease,                      (pNote && pNote->Override.Decay.isFinal()) ?
506                      pRegion->EG1Decay2 * egInfo.Decay * velrelease,                          pNote->Override.Decay.Value :
507                            pRegion->EG1Decay1 * egInfo.Decay * velrelease,
508                        (pNote && pNote->Override.Decay.isFinal()) ?
509                            pNote->Override.Decay.Value :
510                            pRegion->EG1Decay2 * egInfo.Decay * velrelease,
511                      pRegion->EG1InfiniteSustain,                      pRegion->EG1InfiniteSustain,
512                      pRegion->EG1Sustain,                      (pNote && pNote->Override.Sustain.Final) ?
513                      RTMath::Max(pRegion->EG1Release * velrelease, 0.014) * egInfo.Release,                          uint(pNote->Override.Sustain.Value * 1000.f) :
514                            pRegion->EG1Sustain * (pNote ? pNote->Override.Sustain.Value : 1.f),
515                        (pNote && pNote->Override.Release.isFinal()) ?
516                            pNote->Override.Release.Value :
517                            RTMath::Max(pRegion->EG1Release * velrelease, 0.014) * egInfo.Release,
518                      velocityAttenuation,                      velocityAttenuation,
519                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
520      }      }
521    
522      void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {      void Voice::TriggerEG2(const EGInfo& egInfo, double velrelease, double velocityAttenuation, uint sampleRate, uint8_t velocity) {
523            EG2.setStateOptions(
524                pRegion->EG2Options.AttackCancel,
525                pRegion->EG2Options.AttackHoldCancel,
526                pRegion->EG2Options.Decay1Cancel,
527                pRegion->EG2Options.Decay2Cancel,
528                pRegion->EG2Options.ReleaseCancel
529            );
530          EG2.trigger(uint(RgnInfo.EG2PreAttack),          EG2.trigger(uint(RgnInfo.EG2PreAttack),
531                      RgnInfo.EG2Attack * egInfo.Attack,                      (pNote && pNote->Override.CutoffAttack.isFinal()) ?
532                            pNote->Override.CutoffAttack.Value :
533                            RgnInfo.EG2Attack * egInfo.Attack,
534                      false,                      false,
535                      RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,                      (pNote && pNote->Override.CutoffDecay.isFinal()) ?
536                      RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,                          pNote->Override.CutoffDecay.Value :
537                            RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,
538                        (pNote && pNote->Override.CutoffDecay.isFinal()) ?
539                            pNote->Override.CutoffDecay.Value :
540                            RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,
541                      RgnInfo.EG2InfiniteSustain,                      RgnInfo.EG2InfiniteSustain,
542                      uint(RgnInfo.EG2Sustain),                      (pNote && pNote->Override.CutoffSustain.Final) ?
543                      RgnInfo.EG2Release * egInfo.Release * velrelease,                          uint(pNote->Override.CutoffSustain.Value * 1000.f) :
544                            uint(RgnInfo.EG2Sustain),
545                        (pNote && pNote->Override.CutoffRelease.isFinal()) ?
546                            pNote->Override.CutoffRelease.Value :
547                            RgnInfo.EG2Release * egInfo.Release * velrelease,
548                      velocityAttenuation,                      velocityAttenuation,
549                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
550      }      }
# Line 523  namespace LinuxSampler { namespace gig { Line 586  namespace LinuxSampler { namespace gig {
586          return p;          return p;
587      }      }
588    
589        release_trigger_t Voice::GetReleaseTriggerFlags() {
590            release_trigger_t flags =
591                (pRegion->NoNoteOffReleaseTrigger) ?
592                    release_trigger_none : release_trigger_noteoff; //HACK: currently this method is actually only called by EngineBase if it already knows that this voice requires release trigger, so I took the short way instead of checking (again) the existence of a ::gig::dimension_releasetrigger
593            switch (pRegion->SustainReleaseTrigger) {
594                case ::gig::sust_rel_trg_none:
595                    break;
596                case ::gig::sust_rel_trg_maxvelocity:
597                    flags |= release_trigger_sustain_maxvelocity;
598                    break;
599                case ::gig::sust_rel_trg_keyvelocity:
600                    flags |= release_trigger_sustain_keyvelocity;
601                    break;
602            }
603            return flags;
604        }
605    
606  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig

Legend:
Removed from v.3017  
changed lines
  Added in v.3615

  ViewVC Help
Powered by ViewVC