DummyBackend: symmetric freq sweep: up/down
This commit is contained in:
parent
6dfb8c5c8a
commit
186493687b
@ -1414,22 +1414,33 @@ void DummyAudioPort::setup_generator (GeneratorType const g, float const sampler
|
|||||||
case SineSweepSwell:
|
case SineSweepSwell:
|
||||||
{
|
{
|
||||||
_gen_period = 5 * samplerate + randi() % (int)(samplerate * 10.f);
|
_gen_period = 5 * samplerate + randi() % (int)(samplerate * 10.f);
|
||||||
_wavetable = (Sample*) malloc (_gen_period * sizeof(Sample));
|
_gen_period &= ~1;
|
||||||
_gen_perio2 = 1 | (int)ceilf (_gen_period * .89f); // Volume Swell period
|
_gen_perio2 = 1 | (int)ceilf (_gen_period * .89f); // Volume Swell period
|
||||||
const double f_min = 20.;
|
const double f_min = 20.;
|
||||||
const double f_max = samplerate * .5;
|
const double f_max = samplerate * .5;
|
||||||
|
const double g_p2 = _gen_period * .5;
|
||||||
#ifdef LINEAR_SWEEP
|
#ifdef LINEAR_SWEEP
|
||||||
const double b = (f_max - f_min) / (2. * samplerate * _gen_period);
|
const double b = (f_max - f_min) / (2. * samplerate * g_p2);
|
||||||
const double a = f_min / samplerate;
|
const double a = f_min / samplerate;
|
||||||
#else
|
#else
|
||||||
const double b = log (f_max / f_min) / _gen_period;
|
const double b = log (f_max / f_min) / g_p2;
|
||||||
const double a = f_min / (b * samplerate);
|
const double a = f_min / (b * samplerate);
|
||||||
#endif
|
#endif
|
||||||
for (uint32_t i = 0 ; i < _gen_period; ++i) {
|
_wavetable = (Sample*) malloc (_gen_period * sizeof(Sample));
|
||||||
|
for (uint32_t i = 0 ; i < g_p2; ++i) {
|
||||||
#ifdef LINEAR_SWEEP
|
#ifdef LINEAR_SWEEP
|
||||||
const double phase = i * (a + b * i);
|
const double phase = i * (a + b * i);
|
||||||
#else
|
#else
|
||||||
const double phase = a * exp (b * i) - a;
|
const double phase = a * exp (b * i) - a;
|
||||||
|
#endif
|
||||||
|
_wavetable[i] = (float)sin (2. * M_PI * (phase - floor (phase)));
|
||||||
|
}
|
||||||
|
for (uint32_t i = g_p2; i < _gen_period; ++i) {
|
||||||
|
const uint32_t j = _gen_period - i;
|
||||||
|
#ifdef LINEAR_SWEEP
|
||||||
|
const double phase = j * (a + b * j);
|
||||||
|
#else
|
||||||
|
const double phase = a * exp (b * j) - a;
|
||||||
#endif
|
#endif
|
||||||
_wavetable[i] = (float)sin (2. * M_PI * (phase - floor (phase)));
|
_wavetable[i] = (float)sin (2. * M_PI * (phase - floor (phase)));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user