History

env: initial words

Paul Batchelor committed 5 years ago

Commit b39bed21 parent 0b1a09c1 file · +79 −0Browse files

Unified · Split

dsp/env.org+79−0
@@ -0,0 +1,79 @@
1#+TITLE: Env
2* Overview
3This document describes =env=, a trigger based envelope
4generator with adjustable attack, hold, and release times.
5This envelope is produced by feeding a gate signal into
6a smoothing filter. The output returns an exponetial
7envelope with very nice-sounding curves: a convex rise,
8and a concave fall.
9
10This sort of envelope is very ideal for percussive sounds
11and for mimicking analogue synthesizers. The drawbacks
12mainly have to do with precision. Attack and release
13times are specified as time constants, which are a little
14bit less intuitive than using seconds. The signal
15generated is in range 0 to 1, but it will never reach 1
16exactly.
17* Tangled Files
18=env.c= and =env.h=, respectively.
19* Components
20** Timer
21A timer is used to produce a gate signal of a particular
22duration. This kicks on during the hold portion of
23the signal.
24
25This timer is stored in a @!(ref "normalized_range"
26"normalized range")!@, and is updated by a normalized
27floating-point incrementor value.
28** Filter
29The filter used is a pretty typical
30@!(ref "smoother" "one-pole lowpass filter")!@, but with
31two parameters for the release and attack portions of
32the envelope.
33** State Management
34The envelope has three main states: attack, hold, and
35release. There is also a zero state to inidicate that
36envelope is not playing anything.
37** Previous Output
38The output from the previous sample is stored.
39* Parameters
40** Attack Time (in tau units)
41** Release Time (in tau units)
42** Hold Time (in seconds)
43* A Decent Epsilon Value
44To break out of attack mode, and to have a clean silence
45after release mode, a very small value known as an =epsilon=
46will be used. This value should be small enough to be
47perceptually perfect, and large enough to be numerically
48stable.
49
50High-quality tends to be 24-bit, so anything less than
51=1/2^24= can be ignored, which is roughly =5e-8= (rounded
52down), which
53I *think* should be reasonable enough for 32-bit
54floating-point numbers.
55* Computation
56The envelope will wait for a trigger. A trigger at any
57point will cause a retrigger. Some work will be done to
58write in behavior that will prevent clicks from happening.
59
60When the trigger occurs, the state is set to attack,
61and the gate signal is turned on. The attack time parameters
62are updated at this point, and the filter is configured
63to use the attack time parameters.
64
65In attack mode, the on-gate signal is put through the
66filter. The output is checked to see if exceeds a threshold
67reasonably close to 1. If it does, that value is held,
68and the state is set to be hold mode.
69
70The timer is stored in a @!(ref "normalized_range"
71"normalized range")!@, which allows the hold time to be
72adjustable while it is in hold mode. During the period
73in hold mode, the output signal will be the last returned
74value of the attack envelope.
75
76When timer reaches the end, the envelope goes into release
77mode. This is very similar to to attack mode, except that
78it uses release time coefficients and the input
79signal is a off-gate.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t