/[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 3561 by schoenebeck, Fri Aug 23 11:44:00 2019 UTC revision 3628 by schoenebeck, Sat Oct 5 14:37:31 2019 UTC
# Line 33  Line 33 
33    
34  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
35    
36        // sanity checks: fromGigLfoWave() assumes equally mapped enums
37        static_assert(int64_t(::gig::lfo_wave_sine) == int64_t(LFO::wave_sine),
38                      "enum LFO::wave_t not equally value mapped to libgig's enum ::gig::lfo_wave_t");
39        static_assert(int64_t(::gig::lfo_wave_triangle) == int64_t(LFO::wave_triangle),
40                      "enum LFO::wave_t not equally value mapped to libgig's enum ::gig::lfo_wave_t");
41        static_assert(int64_t(::gig::lfo_wave_saw) == int64_t(LFO::wave_saw),
42                      "enum LFO::wave_t not equally value mapped to libgig's enum ::gig::lfo_wave_t");
43        static_assert(int64_t(::gig::lfo_wave_square) == int64_t(LFO::wave_square),
44                      "enum LFO::wave_t not equally value mapped to libgig's enum ::gig::lfo_wave_t");
45    
46        // converts ::gig::lfo_wave_t (libgig) -> LFO::wave_t (LinuxSampler)
47        inline LFO::wave_t fromGigLfoWave(::gig::lfo_wave_t wave) {
48            // simply assuming equally mapped enums on both sides
49            return static_cast<LFO::wave_t>(wave);
50        }
51    
52      Voice::Voice() {      Voice::Voice() {
53          pEngine = NULL;          pEngine = NULL;
54          pEG1 = &EG1;          pEG1 = &EG1;
# Line 273  namespace LinuxSampler { namespace gig { Line 289  namespace LinuxSampler { namespace gig {
289                  bLFO1Enabled         = false;                  bLFO1Enabled         = false;
290          }          }
291          if (bLFO1Enabled) {          if (bLFO1Enabled) {
292              pLFO1->trigger(pRegion->LFO1Frequency,              pLFO1->trigger(fromGigLfoWave(pRegion->LFO1WaveForm),
293                             start_level_min,                             pRegion->LFO1Frequency,
294                               pRegion->LFO1Phase,
295                               LFO::start_level_mid, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
296                             lfo1_internal_depth,                             lfo1_internal_depth,
297                             pRegion->LFO1ControlDepth,                             pRegion->LFO1ControlDepth,
298                             pRegion->LFO1FlipPhase,                             pRegion->LFO1FlipPhase,
# Line 329  namespace LinuxSampler { namespace gig { Line 347  namespace LinuxSampler { namespace gig {
347                  bLFO2Enabled         = false;                  bLFO2Enabled         = false;
348          }          }
349          if (bLFO2Enabled) {          if (bLFO2Enabled) {
350              pLFO2->trigger(pRegion->LFO2Frequency,              pLFO2->trigger(fromGigLfoWave(pRegion->LFO2WaveForm),
351                             start_level_max,                             pRegion->LFO2Frequency,
352                               pRegion->LFO2Phase,
353                               LFO::start_level_mid, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
354                             lfo2_internal_depth,                             lfo2_internal_depth,
355                             pRegion->LFO2ControlDepth,                             pRegion->LFO2ControlDepth,
356                             pRegion->LFO2FlipPhase,                             pRegion->LFO2FlipPhase,
# Line 381  namespace LinuxSampler { namespace gig { Line 401  namespace LinuxSampler { namespace gig {
401                  bLFO3Enabled         = false;                  bLFO3Enabled         = false;
402          }          }
403          if (bLFO3Enabled) {          if (bLFO3Enabled) {
404              pLFO3->trigger(pRegion->LFO3Frequency,              pLFO3->trigger(fromGigLfoWave(pRegion->LFO3WaveForm),
405                             start_level_mid,                             pRegion->LFO3Frequency,
406                               pRegion->LFO3Phase,
407                               LFO::start_level_max, // see https://sourceforge.net/p/linuxsampler/mailman/linuxsampler-devel/thread/2189307.cNP0Xbctxq%40silver/#msg36774029
408                             lfo3_internal_depth,                             lfo3_internal_depth,
409                             pRegion->LFO3ControlDepth,                             pRegion->LFO3ControlDepth,
410                             false,                             pRegion->LFO3FlipPhase,
411                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                             pEngine->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
412              pLFO3->updateByMIDICtrlValue(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);              pLFO3->updateByMIDICtrlValue(pLFO3->ExtController ? GetGigEngineChannel()->ControllerTable[pLFO3->ExtController] : 0);
413              pLFO3->setScriptDepthFactor(              pLFO3->setScriptDepthFactor(
# Line 498  namespace LinuxSampler { namespace gig { Line 520  namespace LinuxSampler { namespace gig {
520              pRegion->EG1Options.ReleaseCancel              pRegion->EG1Options.ReleaseCancel
521          );          );
522          EG1.trigger(pRegion->EG1PreAttack,          EG1.trigger(pRegion->EG1PreAttack,
523                      RTMath::Max(pRegion->EG1Attack, 0.0316) * egInfo.Attack,                      (pNote && pNote->Override.Attack.isFinal()) ?
524                            pNote->Override.Attack.Value :
525                            RTMath::Max(pRegion->EG1Attack, 0.0316) * egInfo.Attack,
526                      pRegion->EG1Hold,                      pRegion->EG1Hold,
527                      pRegion->EG1Decay1 * egInfo.Decay * velrelease,                      (pNote && pNote->Override.Decay.isFinal()) ?
528                      pRegion->EG1Decay2 * egInfo.Decay * velrelease,                          pNote->Override.Decay.Value :
529                            pRegion->EG1Decay1 * egInfo.Decay * velrelease,
530                        (pNote && pNote->Override.Decay.isFinal()) ?
531                            pNote->Override.Decay.Value :
532                            pRegion->EG1Decay2 * egInfo.Decay * velrelease,
533                      pRegion->EG1InfiniteSustain,                      pRegion->EG1InfiniteSustain,
534                      (pNote && pNote->Override.Sustain.Final) ?                      (pNote && pNote->Override.Sustain.Final) ?
535                          pNote->Override.Sustain.Value :                          uint(pNote->Override.Sustain.Value * 1000.f) :
536                          pRegion->EG1Sustain * (pNote ? pNote->Override.Sustain.Value : 1.f),                          pRegion->EG1Sustain * (pNote ? pNote->Override.Sustain.Value : 1.f),
537                      RTMath::Max(pRegion->EG1Release * velrelease, 0.014) * egInfo.Release,                      (pNote && pNote->Override.Release.isFinal()) ?
538                            pNote->Override.Release.Value :
539                            RTMath::Max(pRegion->EG1Release * velrelease, 0.014) * egInfo.Release,
540                      velocityAttenuation,                      velocityAttenuation,
541                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
542      }      }
# Line 520  namespace LinuxSampler { namespace gig { Line 550  namespace LinuxSampler { namespace gig {
550              pRegion->EG2Options.ReleaseCancel              pRegion->EG2Options.ReleaseCancel
551          );          );
552          EG2.trigger(uint(RgnInfo.EG2PreAttack),          EG2.trigger(uint(RgnInfo.EG2PreAttack),
553                      RgnInfo.EG2Attack * egInfo.Attack,                      (pNote && pNote->Override.CutoffAttack.isFinal()) ?
554                            pNote->Override.CutoffAttack.Value :
555                            RgnInfo.EG2Attack * egInfo.Attack,
556                      false,                      false,
557                      RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,                      (pNote && pNote->Override.CutoffDecay.isFinal()) ?
558                      RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,                          pNote->Override.CutoffDecay.Value :
559                            RgnInfo.EG2Decay1 * egInfo.Decay * velrelease,
560                        (pNote && pNote->Override.CutoffDecay.isFinal()) ?
561                            pNote->Override.CutoffDecay.Value :
562                            RgnInfo.EG2Decay2 * egInfo.Decay * velrelease,
563                      RgnInfo.EG2InfiniteSustain,                      RgnInfo.EG2InfiniteSustain,
564                      uint(RgnInfo.EG2Sustain),                      (pNote && pNote->Override.CutoffSustain.Final) ?
565                      RgnInfo.EG2Release * egInfo.Release * velrelease,                          uint(pNote->Override.CutoffSustain.Value * 1000.f) :
566                            uint(RgnInfo.EG2Sustain),
567                        (pNote && pNote->Override.CutoffRelease.isFinal()) ?
568                            pNote->Override.CutoffRelease.Value :
569                            RgnInfo.EG2Release * egInfo.Release * velrelease,
570                      velocityAttenuation,                      velocityAttenuation,
571                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);                      sampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE);
572      }      }

Legend:
Removed from v.3561  
changed lines
  Added in v.3628

  ViewVC Help
Powered by ViewVC