phaser1

A phaser with 2 stages. Use size 256 samples for the table, it sounds best for a phaser. 6-7%
Author: Jaffasplaffa
License: BSD
Github: jaffa/fx/phaser1.axo

Inlets

frac32 lfo speed mod

frac32buffer in

frac32buffer delay time (fraction of total delayline size)

Outlets

frac32buffer wave

Parameters

bool32.tgl on

bool32.tgl lfoon

bool32.tgl feedinvert

frac32.u.map mix

frac32.u.map feedback

frac32.u.map freqa

frac32.u.map freqb

frac32.u.map timea

frac32.u.map timeb

frac32.u.map lfoam

frac32.s.map lfospeed

Attributes

combo s

Declaration
// From delay write sdram //
static const uint32_t LENGTHPOW1 = (attr_s);
static const uint32_t LENGTH1 = (1 << attr_s);
static const uint32_t LENGTHMASK1 = ((1 << attr_s) - 1);
int16_t *array1;
uint32_t writepos1;

int32_t vala;

int32_t FILTERa;
int32_t FILTERINVa;
int32_t CLEANPLUSINVERTEDFILTERa;
int32_t CLEANPLUSINVERTEDFILTERINVa;
int32_t STEP2a;

// From delay write sdram //
static const uint32_t LENGTHPOW = (attr_s);
static const uint32_t LENGTH = (1 << attr_s);
static const uint32_t LENGTHMASK = ((1 << attr_s) - 1);
int16_t *array;
uint32_t writepos;

int32_t val;

int32_t FILTER;
int32_t FILTERINV;
int32_t CLEANPLUSINVERTEDFILTER;
int32_t CLEANPLUSINVERTEDFILTERINV;
int32_t STEP2;

// Delay - THis one is different than the others //
// I put the allpase AFTER the delay //
int32_t ALLPASSS;
int32_t MIX;

// LFO //
uint32_t phase;
uint32_t old_reset;
__attribute__((always_inline)) __STATIC_INLINE int32_t ___ABS(int32_t op1) {
  int32_t result;
  __ASM volatile("movs  %0, %1\n"
                 "it    mi\n"
                 "rsbmi %0, %0, #0"
                 : "=r"(result)
                 : "r"(op1));
  return (result);
};
Init
// From delay write sdram //
static int16_t _array1[attr_poly][1 << attr_s]
    __attribute__((section(".sdram")));
array1 = &_array1[parent->polyIndex][0];
int i1;
writepos1 = 0;
for (i1 = 0; i1 < LENGTH1; i1++)
  array1[i1] = 0;

// 6db lo pass //
vala = 0;

// From delay write sdram //
static int16_t _array[attr_poly][1 << attr_s]
    __attribute__((section(".sdram")));
array = &_array[parent->polyIndex][0];
int i;
writepos = 0;
for (i = 0; i < LENGTH; i++)
  array[i] = 0;

// 6db lo pass //
val = 0;

phase = 0;
old_reset = 0;
Control Rate
if (0 && !old_reset) {
  phase = 0;
} else {
  int32_t freq;
  MTOFEXTENDED(param_lfospeed + inlet_lfo, freq);
  phase += freq >> 2;
}
old_reset = 0;

int32_t saw;

saw = (phase >> 4) - (1 << 27);
int32_t ZERO = (1 << 27) - ___ABS(saw << 1);

saw = ((phase - 0x40000000) >> 4) - (1 << 27);
int32_t NINETY = (1 << 27) - ___ABS(saw << 1);

int32_t ZEROAMOUNT;
int32_t NINETYAMOUNT;
// on/off button + amount
if (param_lfoon) {
  ZEROAMOUNT = ___SMMUL(ZERO << 3, param_lfoam << 2);
  NINETYAMOUNT = ___SMMUL(NINETY << 3, param_lfoam << 2);
}

else {
  ZEROAMOUNT = 0;
  NINETYAMOUNT = 0;
}

// 6db lo pass //
int32_t fa;
MTOF(ZEROAMOUNT + param_freqa, fa);

// 6db lo pass //
int32_t f;
MTOF(NINETYAMOUNT + param_freqa + param_freqb, f);

int32_t ccompl = ((128 << 20) - param_mix);
Audio Rate
int32_t FEEDINVERT = (param_feedinvert) ? -outlet_out : outlet_out;
int32_t FEEDAMOUNT = ___SMMUL(FEEDINVERT << 3, param_feedback << 2);
int32_t FEEDLIMIT =
    ___SMMUL(FEEDAMOUNT << 3, (int32_t)(54.00f * (1 << 21)) << 2);

// 6db lo pass //
vala = ___SMMLA(((inlet_in + FEEDLIMIT) - vala) << 1, fa, vala);
FILTERa = vala;

FILTERINVa = -FILTERa;
CLEANPLUSINVERTEDFILTERa = (inlet_in + FEEDLIMIT) + FILTERINVa;
CLEANPLUSINVERTEDFILTERINVa = -CLEANPLUSINVERTEDFILTERa;
STEP2a = FILTERa + CLEANPLUSINVERTEDFILTERINVa;

// From delay write sdram //
writepos1 = (writepos1 + 1) & LENGTHMASK1;
array1[writepos1] = __SSAT(STEP2a >> 14, 16);

int32_t TIMEMINIMUM1 =
    (param_timea + inlet_time > (int32_t)(02.00f * (1 << 21)))
        ? param_timea + inlet_time
        : (int32_t)(02.00f * (1 << 21));
int32_t TIME1LIMIT =
    ___SMMUL(TIMEMINIMUM1 << 3, (int32_t)(08.00f * (1 << 21)) << 2);

// delay/read interp //
uint32_t tmp_d1 = __USAT(TIME1LIMIT, 27);
uint32_t tmp_di1 =
    writepos1 - (tmp_d1 >> (27 - LENGTHPOW1)); //- BUFSIZE + buffer_index -1//
uint32_t tmp_w11 = (tmp_d1 << (LENGTHPOW1 + 3)) & 0x3FFFFFFF;
uint32_t tmp_w21 = (1 << 30) - tmp_w11;
int32_t tmp_a11 = array1[tmp_di1 & LENGTHMASK1] << 16;
int32_t tmp_a21 = array1[(tmp_di1 + 1) & LENGTHMASK1] << 16;
int32_t tmp_r1 = ___SMMUL(tmp_a11, tmp_w11);
tmp_r1 = ___SMMLA(tmp_a21, tmp_w21, tmp_r1);
int32_t AP1 = tmp_r1;

// 6db lo pass //
val = ___SMMLA((AP1 - val) << 1, f, val);
FILTER = val;

FILTERINV = -FILTER;
CLEANPLUSINVERTEDFILTER = AP1 + FILTERINV;
CLEANPLUSINVERTEDFILTERINV = -CLEANPLUSINVERTEDFILTER;
STEP2 = FILTER + CLEANPLUSINVERTEDFILTERINV;

// From delay write sdram //
writepos = (writepos + 1) & LENGTHMASK;
array[writepos] = __SSAT(STEP2 >> 14, 16);

int32_t TIMEMINIMUM2 =
    (param_timeb + inlet_time > (int32_t)(02.00f * (1 << 21)))
        ? param_timeb + inlet_time
        : (int32_t)(02.00f * (1 << 21));
int32_t TIME2LIMIT =
    ___SMMUL(TIMEMINIMUM2 << 3, (int32_t)(08.00f * (1 << 21)) << 2);

// delay/read interp //
uint32_t tmp_d = __USAT(TIME2LIMIT, 27);
uint32_t tmp_di =
    writepos - (tmp_d >> (27 - LENGTHPOW)); //- BUFSIZE + buffer_index -1//
uint32_t tmp_w1 = (tmp_d << (LENGTHPOW + 3)) & 0x3FFFFFFF;
uint32_t tmp_w2 = (1 << 30) - tmp_w1;
int32_t tmp_a1 = array[tmp_di & LENGTHMASK] << 16;
int32_t tmp_a2 = array[(tmp_di + 1) & LENGTHMASK] << 16;
int32_t tmp_r = ___SMMUL(tmp_a1, tmp_w1);
tmp_r = ___SMMLA(tmp_a2, tmp_w2, tmp_r);
ALLPASSS = tmp_r;

{
  int64_t a = (int64_t)ALLPASSS * param_mix;
  a += (int64_t)inlet_in * ccompl;
  MIX = a >> 27;
}

outlet_out = (param_on) ? MIX : inlet_in;

Privacy

© 2024 Zrna Research