// ----
// ---- file   : rev_1_stereo.cpp
// ---- author : bsp
// ---- legal  : Distributed under terms of the MIT license (https://opensource.org/licenses/MIT)
// ----
// ----          Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
// ----          associated documentation files (the "Software"), to deal in the Software without restriction, including
// ----          without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// ----          copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to
// ----          the following conditions:
// ----
// ----          The above copyright notice and this permission notice shall be included in all copies or substantial
// ----          portions of the Software.
// ----
// ----          THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
// ----          NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// ----          IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// ----          WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// ----          SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ----
// ---- info   : auto-generated by "Cycle"
// ----           $ g++ -Wall -Wno-unused-function -Wno-unused-variable -I../../tksampler -c rev_1_stereo.cpp -o rev_1_stereo.o
// ---- created: 22Dec2024 11:36:36
// ----
// ----
// ----

// (note) pre-define CYCLE_SKIP_UI to skip all code used only for UI/editing purposes (e.g. when compiling for standalone replay)
// #define CYCLE_SKIP_UI  defined

#include <plugin.h>

#include <stdlib.h>
#include <math.h>
#include <string.h>

#define STEREO  defined

#define PARAM_T                  0
#define PARAM_LPF                1
#define PARAM_HPF                2
#define PARAM_MIX                3
#define PARAM_BALANCE            4
#define PARAM_CROSSFB            5
#define NUM_PARAMS               6
#ifndef CYCLE_SKIP_UI
static const char *loc_param_names[NUM_PARAMS
#if defined(_MSC_VER) && 0 == NUM_PARAMS
                                   +1
#endif
                                   ] = {
#if defined(_MSC_VER) && 0 == NUM_PARAMS
                                   ""
#else
   "t",                       // 0: T
   "lpf",                     // 1: LPF
   "hpf",                     // 2: HPF
   "mix",                     // 3: MIX
   "balance",                 // 4: BALANCE
   "crossfb",                 // 5: CROSSFB

#endif
};
#endif // CYCLE_SKIP_UI
static float loc_param_resets[NUM_PARAMS
#if defined(_MSC_VER) && 0 == NUM_PARAMS
                                   +1
#endif
                              ] = {
#if defined(_MSC_VER) && 0 == NUM_PARAMS
   0.0f
#else
   0.5f,                      // 0: T
   0.5f,                      // 1: LPF
   0.7f,                      // 2: HPF
   0.5f,                      // 3: MIX
   0.5f,                      // 4: BALANCE
   0.1f,                      // 5: CROSSFB

#endif
};

#define MOD_T                    0
#define MOD_LPF                  1
#define MOD_HPF                  2
#define MOD_MIX                  3
#define MOD_BALANCE              4
#define MOD_CROSSFB              5
#define NUM_MODS                 6
#ifndef CYCLE_SKIP_UI
static const char *loc_mod_names[NUM_MODS
#if defined(_MSC_VER) && 0 == NUM_MODS
   +1
#endif
                                 ] = {
#if defined(_MSC_VER) && 0 == NUM_MODS
   ""
#else
   "t",                    // 0: T
   "lpf",                  // 1: LPF
   "hpf",                  // 2: HPF
   "mix",                  // 3: MIX
   "balance",              // 4: BALANCE
   "crossfb",              // 5: CROSSFB

#endif
};
#endif // CYCLE_SKIP_UI

typedef struct rev_1_stereo_info_s {
   st_plugin_info_t base;
} rev_1_stereo_info_t;

typedef struct rev_1_stereo_shared_s {
   st_plugin_shared_t base;
   float params[NUM_PARAMS
#if defined(_MSC_VER) && 0 == NUM_PARAMS
                +1
#endif
                ];

} rev_1_stereo_shared_t;

typedef struct rev_1_stereo_voice_s {
   st_plugin_voice_t base;
   float             sample_rate;
   float             bpm;
   float             velocity;
   float             note_speed_fixed;
   float             note_speed_cur;
   float             note_speed_inc;
   float             note_cur;
   float             note_inc;
   float             mods[NUM_MODS
#if defined(_MSC_VER) && 0 == NUM_MODS
                          +1
#endif
                          ];
   float mod_t_cur;
   float mod_t_inc;
   float mod_lpf_cur;
   float mod_lpf_inc;
   float mod_hpf_cur;
   float mod_hpf_inc;
   float mod_mix_cur;
   float mod_mix_inc;
   float mod_balance_cur;
   float mod_balance_inc;
   float mod_crossfb_cur;
   float mod_crossfb_inc;

   float tmp1;
   float tmp2;
   float tmp3;
   float tmp4_hpf_z1;
   float tmp5_hpf_z2;
   float tmp6;
   float tmp7;
   float tmp8_lpf_1rc_v0;
   float tmp9_lpf_1rc_v1;
   float tmp10;
   float tmp11_hbx_last;
   int tmp12_dly_write_idx;
   float arr0_dly[4096];
   float tmp13;
   int tmp14;
   int tmp15;
   float tmp16;
   float tmp17;
   float tmp18_apf_state;
   float tmp19_lpf_1rc_v0;
   float tmp20_lpf_1rc_v1;
   float tmp21_hbx_last;
   int tmp22_dly_write_idx;
   float arr1_dly[4096];
   int tmp23;
   float tmp24;
   float tmp25_apf_state;
   float tmp26_lpf_1rc_v0;
   float tmp27_lpf_1rc_v1;
   float tmp28_hbx_last;
   int tmp29_dly_write_idx;
   float arr2_dly[4096];
   int tmp30;
   float tmp31;
   float tmp32_apf_state;
   float tmp33_lpf_1rc_v0;
   float tmp34_lpf_1rc_v1;
   float tmp35_hbx_last;
   int tmp36_dly_write_idx;
   float arr3_dly[4096];
   int tmp37;
   float tmp38;
   float tmp39_apf_state;
   float tmp40_hpf_z1;
   float tmp41_hpf_z2;
   float tmp42_lpf_1rc_v0;
   float tmp43_lpf_1rc_v1;
   float tmp44_hbx_last;
   int tmp45_dly_write_idx;
   float arr4_dly[4096];
   int tmp46;
   float tmp47;
   float tmp48_apf_state;
   float tmp49_lpf_1rc_v0;
   float tmp50_lpf_1rc_v1;
   float tmp51_hbx_last;
   int tmp52_dly_write_idx;
   float arr5_dly[4096];
   int tmp53;
   float tmp54;
   float tmp55_apf_state;
   float tmp56_lpf_1rc_v0;
   float tmp57_lpf_1rc_v1;
   float tmp58_hbx_last;
   int tmp59_dly_write_idx;
   float arr6_dly[4096];
   int tmp60;
   float tmp61;
   float tmp62_apf_state;
   float tmp63_lpf_1rc_v0;
   float tmp64_lpf_1rc_v1;
   float tmp65_hbx_last;
   int tmp66_dly_write_idx;
   float arr7_dly[4096];
   int tmp67;
   float tmp68;
   float tmp69_apf_state;
   float var_x;
   float var_v_lpf;
   float var_v_t_l;
   float var_v_t_r;
   float var_v_crossfb;
   float var_v_last_l;
   float var_v_last_r;
   float var_prepare__v_balance;
   float var___ti_rev_1_1;
   float var_v_fb1;
   float var___ti_rev_1_dly_2;
   float var___ti_rev_1_dly_3;
   float var___ti_rev_1_dly_4;
   float var___ti_rev_1_dly_5;
   float var___ti_rev_1_6;
   float var_v_fb6;
   float var___ti_rev_1_dly_7;
   float var___ti_rev_1_dly_8;
   float var___ti_rev_1_dly_9;
   float var___ti_rev_1_dly_10;
   float sr_factor;

} rev_1_stereo_voice_t;

#define loop(X)  for(unsigned int i = 0u; i < (X); i++)
#define clamp(a,b,c) (((a)<(b))?(b):(((a)>(c))?(c):(a)))

static inline float mathLerpf(float _a, float _b, float _t) { return _a + (_b - _a) * _t; }
static inline float mathClampf(float a, float b, float c) { return (((a)<(b))?(b):(((a)>(c))?(c):(a))); }
static inline float mathMinf(float a, float b) { return (a<b)?a:b; }
static inline float mathMaxf(float a, float b) { return (a>b)?a:b; }
static inline float mathAbsMaxf(float _x, float _y) { return ( ( (_x<0.0f)?-_x:_x)>((_y<0.0f)?-_y:_y)?_x:_y ); }
static inline float mathAbsMinf(float _x, float _y) { return ( ((_x<0.0f)?-_x:_x)<((_y<0.0f)?-_y:_y)?_x:_y ); }
static inline float frac(float _x) { return _x - ((int)_x); }

static inline float winLinear(const float *_s, float _index) {
   int idx = (int)_index;
   float r = _index - (float)idx;
   return mathLerpf(_s[idx], _s[idx+1], r);
}

static float ffrac_s(float _f) { int i; if(_f >= 0.0f) { i = (int)_f; return _f - (float)i; } else { i = (int)-_f; return 1.0f - (-_f - (float)i); } }

static float mathLogf(const float _x) {
   union {
      float f;
      unsigned int u;
   } bx;
   bx.f = _x;
   const unsigned int ex = bx.u >> 23;
   const signed int t = (signed int)ex - (signed int)127;
   const unsigned int s = (t < 0) ? (-t) : t;
   bx.u = 1065353216u | (bx.u & 8388607u);
   return
      -1.7417939f + (2.8212026f + (-1.4699568f + (0.44717955f - 0.056570851f * bx.f)*bx.f)*bx.f)*bx.f
      + 0.6931471806f * t;
}

static float mathPowerf(float _x, float _y) {
   float r;
   if(_y != 0.0f)
   {
      if(_x < 0.0f)
      {
         r = (float)( -expf(_y*mathLogf(-_x)) );
      }
      else if(_x > 0.0f)
      {
         r = (float)( expf(_y*mathLogf(_x)) );
      }
      else
      {
         r = 0.0f;
      }
   }
   else
   {
      r = 1.0f;
   }
   return Dstplugin_fix_denorm_32(r);
}

static void loc_prepare(st_plugin_voice_t *_voice);

void loc_prepare(st_plugin_voice_t *_voice) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   ST_PLUGIN_VOICE_SHARED_CAST(rev_1_stereo_shared_t);

   int tmp12_dly_write_idx;
   int tmp22_dly_write_idx;
   int tmp29_dly_write_idx;
   int tmp36_dly_write_idx;
   int tmp45_dly_write_idx;
   int tmp52_dly_write_idx;
   int tmp59_dly_write_idx;
   int tmp66_dly_write_idx;
   float out = 0.0f;
   (void)out;
   // -------- lane "prepare" modIdx=0 modString=$m_lpf
   
   // -- mod="$m_lpf" dstVar=out
   out = voice->mod_lpf_cur;
   
   // -- mod="p2s" dstVar=out
   out  = (mathPowerf(2.0f, out * 7.0f) - 1.0f);
   out *= 0.00787402f;
   
   // -- mod="sto v_lpf" dstVar=out
   voice->var_v_lpf = out;
   
   // -- mod="$m_balance" dstVar=out
   out = voice->mod_balance_cur;
   
   // -- mod="fma" dstVar=out
   out = (out * 2.0f) + -1.0f;
   
   // -- mod="0.125" dstVar=out
   out *= 0.125f;
   
   // -- mod="set prepare__v_balance" dstVar=out
   voice->var_prepare__v_balance = out;
   
   // -- mod="$m_t" dstVar=out
   out = voice->mod_t_cur;
   
   // -- mod="1" dstVar=out
   voice->tmp1/*seq*/ = out;
   voice->tmp1/*seq*/ = 1.0f;
   
   // -- mod="$prepare__v_balance" dstVar=voice->tmp1/*seq*/
   voice->tmp2/*seq*/ = voice->tmp1/*seq*/;
   voice->tmp2/*seq*/ = voice->var_prepare__v_balance;
   voice->tmp1/*seq*/ -= voice->tmp2/*seq*/;
   out *= voice->tmp1/*seq*/;
   
   // -- mod="clp" dstVar=out
   if(out > 1.0f) out = 1.0f;
   else if(out < 0.0f) out = 0.0f;
   
   // -- mod="sto v_t_l" dstVar=out
   voice->var_v_t_l = out;
   
   // -- mod="$m_t" dstVar=out
   out = voice->mod_t_cur;
   
   // -- mod="1" dstVar=out
   voice->tmp1/*seq*/ = out;
   voice->tmp1/*seq*/ = 1.0f;
   
   // -- mod="$prepare__v_balance" dstVar=voice->tmp1/*seq*/
   voice->tmp2/*seq*/ = voice->tmp1/*seq*/;
   voice->tmp2/*seq*/ = voice->var_prepare__v_balance;
   voice->tmp1/*seq*/ += voice->tmp2/*seq*/;
   out *= voice->tmp1/*seq*/;
   
   // -- mod="clp" dstVar=out
   if(out > 1.0f) out = 1.0f;
   else if(out < 0.0f) out = 0.0f;
   
   // -- mod="sto v_t_r" dstVar=out
   voice->var_v_t_r = out;
   
   // -- mod="$m_crossfb" dstVar=out
   out = voice->mod_crossfb_cur;
   
   // -- mod="clp" dstVar=out
   if(out > 0.999f) out = 0.999f;
   else if(out < -0.999f) out = -0.999f;
   
   // -- mod="0.125" dstVar=out
   out *= 0.125f;
   
   // -- mod="sto v_crossfb" dstVar=out
   voice->var_v_crossfb = out;
} /* end prepare */


#ifndef CYCLE_SKIP_UI
static unsigned int loc_copy_chars(char *_d, const unsigned int _dSize, const char *_s) {
   unsigned int r = 0u;
   if(NULL != _d)
   {
      // Write min(dSize,len(s)) characters to 'd'
      char *d = _d;
      if(NULL != _s)
      {
         const char *s = _s;
         for(;;)
         {
            if(r < _dSize)
            {
               char c = s[r++];
               *d++ = c;
               if(0 == c)
                  break;
            }
            else
            {
               if(r > 0u)
                  d[-1] = 0;  // force ASCIIZ
               break;
            }
         }
      }
      else
      {
         if(_dSize > 0u)
         {
            _d[0] = 0;
            r = 1u;
         }
      }
   }
   else
   {
      // Return total length of source string
      if(NULL != _s)
      {
         const char *s = _s;
         for(;;)
         {
            char c = s[r++];
            if(0 == c)
               break;
         }
      }
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int loc_copy_floats(float              *_d,
                                    const unsigned int  _dSize,
                                    const float        *_s,
                                    const unsigned int  _sNum
                                    ) {
   unsigned int r = 0u;
   if(NULL != _d)
   {
      // Write min(dSize,sNum) characters to 'd'
      if(NULL != _s)
      {
         unsigned int num = (_sNum > _dSize) ? _dSize : _sNum;
         memcpy((void*)_d, (const void*)_s, num * sizeof(float));
         r = num;
      }
   }
   else
   {
      // Query total number of presets
      r = _sNum;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static const char *ST_PLUGIN_API loc_get_param_name(st_plugin_info_t *_info,
                                                    unsigned int      _paramIdx
                                                    ) {
   (void)_info;
   return loc_param_names[_paramIdx];
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static const char *ST_PLUGIN_API loc_get_param_group_name(st_plugin_info_t *_info,
                                                          unsigned int      _paramGroupIdx
                                                          ) {
   (void)_info;
   const char *r = NULL;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_get_param_group_idx(st_plugin_info_t *_info,
                                                          unsigned int      _paramIdx
                                                          ) {
   (void)_info;
   unsigned int r = ~0u;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static const char *ST_PLUGIN_API loc_get_param_section_name(st_plugin_info_t *_info,
                                                            unsigned int      _paramSectionIdx
                                                            ) {
   (void)_info;
   const char *r = NULL;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_get_param_section_idx(st_plugin_info_t *_info,
                                                            unsigned int      _paramIdx
                                                            ) {
   (void)_info;
   unsigned int r = ~0u;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static float ST_PLUGIN_API loc_get_param_reset(st_plugin_info_t *_info,
                                               unsigned int      _paramIdx
                                               ) {
   (void)_info;
   return loc_param_resets[_paramIdx];
}
#endif // CYCLE_SKIP_UI

static float ST_PLUGIN_API loc_get_param_value(st_plugin_shared_t *_shared,
                                               unsigned int        _paramIdx
                                               ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   return shared->params[_paramIdx];
}

static void ST_PLUGIN_API loc_set_param_value(st_plugin_shared_t *_shared,
                                              unsigned int        _paramIdx,
                                              float               _value
                                              ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   shared->params[_paramIdx] = _value;
}

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_query_dynamic_param_preset_values(st_plugin_shared_t *_shared,
                                                                        const unsigned int  _paramIdx,
                                                                        float              *_retValues,
                                                                        const unsigned int  _retValuesSize
                                                                        ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   unsigned int r = 0u;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_query_dynamic_param_preset_name(st_plugin_shared_t *_shared,
                                                                      const unsigned int  _paramIdx,
                                                                      const unsigned int  _presetIdx,
                                                                      char               *_retBuf,
                                                                      const unsigned int  _retBufSize
                                                                      ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   unsigned int r = 0u;
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_get_array_param_size(st_plugin_info_t   *_info,
                                                           const unsigned int  _paramIdx
                                                           ) {
   unsigned int r = 0u;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static unsigned int ST_PLUGIN_API loc_get_array_param_num_variations(st_plugin_info_t   *_info,
                                                                     const unsigned int  _paramIdx
                                                                     ) {
   unsigned int r = 0u;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static float * ST_PLUGIN_API loc_get_array_param_variation_ptr(st_plugin_shared_t *_shared,
                                                               const unsigned int  _paramIdx,
                                                               const unsigned int  _variationIdx
                                                               ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   float *r = NULL;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static void ST_PLUGIN_API loc_set_array_param_edit_variation_idx(st_plugin_shared_t *_shared,
                                                                 const unsigned int  _paramIdx,
                                                                 const int           _variationIdx
                                                                 ) {
   ST_PLUGIN_SHARED_CAST(rev_1_stereo_shared_t);
   switch(_paramIdx)
   {
      default:
         break;
   }
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static const char *ST_PLUGIN_API loc_get_array_param_element_name(st_plugin_info_t   *_info,
                                                                  const unsigned int  _paramIdx,
                                                                  const unsigned int  _elementIdx
                                                                  ) {
   ST_PLUGIN_INFO_CAST(rev_1_stereo_info_t);
   const char *r = NULL;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static int ST_PLUGIN_API loc_get_array_param_element_value_range(st_plugin_info_t   *_info,
                                                                 const unsigned int  _paramIdx,
                                                                 const unsigned int  _elementIdx,
                                                                 float              *_retStorageMin,
                                                                 float              *_retStorageMax,
                                                                 float              *_retDisplayMin,
                                                                 float              *_retDisplayMax,
                                                                 unsigned int       *_retDisplayPrecision
                                                                 ) {
   (void)_elementIdx;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return 0;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static float ST_PLUGIN_API loc_get_array_param_element_reset(st_plugin_info_t   *_info,
                                                             const unsigned int  _paramIdx,
                                                             const unsigned int  _elementIdx
                                                             ) {
   ST_PLUGIN_INFO_CAST(rev_1_stereo_info_t);
   float r = -999999.0f/*INVALID_VALUE*/;
   switch(_paramIdx)
   {
      default:
         break;
   }
   return r;
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static void ST_PLUGIN_API loc_update_lut(st_plugin_info_t   *_info,
                                         unsigned int        _idx,
                                         const float        *_src,
                                         const unsigned int  _srcNumElements
                                         ) {
   (void)_info;
   unsigned int copySz = 0u;
   (void)copySz;
   switch(_idx)
   {
      default:
         break;
   }
}
#endif // CYCLE_SKIP_UI

#ifndef CYCLE_SKIP_UI
static const char *ST_PLUGIN_API loc_get_mod_name(st_plugin_info_t *_info,
                                                  unsigned int      _modIdx
                                                  ) {
   (void)_info;
   return loc_mod_names[_modIdx];
}
#endif // CYCLE_SKIP_UI

static void ST_PLUGIN_API loc_set_sample_rate(st_plugin_voice_t *_voice,
                                              float              _sampleRate
                                              ) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   if(_sampleRate != voice->sample_rate)
   {
      voice->sr_factor = 48000.0f / _sampleRate;
   }
   voice->sample_rate = _sampleRate;
}

static void ST_PLUGIN_API loc_set_bpm(st_plugin_voice_t *_voice,
                                      float              _bpm
                                      ) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   voice->bpm = _bpm;
}

static void ST_PLUGIN_API loc_note_on(st_plugin_voice_t  *_voice,
                                      int                 _bGlide,
                                      unsigned char       _note,
                                      float               _vel
                                      ) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   ST_PLUGIN_VOICE_SHARED_CAST(rev_1_stereo_shared_t);
   (void)_bGlide;
   (void)_note;
   (void)_vel;
   if(!_bGlide)
   {
      memset((void*)voice->mods, 0, sizeof(voice->mods));
#ifdef OVERSAMPLE_FACTOR
      voice->note_speed_fixed = (261.63f/*C-5*/ / (voice->sample_rate * OVERSAMPLE_FACTOR));
#else
      voice->note_speed_fixed = (261.63f/*C-5*/ / voice->sample_rate);
#endif // OVERSAMPLE_FACTOR
      voice->velocity = _vel;
   int tmp12_dly_write_idx;
   int tmp22_dly_write_idx;
   int tmp29_dly_write_idx;
   int tmp36_dly_write_idx;
   int tmp45_dly_write_idx;
   int tmp52_dly_write_idx;
   int tmp59_dly_write_idx;
   int tmp66_dly_write_idx;
      voice->tmp4_hpf_z1 = 0.0f;
      voice->tmp5_hpf_z2 = 0.0f;
      voice->tmp8_lpf_1rc_v0 = 0.0f;
      voice->tmp9_lpf_1rc_v1 = 0.0f;
      voice->tmp11_hbx_last = 0.0f;
      voice->tmp12_dly_write_idx = 0;
      memset(&voice->arr0_dly, 0, sizeof(voice->arr0_dly));
      voice->tmp18_apf_state = 0.0f;
      voice->tmp19_lpf_1rc_v0 = 0.0f;
      voice->tmp20_lpf_1rc_v1 = 0.0f;
      voice->tmp21_hbx_last = 0.0f;
      voice->tmp22_dly_write_idx = 0;
      memset(&voice->arr1_dly, 0, sizeof(voice->arr1_dly));
      voice->tmp25_apf_state = 0.0f;
      voice->tmp26_lpf_1rc_v0 = 0.0f;
      voice->tmp27_lpf_1rc_v1 = 0.0f;
      voice->tmp28_hbx_last = 0.0f;
      voice->tmp29_dly_write_idx = 0;
      memset(&voice->arr2_dly, 0, sizeof(voice->arr2_dly));
      voice->tmp32_apf_state = 0.0f;
      voice->tmp33_lpf_1rc_v0 = 0.0f;
      voice->tmp34_lpf_1rc_v1 = 0.0f;
      voice->tmp35_hbx_last = 0.0f;
      voice->tmp36_dly_write_idx = 0;
      memset(&voice->arr3_dly, 0, sizeof(voice->arr3_dly));
      voice->tmp39_apf_state = 0.0f;
      voice->tmp40_hpf_z1 = 0.0f;
      voice->tmp41_hpf_z2 = 0.0f;
      voice->tmp42_lpf_1rc_v0 = 0.0f;
      voice->tmp43_lpf_1rc_v1 = 0.0f;
      voice->tmp44_hbx_last = 0.0f;
      voice->tmp45_dly_write_idx = 0;
      memset(&voice->arr4_dly, 0, sizeof(voice->arr4_dly));
      voice->tmp48_apf_state = 0.0f;
      voice->tmp49_lpf_1rc_v0 = 0.0f;
      voice->tmp50_lpf_1rc_v1 = 0.0f;
      voice->tmp51_hbx_last = 0.0f;
      voice->tmp52_dly_write_idx = 0;
      memset(&voice->arr5_dly, 0, sizeof(voice->arr5_dly));
      voice->tmp55_apf_state = 0.0f;
      voice->tmp56_lpf_1rc_v0 = 0.0f;
      voice->tmp57_lpf_1rc_v1 = 0.0f;
      voice->tmp58_hbx_last = 0.0f;
      voice->tmp59_dly_write_idx = 0;
      memset(&voice->arr6_dly, 0, sizeof(voice->arr6_dly));
      voice->tmp62_apf_state = 0.0f;
      voice->tmp63_lpf_1rc_v0 = 0.0f;
      voice->tmp64_lpf_1rc_v1 = 0.0f;
      voice->tmp65_hbx_last = 0.0f;
      voice->tmp66_dly_write_idx = 0;
      memset(&voice->arr7_dly, 0, sizeof(voice->arr7_dly));
      voice->tmp69_apf_state = 0.0f;
      voice->var_x = 0.0f;
      voice->var_v_lpf = 0.0f;
      voice->var_v_t_l = 0.0f;
      voice->var_v_t_r = 0.0f;
      voice->var_v_crossfb = 0.0f;
      voice->var_v_last_l = 0.0f;
      voice->var_v_last_r = 0.0f;
      voice->var_prepare__v_balance = 0.0f;
      voice->var___ti_rev_1_1 = 0.0f;
      voice->var_v_fb1 = 0.0f;
      voice->var___ti_rev_1_dly_2 = 0.0f;
      voice->var___ti_rev_1_dly_3 = 0.0f;
      voice->var___ti_rev_1_dly_4 = 0.0f;
      voice->var___ti_rev_1_dly_5 = 0.0f;
      voice->var___ti_rev_1_6 = 0.0f;
      voice->var_v_fb6 = 0.0f;
      voice->var___ti_rev_1_dly_7 = 0.0f;
      voice->var___ti_rev_1_dly_8 = 0.0f;
      voice->var___ti_rev_1_dly_9 = 0.0f;
      voice->var___ti_rev_1_dly_10 = 0.0f;
   }
}

static void ST_PLUGIN_API loc_set_mod_value(st_plugin_voice_t *_voice,
                                            unsigned int       _modIdx,
                                            float              _value,
                                            unsigned           _frameOffset
                                            ) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   (void)_frameOffset;
   voice->mods[_modIdx] = _value;
}

static void ST_PLUGIN_API loc_prepare_block(st_plugin_voice_t *_voice,
                                            unsigned int       _numFrames,
                                            float              _freqHz,
                                            float              _note,
                                            float              _vol,
                                            float              _pan
                                            ) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   ST_PLUGIN_VOICE_SHARED_CAST(rev_1_stereo_shared_t);
   (void)_note;
   (void)_vol;
   (void)_pan;

#ifdef OVERSAMPLE_FACTOR
   float noteSpeed = _freqHz / (voice->sample_rate * OVERSAMPLE_FACTOR);
#else
   float noteSpeed = _freqHz / voice->sample_rate;
#endif // OVERSAMPLE_FACTOR

   float modt            = shared->params[PARAM_T           ]                       + voice->mods[MOD_T            ];
   float modlpf          = shared->params[PARAM_LPF         ]                       + voice->mods[MOD_LPF          ];
   float modhpf          = shared->params[PARAM_HPF         ]                       + voice->mods[MOD_HPF          ];
   float modmix          = shared->params[PARAM_MIX         ]                       + voice->mods[MOD_MIX          ];
   float modbalance      = shared->params[PARAM_BALANCE     ]                       + voice->mods[MOD_BALANCE      ];
   float modcrossfb      = shared->params[PARAM_CROSSFB     ]                       + voice->mods[MOD_CROSSFB      ];

   if(_numFrames > 0u)
   {
      // lerp
#ifdef OVERSAMPLE_FACTOR
      float recBlockSize = (1.0f / (_numFrames * OVERSAMPLE_FACTOR));
#else
      float recBlockSize = (1.0f / _numFrames);
#endif // OVERSAMPLE_FACTOR
      voice->note_speed_inc = (noteSpeed - voice->note_speed_cur) * recBlockSize;
      voice->note_inc       = (_note - voice->note_cur) * recBlockSize;
      voice->mod_t_inc            = (modt               - voice->mod_t_cur             ) * recBlockSize;
      voice->mod_lpf_inc          = (modlpf             - voice->mod_lpf_cur           ) * recBlockSize;
      voice->mod_hpf_inc          = (modhpf             - voice->mod_hpf_cur           ) * recBlockSize;
      voice->mod_mix_inc          = (modmix             - voice->mod_mix_cur           ) * recBlockSize;
      voice->mod_balance_inc      = (modbalance         - voice->mod_balance_cur       ) * recBlockSize;
      voice->mod_crossfb_inc      = (modcrossfb         - voice->mod_crossfb_cur       ) * recBlockSize;
      loc_prepare(&voice->base);
   }
   else
   {
      // initial params/modulation (first block, not rendered)
      voice->note_speed_cur = noteSpeed;
      voice->note_speed_inc = 0.0f;
      voice->note_cur       = _note;
      voice->note_inc       = 0.0f;
      voice->mod_t_cur            = modt;
      voice->mod_t_inc            = 0.0f;
      voice->mod_lpf_cur          = modlpf;
      voice->mod_lpf_inc          = 0.0f;
      voice->mod_hpf_cur          = modhpf;
      voice->mod_hpf_inc          = 0.0f;
      voice->mod_mix_cur          = modmix;
      voice->mod_mix_inc          = 0.0f;
      voice->mod_balance_cur      = modbalance;
      voice->mod_balance_inc      = 0.0f;
      voice->mod_crossfb_cur      = modcrossfb;
      voice->mod_crossfb_inc      = 0.0f;
      loc_prepare(&voice->base);
   }

   // printf("xxx note_cur=%f\n", voice->note_cur);
   // printf("xxx prepare_block: numFrames=%u moda=%f\n", _numFrames, moda);
   // printf("xxx voice->voicebus_idx_0=%u voice->base.voice_bus_read_offset=%u\n", voice->voicebus_idx_0, voice->base.voice_bus_read_offset);
}

static void ST_PLUGIN_API loc_process_replace(st_plugin_voice_t  *_voice,
                                              int                 _bMonoIn,
                                              const float        *_samplesIn,
                                              float              *_samplesOut,
                                              unsigned int        _numFrames
                                              ) {
   (void)_bMonoIn;
   (void)_samplesIn;

   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);
   ST_PLUGIN_VOICE_SHARED_CAST(rev_1_stereo_shared_t);

   // Mono output (replicate left to right channel)
   unsigned int j = 0u;
#ifndef STEREO
   unsigned int jStep = _bMonoIn ? 1u : 2u;
#endif // STEREO
   unsigned int k = 0u;
   for(unsigned int i = 0u; i < _numFrames; i++)
   {
      const float inL = _samplesIn[j];
#ifdef STEREO
      float outL;
      float outR;
      const float inR = _samplesIn[j + 1u];
#endif // STEREO
      float out;
#ifdef OVERSAMPLE_FACTOR
#ifdef STEREO
      float outOSL = 0.0f;
      float outOSR = 0.0f;
#else
      float outOS = 0.0f;
#endif // STEREO
#endif // OVERSAMPLE_FACTOR

#ifdef OVERSAMPLE_FACTOR
      for(unsigned int osi = 0u; osi < OVERSAMPLE_FACTOR; osi++)
#endif // OVERSAMPLE_FACTOR
      {
#ifdef STEREO
         out = outL = inL;
         outR = inR;
#else
         out = inL;
#endif // STEREO
      float tmp_f; (void)tmp_f;
      float tmp2_f; (void)tmp2_f;
      
      // ========
      // ======== lane "out" modIdx=0 modString=rdl
      // ========
      
      // -- mod="rdl" dstVar=out
      out = inL;
      
      // -- mod="$v_last_r" dstVar=out
      voice->tmp3/*seq*/ = out;
      voice->tmp3/*seq*/ = voice->var_v_last_r;
      
      // -- mod="hpf" dstVar=voice->tmp3/*seq*/
      tmp_f = voice->tmp3/*seq*/;
      voice->tmp3/*seq*/ = tmp_f * 0.198638 + voice->tmp4_hpf_z1;
      voice->tmp4_hpf_z1 = tmp_f * -0.397276 + voice->tmp5_hpf_z2 - 0.217248 * voice->tmp3/*seq*/;
      voice->tmp5_hpf_z2 = tmp_f * -0.397276 - 0.011799 * voice->tmp3/*seq*/;
      
      // -- mod="$v_crossfb" dstVar=voice->tmp3/*seq*/
      voice->tmp6/*seq*/ = voice->tmp3/*seq*/;
      voice->tmp6/*seq*/ = voice->var_v_crossfb;
      voice->tmp3/*seq*/ *= voice->tmp6/*seq*/;
      out += voice->tmp3/*seq*/;
      
      // -- mod="set __ti_rev_1_1" dstVar=out
      voice->tmp3/*delta*/ = out;
      
      // ---- mod="set __ti_rev_1_1" input "value" seq 1/1
      
      // -- mod="0.7" dstVar=voice->tmp3/*delta*/
      voice->tmp6/*seq*/ = voice->tmp3/*delta*/;
      voice->tmp6/*seq*/ = 0.7f;
      
      // -- mod="$v_t_l" dstVar=voice->tmp6/*seq*/
      voice->tmp7/*seq*/ = voice->tmp6/*seq*/;
      voice->tmp7/*seq*/ = voice->var_v_t_l;
      
      // -- mod="0.29" dstVar=voice->tmp7/*seq*/
      voice->tmp7/*seq*/ *= 0.29f;
      voice->tmp6/*seq*/ += voice->tmp7/*seq*/;
      
      // -- mod="sto v_fb1" dstVar=voice->tmp6/*seq*/
      voice->var_v_fb1 = voice->tmp6/*seq*/;
      // (ignore last output via '.')
      
      // -- mod="ipl" dstVar=voice->tmp3/*delta*/
      voice->tmp6/*b*/ = voice->tmp3/*delta*/;
      
      // ---- mod="ipl" input "b" seq 1/1
      
      // -- mod="pre" dstVar=voice->tmp6/*b*/
      
      // -- mod="set __ti_rev_1_dly_2" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_2" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp8_lpf_1rc_v0 = tmp_f * voice->tmp8_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp9_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp9_lpf_1rc_v1 = tmp_f * voice->tmp9_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp8_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp9_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp11_hbx_last = mathLerpf(voice->tmp11_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp11_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.348047" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.348047f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp12_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr0_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp15/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp15/*dly_read_idx_n*/ >= 4096)
        voice->tmp15/*dly_read_idx_n*/ -= 4096;
      voice->tmp16/*dly_n*/ = voice->arr0_dly[voice->tmp15/*dly_read_idx_n*/];
      voice->tmp17/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp16/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp16/*dly_n*/) * voice->tmp17/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp18_apf_state + -0.67139f * voice->tmp13/*dly_cur*/;
      voice->tmp18_apf_state = voice->tmp13/*dly_cur*/ - -0.67139f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb1" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb1;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr0_dly[voice->tmp12_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp12_dly_write_idx >= 4096)
         voice->tmp12_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_2 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_2" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_2;
      
      // -- mod="0.05099" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.05099f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_3" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_3" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp19_lpf_1rc_v0 = tmp_f * voice->tmp19_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp20_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp20_lpf_1rc_v1 = tmp_f * voice->tmp20_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp19_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp20_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp21_hbx_last = mathLerpf(voice->tmp21_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp21_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.371484" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.371484f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp22_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr1_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp23/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp23/*dly_read_idx_n*/ >= 4096)
        voice->tmp23/*dly_read_idx_n*/ -= 4096;
      voice->tmp17/*dly_n*/ = voice->arr1_dly[voice->tmp23/*dly_read_idx_n*/];
      voice->tmp24/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp17/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp17/*dly_n*/) * voice->tmp24/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp25_apf_state + -0.85269f * voice->tmp13/*dly_cur*/;
      voice->tmp25_apf_state = voice->tmp13/*dly_cur*/ - -0.85269f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb1" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb1;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr1_dly[voice->tmp22_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp22_dly_write_idx >= 4096)
         voice->tmp22_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_3 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_3" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_3;
      
      // -- mod="0.08499" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.08499f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_4" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_4" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp26_lpf_1rc_v0 = tmp_f * voice->tmp26_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp27_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp27_lpf_1rc_v1 = tmp_f * voice->tmp27_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp26_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp27_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp28_hbx_last = mathLerpf(voice->tmp28_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp28_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.481641" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.481641f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp29_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr2_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp30/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp30/*dly_read_idx_n*/ >= 4096)
        voice->tmp30/*dly_read_idx_n*/ -= 4096;
      voice->tmp24/*dly_n*/ = voice->arr2_dly[voice->tmp30/*dly_read_idx_n*/];
      voice->tmp31/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp24/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp24/*dly_n*/) * voice->tmp31/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp32_apf_state + -0.42776f * voice->tmp13/*dly_cur*/;
      voice->tmp32_apf_state = voice->tmp13/*dly_cur*/ - -0.42776f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb1" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb1;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr2_dly[voice->tmp29_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp29_dly_write_idx >= 4096)
         voice->tmp29_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_4 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_4" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_4;
      
      // -- mod="0.14731" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.14731f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_5" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_5" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp33_lpf_1rc_v0 = tmp_f * voice->tmp33_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp34_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp34_lpf_1rc_v1 = tmp_f * voice->tmp34_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp33_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp34_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp35_hbx_last = mathLerpf(voice->tmp35_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp35_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.512109" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.512109f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp36_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr3_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp37/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp37/*dly_read_idx_n*/ >= 4096)
        voice->tmp37/*dly_read_idx_n*/ -= 4096;
      voice->tmp31/*dly_n*/ = voice->arr3_dly[voice->tmp37/*dly_read_idx_n*/];
      voice->tmp38/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp31/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp31/*dly_n*/) * voice->tmp38/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp39_apf_state + -0.72805f * voice->tmp13/*dly_cur*/;
      voice->tmp39_apf_state = voice->tmp13/*dly_cur*/ - -0.72805f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb1" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb1;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr3_dly[voice->tmp36_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp36_dly_write_idx >= 4096)
         voice->tmp36_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_5 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_5" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_5;
      
      // -- mod="0.12748" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.12748f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      voice->tmp7/*t*/ = voice->tmp3/*delta*/;
      
      // ---- mod="ipl" input "t" seq 1/1
      
      // -- mod="$m_mix" dstVar=voice->tmp7/*t*/
      voice->tmp7/*t*/ = voice->mod_mix_cur;
      voice->tmp3/*delta*/ = voice->tmp3/*delta*/ + (voice->tmp6/*b*/ - voice->tmp3/*delta*/) * voice->tmp7/*t*/;
      voice->var___ti_rev_1_1 = voice->tmp3/*delta*/;
      
      // -- mod="$__ti_rev_1_1" dstVar=out
      out = voice->var___ti_rev_1_1;
      
      // -- mod="clp" dstVar=out
      if(out > 0.999f) out = 0.999f;
      else if(out < -0.999f) out = -0.999f;
      
      // -- mod="sto v_last_l" dstVar=out
      voice->var_v_last_l = out;
      
      // -- mod="wrl" dstVar=out
      outL = out;
      
      // -- mod="rdr" dstVar=out
      out = inR;
      
      // -- mod="$v_last_l" dstVar=out
      voice->tmp3/*seq*/ = out;
      voice->tmp3/*seq*/ = voice->var_v_last_l;
      
      // -- mod="hpf" dstVar=voice->tmp3/*seq*/
      tmp_f = voice->tmp3/*seq*/;
      voice->tmp3/*seq*/ = tmp_f * 0.198638 + voice->tmp40_hpf_z1;
      voice->tmp40_hpf_z1 = tmp_f * -0.397276 + voice->tmp41_hpf_z2 - 0.217248 * voice->tmp3/*seq*/;
      voice->tmp41_hpf_z2 = tmp_f * -0.397276 - 0.011799 * voice->tmp3/*seq*/;
      
      // -- mod="$v_crossfb" dstVar=voice->tmp3/*seq*/
      voice->tmp6/*seq*/ = voice->tmp3/*seq*/;
      voice->tmp6/*seq*/ = voice->var_v_crossfb;
      voice->tmp3/*seq*/ *= voice->tmp6/*seq*/;
      out += voice->tmp3/*seq*/;
      
      // -- mod="set __ti_rev_1_6" dstVar=out
      voice->tmp3/*delta*/ = out;
      
      // ---- mod="set __ti_rev_1_6" input "value" seq 1/1
      
      // -- mod="0.7" dstVar=voice->tmp3/*delta*/
      voice->tmp6/*seq*/ = voice->tmp3/*delta*/;
      voice->tmp6/*seq*/ = 0.7f;
      
      // -- mod="$v_t_r" dstVar=voice->tmp6/*seq*/
      voice->tmp7/*seq*/ = voice->tmp6/*seq*/;
      voice->tmp7/*seq*/ = voice->var_v_t_r;
      
      // -- mod="0.29" dstVar=voice->tmp7/*seq*/
      voice->tmp7/*seq*/ *= 0.29f;
      voice->tmp6/*seq*/ += voice->tmp7/*seq*/;
      
      // -- mod="sto v_fb6" dstVar=voice->tmp6/*seq*/
      voice->var_v_fb6 = voice->tmp6/*seq*/;
      // (ignore last output via '.')
      
      // -- mod="ipl" dstVar=voice->tmp3/*delta*/
      voice->tmp6/*b*/ = voice->tmp3/*delta*/;
      
      // ---- mod="ipl" input "b" seq 1/1
      
      // -- mod="pre" dstVar=voice->tmp6/*b*/
      
      // -- mod="set __ti_rev_1_dly_7" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_7" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp42_lpf_1rc_v0 = tmp_f * voice->tmp42_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp43_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp43_lpf_1rc_v1 = tmp_f * voice->tmp43_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp42_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp43_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp44_hbx_last = mathLerpf(voice->tmp44_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp44_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.348047" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.348047f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp45_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr4_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp46/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp46/*dly_read_idx_n*/ >= 4096)
        voice->tmp46/*dly_read_idx_n*/ -= 4096;
      voice->tmp38/*dly_n*/ = voice->arr4_dly[voice->tmp46/*dly_read_idx_n*/];
      voice->tmp47/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp38/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp38/*dly_n*/) * voice->tmp47/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp48_apf_state + -0.67139f * voice->tmp13/*dly_cur*/;
      voice->tmp48_apf_state = voice->tmp13/*dly_cur*/ - -0.67139f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb6" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb6;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr4_dly[voice->tmp45_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp45_dly_write_idx >= 4096)
         voice->tmp45_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_7 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_7" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_7;
      
      // -- mod="0.05099" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.05099f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_8" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_8" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp49_lpf_1rc_v0 = tmp_f * voice->tmp49_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp50_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp50_lpf_1rc_v1 = tmp_f * voice->tmp50_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp49_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp50_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp51_hbx_last = mathLerpf(voice->tmp51_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp51_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.371484" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.371484f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp52_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr5_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp53/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp53/*dly_read_idx_n*/ >= 4096)
        voice->tmp53/*dly_read_idx_n*/ -= 4096;
      voice->tmp47/*dly_n*/ = voice->arr5_dly[voice->tmp53/*dly_read_idx_n*/];
      voice->tmp54/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp47/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp47/*dly_n*/) * voice->tmp54/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp55_apf_state + -0.85269f * voice->tmp13/*dly_cur*/;
      voice->tmp55_apf_state = voice->tmp13/*dly_cur*/ - -0.85269f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb6" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb6;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr5_dly[voice->tmp52_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp52_dly_write_idx >= 4096)
         voice->tmp52_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_8 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_8" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_8;
      
      // -- mod="0.08499" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.08499f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_9" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_9" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp56_lpf_1rc_v0 = tmp_f * voice->tmp56_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp57_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp57_lpf_1rc_v1 = tmp_f * voice->tmp57_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp56_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp57_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp58_hbx_last = mathLerpf(voice->tmp58_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp58_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.481641" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.481641f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp59_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr6_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp60/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp60/*dly_read_idx_n*/ >= 4096)
        voice->tmp60/*dly_read_idx_n*/ -= 4096;
      voice->tmp54/*dly_n*/ = voice->arr6_dly[voice->tmp60/*dly_read_idx_n*/];
      voice->tmp61/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp54/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp54/*dly_n*/) * voice->tmp61/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp62_apf_state + -0.42776f * voice->tmp13/*dly_cur*/;
      voice->tmp62_apf_state = voice->tmp13/*dly_cur*/ - -0.42776f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb6" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb6;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr6_dly[voice->tmp59_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp59_dly_write_idx >= 4096)
         voice->tmp59_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_9 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_9" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_9;
      
      // -- mod="0.14731" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.14731f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      
      // -- mod="set __ti_rev_1_dly_10" dstVar=voice->tmp6/*b*/
      voice->tmp7/*delta*/ = voice->tmp6/*b*/;
      
      // ---- mod="set __ti_rev_1_dly_10" input "value" seq 1/1
      
      // -- mod="lpf" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="lpf" input "freq" seq 1/1
      
      // -- mod="$v_lpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->var_v_lpf;
      tmp_f = (1.0f - voice->tmp10/*freq*/ * 0.5);
      voice->tmp63_lpf_1rc_v0 = tmp_f * voice->tmp63_lpf_1rc_v0 - voice->tmp10/*freq*/ * voice->tmp64_lpf_1rc_v1 + voice->tmp7/*delta*/ * voice->tmp10/*freq*/;
      voice->tmp64_lpf_1rc_v1 = tmp_f * voice->tmp64_lpf_1rc_v1 + voice->tmp10/*freq*/ * voice->tmp63_lpf_1rc_v0;
      voice->tmp7/*delta*/ = voice->tmp64_lpf_1rc_v1;
      
      // -- mod="hbx" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="hbx" input "freq" seq 1/1
      
      // -- mod="$m_hpf" dstVar=voice->tmp10/*freq*/
      voice->tmp10/*freq*/ = voice->mod_hpf_cur;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp10/*freq*/ *= voice->tmp10/*freq*/;
      voice->tmp65_hbx_last = mathLerpf(voice->tmp65_hbx_last, voice->tmp7/*delta*/, voice->tmp10/*freq*/ * voice->sr_factor);
      voice->tmp7/*delta*/ = voice->tmp7/*delta*/ - voice->tmp65_hbx_last;
      
      // -- mod="dly" dstVar=voice->tmp7/*delta*/
      
      // ---- mod="dly" input "len" seq 1/1
      
      // -- mod="0.512109" dstVar=voice->tmp10/*dly_len*/
      voice->tmp10/*dly_len*/ = 0.512109f;
      voice->tmp10/*dly_len*/ *= 4096;
      voice->tmp10/*dly_len*/ = (voice->tmp10/*dly_len*/ < 1.0f) ? 1.0f : (voice->tmp10/*dly_len*/ > 4095) ? 4095 : voice->tmp10/*dly_len*/;
      voice->tmp14/*dly_read_idx*/ = voice->tmp66_dly_write_idx - (int)voice->tmp10/*dly_len*/;
      if(voice->tmp14/*dly_read_idx*/ < 0)
        voice->tmp14/*dly_read_idx*/ += 4096;
      voice->tmp13/*dly_cur*/ = voice->arr7_dly[voice->tmp14/*dly_read_idx*/];
      voice->tmp67/*dly_read_idx_n*/ = voice->tmp14/*dly_read_idx*/ + 1;
      if(voice->tmp67/*dly_read_idx_n*/ >= 4096)
        voice->tmp67/*dly_read_idx_n*/ -= 4096;
      voice->tmp61/*dly_n*/ = voice->arr7_dly[voice->tmp67/*dly_read_idx_n*/];
      voice->tmp68/*dly_read_frac*/ = voice->tmp10/*dly_len*/ - (int)voice->tmp10/*dly_len*/;
      voice->tmp13/*dly_cur*/ = voice->tmp61/*dly_n*/ + (voice->tmp13/*dly_cur*/ - voice->tmp61/*dly_n*/) * voice->tmp68/*dly_read_frac*/;
      
      // ---- mod="dly" input "read" seq 1/1
      
      // -- mod="apf" dstVar=voice->tmp13/*dly_cur*/
      voice->tmp10/*apf_tmp*/ = voice->tmp69_apf_state + -0.72805f * voice->tmp13/*dly_cur*/;
      voice->tmp69_apf_state = voice->tmp13/*dly_cur*/ - -0.72805f * voice->tmp10/*apf_tmp*/;
      voice->tmp13/*dly_cur*/ = voice->tmp10/*apf_tmp*/;
      
      // ---- mod="dly" input "feedback" seq 1/1
      
      // -- mod="$v_fb6" dstVar=voice->tmp10/*dly_fb_amt*/
      voice->tmp10/*dly_fb_amt*/ = voice->var_v_fb6;
      voice->tmp7/*delta*/ += voice->tmp13/*dly_cur*/ * voice->tmp10/*dly_fb_amt*/;
      voice->arr7_dly[voice->tmp66_dly_write_idx] = voice->tmp7/*delta*/;
      voice->tmp7/*delta*/ = voice->tmp13/*dly_cur*/;
      if(++voice->tmp66_dly_write_idx >= 4096)
         voice->tmp66_dly_write_idx = 0;
      voice->var___ti_rev_1_dly_10 = voice->tmp7/*delta*/;
      
      // -- mod="$__ti_rev_1_dly_10" dstVar=voice->tmp6/*b*/
      voice->tmp7/*seq*/ = voice->tmp6/*b*/;
      voice->tmp7/*seq*/ = voice->var___ti_rev_1_dly_10;
      
      // -- mod="0.12748" dstVar=voice->tmp7/*seq*/
      voice->tmp10/*seq*/ = voice->tmp7/*seq*/;
      voice->tmp10/*seq*/ = 0.12748f;
      
      // -- mod="8" dstVar=voice->tmp10/*seq*/
      voice->tmp10/*seq*/ *= 8.0f;
      voice->tmp7/*seq*/ *= voice->tmp10/*seq*/;
      voice->tmp6/*b*/ += voice->tmp7/*seq*/;
      voice->tmp7/*t*/ = voice->tmp3/*delta*/;
      
      // ---- mod="ipl" input "t" seq 1/1
      
      // -- mod="$m_mix" dstVar=voice->tmp7/*t*/
      voice->tmp7/*t*/ = voice->mod_mix_cur;
      voice->tmp3/*delta*/ = voice->tmp3/*delta*/ + (voice->tmp6/*b*/ - voice->tmp3/*delta*/) * voice->tmp7/*t*/;
      voice->var___ti_rev_1_6 = voice->tmp3/*delta*/;
      
      // -- mod="$__ti_rev_1_6" dstVar=out
      out = voice->var___ti_rev_1_6;
      
      // -- mod="clp" dstVar=out
      if(out > 0.999f) out = 0.999f;
      else if(out < -0.999f) out = -0.999f;
      
      // -- mod="sto v_last_r" dstVar=out
      voice->var_v_last_r = out;
      
      // -- mod="wrr" dstVar=out
      outR = out;

      /* end calc */

#ifdef OVERSAMPLE_FACTOR
#ifdef STEREO
         outOSL += outL;
         outOSR += outR;
#else
         outOS += out;
#endif // STEREO
#endif // OVERSAMPLE_FACTOR
         voice->note_speed_cur += voice->note_speed_inc;
         voice->note_cur       += voice->note_inc;
         voice->mod_t_cur          += voice->mod_t_inc;
         voice->mod_lpf_cur        += voice->mod_lpf_inc;
         voice->mod_hpf_cur        += voice->mod_hpf_inc;
         voice->mod_mix_cur        += voice->mod_mix_inc;
         voice->mod_balance_cur    += voice->mod_balance_inc;
         voice->mod_crossfb_cur    += voice->mod_crossfb_inc;
      }
#ifdef OVERSAMPLE_FACTOR
      // Apply lowpass filter before downsampling
      //   (note) normalized Fc = F/Fs = 0.442947 / sqrt(oversample_factor^2 - 1)
#ifdef STEREO
      outL = outOSL * (1.0f / OVERSAMPLE_FACTOR);
      outR = outOSR * (1.0f / OVERSAMPLE_FACTOR);
#else
      out = outOS * (1.0f / OVERSAMPLE_FACTOR);
#endif // STEREO
#endif // OVERSAMPLE_FACTOR
#ifdef STEREO
      outL = Dstplugin_fix_denorm_32(outL);
      outR = Dstplugin_fix_denorm_32(outR);
#else
      out = Dstplugin_fix_denorm_32(out);
#endif // STEREO
#ifdef STEREO
      _samplesOut[k]      = outL;
      _samplesOut[k + 1u] = outR;
#else
      _samplesOut[k]      = out;
      _samplesOut[k + 1u] = out;
#endif // STEREO

      // Next frame
      k += 2u;
#ifdef STEREO
      j += 2u;
#else
      j += jStep;
#endif // STEREO
   } /* loop numFrames */
}

static st_plugin_shared_t *ST_PLUGIN_API loc_shared_new(st_plugin_info_t *_info) {
   rev_1_stereo_shared_t *ret = (rev_1_stereo_shared_t *)malloc(sizeof(rev_1_stereo_shared_t));
   if(NULL != ret)
   {
      memset((void*)ret, 0, sizeof(*ret));
      ret->base.info  = _info;
      memcpy((void*)ret->params, (void*)loc_param_resets, NUM_PARAMS * sizeof(float));
   }
   return &ret->base;
}

static void ST_PLUGIN_API loc_shared_delete(st_plugin_shared_t *_shared) {
   free((void*)_shared);
}

static st_plugin_voice_t *ST_PLUGIN_API loc_voice_new(st_plugin_info_t *_info, unsigned int _voiceIdx) {
   rev_1_stereo_voice_t *voice = (rev_1_stereo_voice_t *)malloc(sizeof(rev_1_stereo_voice_t));
   if(NULL != voice)
   {
      memset((void*)voice, 0, sizeof(*voice));
      voice->base.info = _info;
      voice->tmp12_dly_write_idx = 0;
      voice->tmp22_dly_write_idx = 0;
      voice->tmp29_dly_write_idx = 0;
      voice->tmp36_dly_write_idx = 0;
      voice->tmp45_dly_write_idx = 0;
      voice->tmp52_dly_write_idx = 0;
      voice->tmp59_dly_write_idx = 0;
      voice->tmp66_dly_write_idx = 0;
   }
   return &voice->base;
}

static void ST_PLUGIN_API loc_voice_delete(st_plugin_voice_t *_voice) {
   ST_PLUGIN_VOICE_CAST(rev_1_stereo_voice_t);

   free((void*)_voice);
   }

static void ST_PLUGIN_API loc_plugin_exit(st_plugin_info_t *_info) {
   free((void*)_info);
}

#ifdef USE_CYCLE_SINE_TBL
static void loc_calc_sine_tbl(void) {
#define QCOS_BITS 16
#define QCOS_ONE  (1 << QCOS_BITS)
#define QCOS_MASK (QCOS_ONE - 1)
   // (note) same as in TSR "C" implementation
   float *qcos = cycle_sine_tbl_f + 4096; // quarter cos tbl

   // calc quarter cos tbl
   int k = 0;
   for(int a = 0; a < (QCOS_ONE/4); a += (QCOS_ONE/16384)/*4*/)  // 4096 elements
   {
      int x = a - ((int)(QCOS_ONE * 0.25 + 0.5)) + ((a + ((int)(QCOS_ONE * 0.25 + 0.5)))&~QCOS_MASK);
      x = ((x * ((x<0?-x:x) - ((int)(QCOS_ONE * 0.5 + 0.5)))) >> QCOS_BITS) << 4;
      x += (((((int)(QCOS_ONE * 0.225 + 0.5)) * x) >> QCOS_BITS) * ((x<0?-x:x) - QCOS_ONE)) >> QCOS_BITS;
      qcos[k++] = x / float(QCOS_ONE);
   }

   // 0..90deg (rev qtbl)
   int j = 4096;
   k = 0;
   loop(4096)
      cycle_sine_tbl_f[k++] = qcos[--j];

   // 90..180deg = cos tbl
   k += 4096;

   // 180..360deg (y-flip first half of tbl)
   j = 0;
   loop(8192)
      cycle_sine_tbl_f[k++] = -cycle_sine_tbl_f[j++];

#ifdef USE_CYCLE_SINE_TBL_I
   loop(16384)
      cycle_sine_tbl_i[i] = (short)(cycle_sine_tbl_f[i] * 2048.0f/*FX_ONE*/);
#endif // USE_CYCLE_SINE_TBL_I
}
#endif // USE_CYCLE_SINE_TBL

#ifdef USE_CYCLE_HSE_TBL
#endif // USE_CYCLE_HSE_TBL

extern "C" {
st_plugin_info_t *rev_1_stereo_init(void) {
   rev_1_stereo_info_t *ret = (rev_1_stereo_info_t *)malloc(sizeof(rev_1_stereo_info_t));

   if(NULL != ret)
   {
      memset(ret, 0, sizeof(*ret));

      ret->base.api_version = ST_PLUGIN_API_VERSION;
      ret->base.id          = "rev_1_stereo";  // unique id. don't change this in future builds.
      ret->base.author      = "bsp";
      ret->base.name        = "rev_1_stereo";
      ret->base.short_name  = "rev_1_stereo";
      ret->base.flags       = ST_PLUGIN_FLAG_OSC;
      ret->base.category    = ST_PLUGIN_CAT_UNKNOWN;
      ret->base.num_params  = NUM_PARAMS;
      ret->base.num_mods    = NUM_MODS;

      ret->base.shared_new                          = &loc_shared_new;
      ret->base.shared_delete                       = &loc_shared_delete;
      ret->base.voice_new                           = &loc_voice_new;
      ret->base.voice_delete                        = &loc_voice_delete;
#ifndef CYCLE_SKIP_UI
      ret->base.get_param_name                      = &loc_get_param_name;
      ret->base.get_param_group_name                = &loc_get_param_group_name;
      ret->base.get_param_group_idx                 = &loc_get_param_group_idx;
      ret->base.get_param_section_name              = &loc_get_param_section_name;
      ret->base.get_param_section_idx               = &loc_get_param_section_idx;
      ret->base.get_param_reset                     = &loc_get_param_reset;
      ret->base.query_dynamic_param_preset_values   = &loc_query_dynamic_param_preset_values;
      ret->base.query_dynamic_param_preset_name     = &loc_query_dynamic_param_preset_name;
      ret->base.get_array_param_size                = &loc_get_array_param_size;
      ret->base.get_array_param_num_variations      = &loc_get_array_param_num_variations;
      ret->base.get_array_param_variation_ptr       = &loc_get_array_param_variation_ptr;
      ret->base.set_array_param_edit_variation_idx  = &loc_set_array_param_edit_variation_idx;
      ret->base.get_array_param_element_name        = &loc_get_array_param_element_name;
      ret->base.get_array_param_element_value_range = &loc_get_array_param_element_value_range;
      ret->base.get_array_param_element_reset       = &loc_get_array_param_element_reset;
      ret->base.update_lut                          = &loc_update_lut;
#endif // CYCLE_SKIP_UI
      ret->base.get_param_value                     = &loc_get_param_value;
      ret->base.set_param_value                     = &loc_set_param_value;
#ifndef CYCLE_SKIP_UI
      ret->base.get_mod_name                        = &loc_get_mod_name;
#endif // CYCLE_SKIP_UI
      ret->base.set_sample_rate                     = &loc_set_sample_rate;
      ret->base.set_bpm                             = &loc_set_bpm;
      ret->base.note_on                             = &loc_note_on;
      ret->base.set_mod_value                       = &loc_set_mod_value;
      ret->base.prepare_block                       = &loc_prepare_block;
      ret->base.process_replace                     = &loc_process_replace;
      ret->base.plugin_exit                         = &loc_plugin_exit;

#ifdef USE_CYCLE_SINE_TBL
      loc_calc_sine_tbl();
#endif // USE_CYCLE_SINE_TBL
   }

   return &ret->base;
}

#ifndef STFX_SKIP_MAIN_INIT
ST_PLUGIN_APICALL st_plugin_info_t *ST_PLUGIN_API st_plugin_init(unsigned int _pluginIdx) {
   switch(_pluginIdx)
   {
      case 0u:
         return rev_1_stereo_init();
   }
   return NULL;
}
#endif // STFX_SKIP_MAIN_INIT

} // extern "C"
