(t_note_length, t_attack=0.010, t_release=0.3, sr=16000)
return envelope
Create an attack sustain release amplitude envelope.
Create an attack sustain release amplitude envelope.
Create an attack sustain release amplitude envelope .
def get_envelope(t_note_length, t_attack=0.010, t_release=0.3, sr=16000):
  """Create an attack sustain release amplitude envelope."""
  t_note_length = min(t_note_length, MAX_NOTE_LENGTH)
  i_attack = int(sr * t_attack)
  i_sustain = int(sr * t_note_length)
  i_release = int(sr * t_release)
  i_tot = i_sustain + i_release  # attack envelope doesn't add to sound length
  envelope = np.ones(i_tot)
  # Linear attack
  envelope[:i_attack] = np.linspace(0.0, 1.0, i_attack)
  # Linear release
  envelope[i_sustain:i_tot] = np.linspace(1.0, 0.0, i_release)
  return envelope
def get_envelope ( t_note_length , t_attack = 0.010 , t_release = 0.3 , sr = 16000 ) : t_note_length = min ( t_note_length , MAX_NOTE_LENGTH ) i_attack = int ( sr * t_attack ) i_sustain = int ( sr * t_note_length ) i_release = int ( sr * t_release ) i_tot = i_sustain + i_release # attack envelope doesn't add to sound length envelope = np . ones ( i_tot ) # Linear attack envelope [ : i_attack ] = np . linspace ( 0.0 , 1.0 , i_attack ) # Linear release envelope [ i_sustain : i_tot ] = np . linspace ( 1.0 , 0.0 , i_release ) return envelope