/[svn]/linuxsampler/trunk/src/engines/common/LFOTriangleDiHarmonic.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/engines/common/LFOTriangleDiHarmonic.h

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

revision 1680 by schoenebeck, Sun Jul 24 19:44:44 2005 UTC revision 1681 by schoenebeck, Wed Feb 13 15:10:13 2008 UTC
# Line 1  Line 1 
1  /***************************************************************************  /***************************************************************************
2   *                                                                         *   *                                                                         *
3   *   Copyright (C) 2005 Christian Schoenebeck                              *   *   Copyright (C) 2005, 2008 Christian Schoenebeck                        *
4   *                                                                         *   *                                                                         *
5   *   This library is free software; you can redistribute it and/or modify  *   *   This library is free software; you can redistribute it and/or modify  *
6   *   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 24  Line 24 
24  #include "LFOBase.h"  #include "LFOBase.h"
25    
26  // amplitue of 2nd harmonic (to approximate the triangular wave)  // amplitue of 2nd harmonic (to approximate the triangular wave)
27  #define AMP2    0.11425509f  #define AMP2    -0.11425509f
28    
29  namespace LinuxSampler {  namespace LinuxSampler {
30    
# Line 70  namespace LinuxSampler { Line 70  namespace LinuxSampler {
70              inline void update(const uint16_t& ExtControlValue) {              inline void update(const uint16_t& ExtControlValue) {
71                  const float max = this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff;                  const float max = this->InternalDepth + ExtControlValue * this->ExtControlDepthCoeff;
72                  if (RANGE == range_unsigned) {                  if (RANGE == range_unsigned) {
73                      const float harmonicCompensation = 1.0f + AMP2; // to compensate the compensation ;) (see trigger())                      const float harmonicCompensation = 1.0f + fabsf(AMP2); // to compensate the compensation ;) (see trigger())
74                      normalizer = max * 0.5f;                      normalizer = max * 0.5f;
75                      offset     = normalizer * harmonicCompensation;                      offset     = normalizer * harmonicCompensation;
76                  } else { // signed range                  } else { // signed range
# Line 93  namespace LinuxSampler { Line 93  namespace LinuxSampler {
93               *                          audio output signal               *                          audio output signal
94               */               */
95              void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {              void trigger(float Frequency, start_level_t StartLevel, uint16_t InternalDepth, uint16_t ExtControlDepth, bool FlipPhase, unsigned int SampleRate) {
96                  const float harmonicCompensation = 1.0f + AMP2; // to compensate the 2nd harmonic's amplitude overhead                  const float harmonicCompensation = 1.0f + fabsf(AMP2); // to compensate the 2nd harmonic's amplitude overhead
97                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max / harmonicCompensation;                  this->InternalDepth        = (InternalDepth / 1200.0f) * this->Max / harmonicCompensation;
98                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max / harmonicCompensation;                  this->ExtControlDepthCoeff = (((float) ExtControlDepth / 1200.0f) / 127.0f) * this->Max / harmonicCompensation;
99    
100                  c1 = 2.0f * M_PI * Frequency / (float) SampleRate;                  c1 = 2.0f * M_PI * Frequency / (float) SampleRate;

Legend:
Removed from v.1680  
changed lines
  Added in v.1681

  ViewVC Help
Powered by ViewVC