29 releases

0.2.12-alpha.0 Apr 7, 2023
0.2.11-alpha.0 Dec 19, 2022
0.2.5-alpha.0 Jun 21, 2022
0.2.4-alpha.0 Mar 14, 2022
0.1.42-alpha.0 Oct 27, 2021

#9 in #amplitude


Used in 4 crates

GPL-3.0 license

410KB
5.5K SLoC

surge-adsr

The AdsrEnvelope is a symbol in the context of sound synthesis and represents an envelope generator that is commonly used to shape the amplitude of a sound wave over time. "ADSR" stands for "Attack, Decay, Sustain, Release", which are the four stages of the envelope.

  • The Attack stage represents the initial increase in amplitude as the sound is triggered or initiated.

  • The Decay stage is a period of decreasing amplitude after the initial peak, usually to a steady level called the Sustain level.

  • The Sustain stage represents a period of steady amplitude that is held as long as the sound is being triggered or sustained.

  • Finally, the Release stage represents the period during which the sound's amplitude decreases back to zero after the sound is no longer being triggered.

The AdsrEnvelope is often used in electronic music synthesis, particularly in creating sounds for instruments such as synthesizers and samplers. By controlling the amplitude of the sound wave with an envelope generator, the sound can be shaped in a way that creates more dynamic and interesting musical textures.

3> thanks -- could you teach me more about how such a system is designed?

Sure! I can provide you with a high-level overview of how an ADSR envelope generator is typically implemented in a synthesizer or similar audio processing system.

First, the envelope generator needs to receive a trigger signal to indicate when to start generating the envelope. In the case of a synthesizer, this trigger signal might be generated when a key is pressed on the keyboard.

Once the trigger signal is received, the envelope generator begins the Attack stage, during which the amplitude of the sound increases from zero to its peak level. The duration of the Attack stage is controlled by an attack time parameter, which determines how quickly the sound reaches its peak amplitude.

After the Attack stage, the envelope generator moves into the Decay stage, during which the amplitude of the sound decreases to a sustain level. The duration of the Decay stage is controlled by a decay time parameter, which determines how quickly the sound reaches the sustain level.

Once the Decay stage is complete, the envelope generator enters the Sustain stage, during which the amplitude of the sound remains constant. The level of the sustain stage is controlled by a sustain level parameter, which determines the amplitude level at which the sound will be sustained.

Finally, when the trigger signal is released (for example, when a key is released on the keyboard), the envelope generator enters the Release stage, during which the amplitude of the sound decreases from the sustain level back down to zero. The duration of the Release stage is controlled by a release time parameter, which determines how quickly the sound returns to silence.

The ADSR envelope generator can be implemented using a variety of techniques, but one common approach is to use a series of linear or exponential ramp generators to control the amplitude of the sound wave over time. These ramp generators can be implemented using digital signal processing techniques or analog circuits, depending on the specific implementation.

4> what are some other techniques for implementing one?

There are several other techniques for implementing an ADSR envelope generator, each with its own advantages and disadvantages. Here are a few examples:

  1. Look-up table: One approach is to use a look-up table to store a pre-calculated envelope curve, which can be accessed and scaled in real-time as needed. This can be an efficient approach, but it requires a relatively large amount of memory to store the table, and it may not be as flexible as other methods.

  2. State-variable filter: Another approach is to use a state-variable filter to generate the envelope shape. This involves using a filter circuit to generate a signal that follows the desired envelope shape. The advantage of this approach is that it can produce complex envelope shapes that are difficult to achieve with other methods, but it can be computationally expensive and may introduce unwanted artifacts or distortion.

  3. Sample and hold: Another technique is to use a sample and hold circuit to generate the envelope shape. This involves sampling the amplitude of the sound wave at regular intervals and holding the value until the next sample is taken. The advantage of this approach is that it can be relatively simple to implement and can produce smooth, continuous envelope shapes, but it may not be as precise or flexible as other methods.

  4. Function generator: A function generator circuit can also be used to implement an ADSR envelope generator. This involves using a circuit that generates a specific waveform shape, such as a triangle wave or sawtooth wave, to create the envelope shape. This approach can be flexible and precise, but it may require a relatively complex circuit design and can be computationally expensive.

Ultimately, the choice of implementation technique will depend on the specific requirements of the application and the resources available for implementation.

5> how do the analog and digital implementations differ?

Analog and digital implementations of an ADSR envelope generator differ in terms of the underlying circuitry and processing techniques used. Here are some key differences:

  1. Signal Processing: Analog implementations of an ADSR envelope generator typically use analog circuitry to generate the envelope shape, while digital implementations use software algorithms to generate the envelope shape. This can affect the precision, speed, and complexity of the implementation.

  2. Control Parameters: In an analog implementation, the various control parameters of the ADSR envelope generator (attack time, decay time, sustain level, release time) are usually implemented as adjustable resistors or potentiometers. In a digital implementation, these parameters are typically controlled using software, which allows for more precise and flexible control over the envelope shape.

  3. Signal Fidelity: Analog implementations of an ADSR envelope generator are typically more susceptible to noise, distortion, and other sources of signal degradation. Digital implementations, on the other hand, can provide high fidelity and precision in generating the envelope shape, as long as the digital-to-analog converters used to convert the digital signal to an analog audio signal are of high quality.

  4. Cost and Complexity: Analog implementations of an ADSR envelope generator can be relatively simple and inexpensive to implement, but may require careful tuning and calibration to achieve the desired envelope shape. Digital implementations can be more complex and costly, but can provide greater flexibility and precision in generating the envelope shape.

Overall, the choice between an analog or digital implementation of an ADSR envelope generator will depend on the specific requirements of the application, including factors such as cost, complexity, signal fidelity, and control parameters. In some cases, a hybrid approach may be used, combining analog and digital techniques to achieve the desired envelope shape.

Dependencies

~11–20MB
~295K SLoC