quarterturn
Well-known member
I've been testing the Teensy 3.1 audio library and find that the envelope object doesn't seem to respond to A, D, or R values greater than 1000 ms, perhaps even a bit shorter.
In my example code below, envelope1 is after the filter and envelope2 feeds a DC signal into the frequency control of the filter. Envelope1 just has a sustain level of 1.0, so basically it's not there. Envelope2 should produce a sound with a quick attack and long release, but it's more like a quick "wow".
I wait 3000 ms before calling noteOff, so there should be plenty of time for phase D to complete.
Bug, or am I doing it wrong?
In my example code below, envelope1 is after the filter and envelope2 feeds a DC signal into the frequency control of the filter. Envelope1 just has a sustain level of 1.0, so basically it's not there. Envelope2 should produce a sound with a quick attack and long release, but it's more like a quick "wow".
I wait 3000 ms before calling noteOff, so there should be plenty of time for phase D to complete.
Bug, or am I doing it wrong?
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
// GUItool: begin automatically generated code
AudioSynthWaveformDc dc1; //xy=57,359
AudioSynthWaveform waveform1; //xy=86,216
AudioEffectEnvelope envelope2; //xy=165,283
AudioFilterStateVariable filter1; //xy=367,277
AudioEffectEnvelope envelope1; //xy=554,266
AudioOutputI2S i2s1; //xy=570,411
AudioConnection patchCord1(dc1, envelope2);
AudioConnection patchCord2(waveform1, 0, filter1, 0);
AudioConnection patchCord3(envelope2, 0, filter1, 1);
AudioConnection patchCord4(filter1, 0, envelope1, 0);
AudioConnection patchCord5(envelope1, 0, i2s1, 0);
AudioConnection patchCord6(envelope1, 0, i2s1, 1);
AudioControlSGTL5000 audioShield; //xy=569,528
// GUItool: end automatically generated code
void setup(void)
{
// Set up
AudioMemory(8);
audioShield.enable();
audioShield.volume(0.45);
// audio waveform
waveform1.pulseWidth(0.5);
waveform1.begin(0.2, 100, WAVEFORM_PULSE);
// EG for VCA
envelope1.attack(1);
envelope1.decay(1);
envelope1.sustain(1.0);
envelope1.release(0.0);
// EG for VCF
envelope2.attack(100);
envelope2.decay(2800);
envelope2.sustain(0.0);
envelope2.release(0.0);
// DC input to EG for VCF
dc1.amplitude(0.3);
// VCF setup
// corner frequency when control is zero
filter1.frequency(0);
// resonance
filter1.resonance(5.0);
// filter range
filter1.octaveControl(7);
}
void loop() {
float w;
float v = 0.3;
for (uint32_t i =1; i<20; i++) {
w = i / 20.0;
waveform1.pulseWidth(w);
envelope1.noteOn();
envelope2.noteOn();
delay(3000);
envelope1.noteOff();
envelope2.noteOff();
delay(100);
v = v + 0.1;
if ( v > 1.0 )
{
v = 0.3;
}
dc1.amplitude(v);
}
}