DR4

drum synthesizer with an extra wavetable shaper to add higher harmonics to the sine-base. Uses wavetables made with the wavetable creator "Creator" (1024 waves of 1024 samples long each) Seperate envelopes for pitch, volume and noise levels. Volume envelope can be fed to the end-LP filter (E2C knob) Noise part has it's own SVF filter with cutoff, resonance and selectable mode(LP,HP,BP,NOTCH) Best to trigger this with a trigger instead of a gate.
Author: Remco van der Most
License: BSD
Github: sss/edrum/DR4.axo

Inlets

bool32.rising trig

int32 hold

int32 waveform

int32 step

int32 octave

int32 mode

frac32 mix

frac32 env2wave

frac32 Vdec

frac32 Pdec

frac32 Ndec

frac32 Watt

frac32 pitch

frac32 Pamt

frac32 E2C

frac32 sineLvl

frac32 waveLvl

frac32 noiseLvl

frac32 cut

frac32 reso

frac32 start

frac32 gain

frac32 LP

Outlets

frac32buffer out

frac32 env

int32 div

Parameters

frac32.u.map sineLvl

frac32.u.map waveLvl

frac32.u.map noiseLvl

frac32.u.map gain

frac32.u.map mix

frac32.u.map.filterq reso

int32.hradio mode

int32 hold

int32 repeat

int32 wave

int32 octave

int32 quant

int32 step

frac32.u.map.kdecaytime Vdec

frac32.u.map.kdecaytime Pdec

frac32.u.map.kdecaytime Ndec

frac32.u.map.kdecaytime Watt

frac32.s.map env2wave

frac32.s.map FM

frac32.s.map E2C

frac32.s.map start

frac32.s.map.pitch pitch

frac32.s.map.pitch Pamt

frac32.s.map.pitch cut

frac32.s.map.pitch LP

Attributes

objref table

Declaration
uint32_t phase;
int32_t sine;
int32_t read;
uint32_t Penv;
uint32_t Venv;
uint32_t Nenv;
uint32_t Wenv;
int gtrig;
int Gtrig;
int32_t noise;
int32_t val;
int32_t table1;
int32_t table2;
int32_t preset;
int32_t count;

int32_t low;
int32_t band;
int32_t mix;
int32_t tablemix(int32_t WaveA, int32_t WaveB, int32_t Mix) {
  mix = ___SMMUL(((1 << 27) - Mix) << 3, WaveA << 2) +
        ___SMMUL(Mix << 3, WaveB << 2);
}
int i;
int32_t MIX1;
int32_t W[2];
Init
low = 0;
band = 0;
Control Rate
int32_t MiX1 = inlet_mix + param_mix +
               ___SMMUL(param_env2wave + inlet_env2wave << 3, Venv << 2);
MiX1 = MiX1 & ((1 << 27) - 1);
int32_t quant = param_quant + 1;
float32_t step =
    ((float32_t)(attr_table.Waveforms)) / (quant) * (inlet_step + param_step);
outlet_div = quant;

W[0] = ((MiX1 >> 4) * quant) >> 23;
MiX1 = (MiX1 - (W[0] << 27) / quant) * quant;
W[1] = W[0] * step + step + param_wave;
W[0] = W[0] * step + param_wave;

for (i = 0; i < 2; i++) {
  W[i] = (W[i] - (W[i] / attr_table.Waveforms) * attr_table.Waveforms);
  W[i] = W[i] < 0 ? W[i] + attr_table.Waveforms : W[i];
  W[i] = W[i] * attr_table.LENGTH;
}

int32_t F1;
MTOF(-param_Pdec - inlet_Pdec, F1)
int32_t F2;
MTOF(-param_Vdec - inlet_Vdec, F2)
int32_t F3;
MTOF(-param_Ndec - inlet_Ndec, F3)
int32_t F4;
MTOF(-param_Watt - inlet_Watt, F4)
if (count >= param_hold) {
  Penv = ___SMMLA(-Penv, F1 << 1, Penv);
  Venv = ___SMMLA(-Venv, F2 << 1, Venv);
  Nenv = ___SMMLA(-Nenv, F3 << 1, Nenv);
  Wenv = ___SMMLA(-Wenv, F4 << 1, Wenv);
}
if ((inlet_trig > 0) && !gtrig) {

  gtrig = 1;
  Penv = (1 << 27);
  Venv = (1 << 27);
  Nenv = (1 << 27);
  Wenv = (1 << 27);
  count = 0;
} else if (inlet_trig == 0) {
  gtrig = 0;
}
int hold = param_hold + inlet_hold;
count += 1;
count = count > hold ? hold : count;

int32_t PENV = Penv;
//___SMMUL(Penv<<3,Penv<<2);
PENV = ___SMMUL(PENV << 3, PENV << 2) * param_repeat & ((1 << 27) - 1);

int32_t VENV = Venv;
VENV = ___SMMUL(VENV << 3, VENV << 2) * param_repeat & ((1 << 27) - 1);

VENV += ___SMMUL(__USAT(param_gain + inlet_gain, 27) << 2, VENV << 3) * 3;

int32_t NENV = ___SMMUL(Nenv << 3, Nenv << 2);
NENV = ___SMMUL(NENV << 3, NENV << 2) * param_repeat & ((1 << 27) - 1);
NENV = ___SMMUL(NENV << 3, (__USAT(param_noiseLvl + inlet_noiseLvl, 27)) << 2);

int32_t WENV = (1 << 27) - Wenv;
WENV = ___SMMUL(WENV << 3, WENV << 2);
WENV = ___SMMUL(WENV << 3, WENV << 2) * param_repeat & ((1 << 27) - 1);
WENV = ___SMMUL(WENV << 3, __USAT(param_waveLvl + inlet_waveLvl, 27) << 2);

int32_t octave = param_octave + inlet_octave;
int32_t Octave;
if (octave >= 0) {
  octave = octave;
  Octave = 0;
} else {
  Octave = -octave;
  octave = 0;
}

int32_t freq;
MTOFEXTENDED(
    param_pitch + inlet_pitch +
        ___SMMUL(__USAT(param_Pamt + inlet_Pamt - param_pitch - inlet_pitch, 27)
                     << 3,
                 PENV << 2),
    freq)
freq = freq >> Octave;
int32_t damp = (0x80 << 24) - (__USAT(param_reso + inlet_reso, 27) << 4);
damp = ___SMMUL(damp, damp);
int32_t alpha;
int32_t fraq;
MTOFEXTENDED(__SSAT(param_cut + inlet_cut +
                        ___SMMUL(__SSAT(param_E2C + inlet_E2C, 28) << 3,
                                 VENV << 2),
                    28),
             alpha);
SINE2TINTERP(alpha, fraq);

int32_t sineLvl = __USAT(param_sineLvl + inlet_sineLvl, 27);
int32_t cut;
MTOF(param_LP + ___SMMUL(__SSAT(param_E2C + inlet_E2C, 28) << 3, VENV << 2),
     cut)
// preset=(param_wave+inlet_waveform);
// preset=preset-preset/attr_table.Waveforms*attr_table.Waveforms;
// preset=preset<<attr_table.LENGTHPOW;
outlet_env = Penv;
int32_t Noise = (1 << 28) - (__SSAT(param_cut + inlet_cut, 28) + (1 << 27));
int32_t FM = ___SMMUL(freq << 1, param_FM << 4);
Audio Rate
if ((inlet_trig > 0) && !Gtrig) {
  Gtrig = 1;
  phase = 0;
} else if (inlet_trig == 0) {
  Gtrig = 0;
}

noise = (int32_t)(GenerateRandomNumber()) >> 5;
int32_t notch = (noise) - (___SMMUL(damp, band) << 1);
low = low + (___SMMUL(fraq, band) << 1);
int32_t high = notch - low;
band = (___SMMUL(fraq, high) << 1) + band;
int32_t out;
switch ((param_mode + inlet_mode) & 3) {
case 0:
  out = low;
  break;
case 1:
  out = high;
  break;
case 2:
  out = band;
  break;
case 3:
  out = notch;
  break;
}

noise = out << 4;

phase += freq + ___SMMUL(NENV, out >> 2) + ___SMMUL(FM << 3, val << 3);

table1 =
    ___SMMUL(attr_table.array[((((phase + (param_start + inlet_start << 5)) >>
                                 32 - attr_table.LENGTHPOW - octave) &
                                attr_table.LENGTHMASK) +
                               W[0])]
                 << 4,
             WENV)
    << 1;
table2 =
    ___SMMUL(attr_table.array[((((phase + (param_start + inlet_start << 5)) >>
                                 32 - attr_table.LENGTHPOW - octave) &
                                attr_table.LENGTHMASK) +
                               W[1])]
                 << 4,
             WENV)
    << 1;
tablemix(table1, table2, MiX1);
SINE2TINTERP(phase << Octave, sine)

int32_t wave;
wave = __SSAT(
    ___SMMUL(___SMMUL(sine, sineLvl) +
                     __SSAT((___SMMUL((noise >> 2) +
                                          (___SMMUL(noise, Noise << 3) << 3),
                                      NENV << 2) +
                             mix),
                            28)
                 << 2,
             VENV << 1)
        << 2,
    27);

val = ___SMMLA((wave - val) << 1, cut, val);

outlet_out = val;

Privacy

© 2024 Zrna Research