Skip to content

Attack is too fast on exponential envelope en.adsre #6

@jmidt

Description

@jmidt

When the attack time is set high on the exponential ADSR envelope, the level saturates very quickly, both not giving the wanted slow increase and also creating a long time with nothing happening before going to the decay stage. I propose something like this as a fix or a separate function

adsre_variable_attack(attT60,decT60,susLvl,relT60,gate) = envelope
  with {
  ugate = gate>0;
  samps = ugate : +~(*(ugate)); // ramp time in samples
  attSamps = int(attT60 * ma.SR);

  //The function for the attack phase. Should go from 0-1 in attSamps samples. Here it is linear
  attLvl = samps/attSamps; 

   //In the attack phase the target moves up following attLvl
  target = select2(ugate, 0.0,
           select2(samps<attSamps, (susLvl)*float(ugate), attLvl));

  //Instead of attT60, we choose some very small number, such that there is virtually no smoothing in the attack phase
  t60 = select2(ugate, relT60, select2(samps<attSamps, decT60, 0.0000001)); 

  pole = ba.tau2pole(t60/6.91);
  envelope = target : si.smooth(pole);

This gives a linear ramp up, but any function could in principle be used. I can make a pull request if you want?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions