Create the subVI ADSR.vi to generate the ADSR-style envelope specified in
Figure 1; recall that
ADSR stands for "Attack Decay Sustain Release."
The envelope shape is defined over a normalized time interval of 0 to 1; the envelope stretches or compresses to match the actual duration requested. The three time intervals are likewise expressed in normalized units, so an attack duration (tA) of 0.2 indicates that the attack time is 20% of the entire envelope duration. The envelope values range from 0 dB (full sound intensity) to -40 dB (close to silence). Once you have defined the envelope shape in terms of straight-line segments, you can create the envelope amplitude waveform by undoing the decibels operation; recall that an amplitude "A" expressed in dB is 20 log10(A).
The subVI requires the following controls as input parameters (units specified in brackets):
- duration [s] - total duration of envelope
- fs [Hz] - system-wide sampling frequency
- t values - three-value array containing attack (A) interval, decay (D) interval, and release (R) interval. All three values are in the range 0 to 1, so the intervals are to be treated as fractions of the total duration of the envelope. For example, A=0.3 indicates the attack interval is 30% of the envelope's duration.
- e values - two-value array containing the envelope value at the beginning of the sustain interval (eS in the diagram above) and the envelope value at the beginning of the release interval (eR).
The subVI requires the single indicator (output) envelope, an array with values in the range 0 to 1.
Show that your ADSR VI functions properly by plotting the envelope for at least two distinct cases. Plot both the dB form of the envelope as well as its non-dB form.
The following screencast video provides coding tips and other suggestions to help you develop your subVI.
"A multimedia educational resource for signal processing students and faculty."