Browse Source

Zyn update complete

tags/1.9.4
falkTX 10 years ago
parent
commit
87cac32380
3 changed files with 45 additions and 14 deletions
  1. +42
    -11
      source/modules/native-plugins/zynaddsubfx/DSP/AnalogFilter.cpp
  2. +1
    -1
      source/modules/native-plugins/zynaddsubfx/DSP/SVFilter.cpp
  3. +2
    -2
      source/modules/native-plugins/zynaddsubfx/DSP/Unison.cpp

+ 42
- 11
source/modules/native-plugins/zynaddsubfx/DSP/AnalogFilter.cpp View File

@@ -24,6 +24,7 @@

#include <cstring> //memcpy
#include <cmath>
#include <cassert>

#include "../Misc/Util.h"
#include "AnalogFilter.h"
@@ -329,10 +330,33 @@ void AnalogFilter::setstages(int stages_)
computefiltercoefs();
}

inline void AnalogBiquadFilterA(const float coeff[5], float &src, float work[4])
{
work[3] = src*coeff[0]
+ work[0]*coeff[1]
+ work[1]*coeff[2]
+ work[2]*coeff[3]
+ work[3]*coeff[4];
work[1] = src;
src = work[3];
}

inline void AnalogBiquadFilterB(const float coeff[5], float &src, float work[4])
{
work[2] = src*coeff[0]
+ work[1]*coeff[1]
+ work[0]*coeff[2]
+ work[3]*coeff[3]
+ work[2]*coeff[4];
work[0] = src;
src = work[2];
}

void AnalogFilter::singlefilterout(float *smp, fstage &hist,
const Coeff &coeff)
{
if(order == 1) //First order filter
assert((buffersize % 8) == 0);
if(order == 1) { //First order filter
for(int i = 0; i < buffersize; ++i) {
float y0 = smp[i] * coeff.c[0] + hist.x1 * coeff.c[1]
+ hist.y1 * coeff.d[1];
@@ -340,17 +364,24 @@ void AnalogFilter::singlefilterout(float *smp, fstage &hist,
hist.x1 = smp[i];
smp[i] = y0;
}
if(order == 2) //Second order filter
for(int i = 0; i < buffersize; ++i) {
float y0 = smp[i] * coeff.c[0] + hist.x1 * coeff.c[1]
+ hist.x2 * coeff.c[2] + hist.y1 * coeff.d[1]
+ hist.y2 * coeff.d[2];
hist.y2 = hist.y1;
hist.y1 = y0;
hist.x2 = hist.x1;
hist.x1 = smp[i];
smp[i] = y0;
} else if(order == 2) {//Second order filter
const float coeff_[5] = {coeff.c[0], coeff.c[1], coeff.c[2], coeff.d[1], coeff.d[2]};
float work[4] = {hist.x1, hist.x2, hist.y1, hist.y2};
for(int i = 0; i < buffersize; i+=8) {
AnalogBiquadFilterA(coeff_, smp[i + 0], work);
AnalogBiquadFilterB(coeff_, smp[i + 1], work);
AnalogBiquadFilterA(coeff_, smp[i + 2], work);
AnalogBiquadFilterB(coeff_, smp[i + 3], work);
AnalogBiquadFilterA(coeff_, smp[i + 4], work);
AnalogBiquadFilterB(coeff_, smp[i + 5], work);
AnalogBiquadFilterA(coeff_, smp[i + 6], work);
AnalogBiquadFilterB(coeff_, smp[i + 7], work);
}
hist.x1 = work[0];
hist.x2 = work[1];
hist.y1 = work[2];
hist.y2 = work[3];
}
}

void AnalogFilter::filterout(float *smp)


+ 1
- 1
source/modules/native-plugins/zynaddsubfx/DSP/SVFilter.cpp View File

@@ -167,7 +167,7 @@ void SVFilter::filterout(float *smp)
singlefilterout(ismp, st[i], ipar);

for(int i = 0; i < buffersize; ++i) {
float x = (float)i / buffersize_f;
float x = i / buffersize_f;
smp[i] = ismp[i] * (1.0f - x) + smp[i] * x;
}
needsinterpolation = false;


+ 2
- 2
source/modules/native-plugins/zynaddsubfx/DSP/Unison.cpp View File

@@ -92,11 +92,11 @@ void Unison::updateParameters(void)
/ (float) update_period_samples;
// printf("#%g, %g\n",increments_per_second,base_freq);
for(int i = 0; i < unison_size; ++i) {
float base = powf(UNISON_FREQ_SPAN, SYNTH_T::numRandom() * 2.0f - 1.0f);
float base = powf(UNISON_FREQ_SPAN, numRandom() * 2.0f - 1.0f);
uv[i].relative_amplitude = base;
float period = base / base_freq;
float m = 4.0f / (period * increments_per_second);
if(SYNTH_T::numRandom() < 0.5f)
if(numRandom() < 0.5f)
m = -m;
uv[i].step = m;
// printf("%g %g\n",uv[i].relative_amplitude,period);


Loading…
Cancel
Save