/[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 3625 by schoenebeck, Thu Oct 3 13:37:25 2019 UTC revision 3652 by schoenebeck, Wed Dec 11 11:10:24 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)      // converts ::gig::lfo_wave_t (libgig) -> LFO::wave_t (LinuxSampler)
47      inline LFO::wave_t fromGigLfoWave(::gig::lfo_wave_t wave) {      inline LFO::wave_t fromGigLfoWave(::gig::lfo_wave_t wave) {
48          // simply assuming equally mapped enums on both sides          // simply assuming equally mapped enums on both sides
# Line 419  namespace LinuxSampler { namespace gig { Line 429  namespace LinuxSampler { namespace gig {
429          return cutoff;          return cutoff;
430      }      }
431    
432        /// Returns true for GigaStudio's original filter types.
433        constexpr bool isGStFilterType(::gig::vcf_type_t type) {
434            return type == ::gig::vcf_type_lowpass ||
435                   type == ::gig::vcf_type_lowpassturbo ||
436                   type == ::gig::vcf_type_bandpass ||
437                   type == ::gig::vcf_type_highpass ||
438                   type == ::gig::vcf_type_bandreject;
439        }
440    
441      float Voice::CalculateFinalCutoff(float cutoffBase) {      float Voice::CalculateFinalCutoff(float cutoffBase) {
442          int cvalue;          int cvalue;
443          if (VCFCutoffCtrl.controller) {          if (VCFCutoffCtrl.controller) {
# Line 433  namespace LinuxSampler { namespace gig { Line 452  namespace LinuxSampler { namespace gig {
452          float fco = cutoffBase * float(cvalue);          float fco = cutoffBase * float(cvalue);
453          if (fco > 127.0f) fco = 127.0f;          if (fco > 127.0f) fco = 127.0f;
454    
455            // the filter implementations of the original GSt filter types take an
456            // abstract cutoff parameter range of 0..127, ...
457            if (isGStFilterType(pRegion->VCFType))
458                return fco;
459    
460            // ... whereas our own filter types take a cutoff parameter in Hz, so
461            // remap here 0 .. 127 [lin] -> 21 Hz .. 18 kHz [x^4] (center @2.2 kHz)
462            fco = (fco + 29.f) / (127.f + 29.f);
463            fco = fco * fco * fco * fco * 18000.f;
464            if (fco > 0.49f * pEngine->SampleRate)
465                fco = 0.49f * pEngine->SampleRate;
466          return fco;          return fco;
467      }      }
468    

Legend:
Removed from v.3625  
changed lines
  Added in v.3652

  ViewVC Help
Powered by ViewVC