teensy dub siren and delay feedback problem

Status
Not open for further replies.

benwadub

Active member
hi, again me with a question,
i m building a dub siren with teensy, I have a pushbutton for noteon few waveforms, 2 lfo, a reverb and a filter
my problem is when my push button send note off it cut also my delay feedback but I want that feedback to continue when note off is send, here is the code, if anyone as a solution it could be nice!!
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>




// GUItool: begin automatically generated code
AudioSynthWaveformDc     dc1;            //xy=1552,282
AudioSynthWaveformModulated waveformMod12;  //xy=1581,498
AudioSynthWaveformModulated waveformMod9;   //xy=1725,528
AudioSynthWaveformModulated waveformMod3;   //xy=1728,229
AudioSynthWaveformModulated waveformMod4;   //xy=1728,264
AudioSynthWaveformModulated waveformMod5;   //xy=1728,308
AudioSynthWaveformModulated waveformMod6;   //xy=1728,343
AudioSynthWaveformModulated waveformMod7;   //xy=1728,378
AudioSynthWaveformModulated waveformMod8;   //xy=1728,415
AudioSynthWaveformModulated waveformMod2;   //xy=1729,192
AudioSynthWaveformModulated waveformMod1;   //xy=1730,155
AudioSynthNoiseWhite     noise1;         //xy=1732,580
AudioSynthNoisePink      pink1;          //xy=1741,624
AudioEffectMultiply      multiply2;      //xy=1808,461
AudioEffectEnvelope      envelope7;      //xy=1907,378
AudioEffectEnvelope      envelope6;      //xy=1911,342
AudioEffectEnvelope      envelope1;      //xy=1912,155
AudioEffectEnvelope      envelope5;      //xy=1912,307
AudioEffectEnvelope      envelope8;      //xy=1912,415
AudioEffectEnvelope      envelope2;      //xy=1913,192
AudioEffectEnvelope      envelope4;      //xy=1913,269
AudioEffectEnvelope      envelope3;      //xy=1914,231
AudioMixer4              mixer4;         //xy=1935,570
AudioEffectEnvelope      envelope9;      //xy=2098,530
AudioMixer4              mixer1;         //xy=2116,224
AudioMixer4              mixer2;         //xy=2122,335
AudioSynthWaveformDc     dc2;            //xy=2122,474
AudioSynthWaveformDc     dc3;            //xy=2144,132
AudioEffectEnvelope      envelope10;     //xy=2283,464
AudioSynthWaveformModulated waveformMod11;  //xy=2291,382
AudioMixer4              mixer3;         //xy=2303,247
AudioSynthWaveformModulated waveformMod10;  //xy=2324,151
AudioMixer4              mixer8;         //xy=2455,396
AudioEffectMultiply      multiply1;      //xy=2495,124
AudioFilterStateVariable filter1;        //xy=2498,271
AudioMixer4              mixer7;         //xy=2678,325
AudioEffectDelay         delay1;         //xy=2821,494
AudioEffectFreeverbStereo freeverbs1;     //xy=2841,333
AudioMixer4              mixer5;         //xy=3001,220
AudioMixer4              mixer6;         //xy=3002,443
AudioOutputUSB           usb1;           //xy=3187,223
AudioOutputAnalogStereo  dacs1;          //xy=3191,298
AudioConnection          patchCord1(dc1, 0, waveformMod12, 1);
AudioConnection          patchCord2(waveformMod12, 0, waveformMod1, 0);
AudioConnection          patchCord3(waveformMod12, 0, waveformMod2, 0);
AudioConnection          patchCord4(waveformMod12, 0, waveformMod3, 0);
AudioConnection          patchCord5(waveformMod12, 0, waveformMod4, 0);
AudioConnection          patchCord6(waveformMod12, 0, waveformMod5, 0);
AudioConnection          patchCord7(waveformMod12, 0, waveformMod6, 0);
AudioConnection          patchCord8(waveformMod12, 0, waveformMod7, 0);
AudioConnection          patchCord9(waveformMod12, 0, waveformMod8, 0);
AudioConnection          patchCord10(waveformMod9, 0, mixer4, 0);
AudioConnection          patchCord11(waveformMod3, envelope3);
AudioConnection          patchCord12(waveformMod4, envelope4);
AudioConnection          patchCord13(waveformMod5, envelope5);
AudioConnection          patchCord14(waveformMod6, envelope6);
AudioConnection          patchCord15(waveformMod7, envelope7);
AudioConnection          patchCord16(waveformMod8, envelope8);
AudioConnection          patchCord17(waveformMod2, envelope2);
AudioConnection          patchCord18(waveformMod1, envelope1);
AudioConnection          patchCord19(noise1, 0, mixer4, 1);
AudioConnection          patchCord20(pink1, 0, mixer4, 2);
AudioConnection          patchCord21(envelope7, 0, mixer2, 2);
AudioConnection          patchCord22(envelope6, 0, mixer2, 1);
AudioConnection          patchCord23(envelope1, 0, mixer1, 0);
AudioConnection          patchCord24(envelope5, 0, mixer2, 0);
AudioConnection          patchCord25(envelope8, 0, mixer2, 3);
AudioConnection          patchCord26(envelope2, 0, mixer1, 1);
AudioConnection          patchCord27(envelope4, 0, mixer1, 3);
AudioConnection          patchCord28(envelope3, 0, mixer1, 2);
AudioConnection          patchCord29(mixer4, envelope9);
AudioConnection          patchCord30(envelope9, 0, mixer3, 2);
AudioConnection          patchCord31(mixer1, 0, mixer3, 0);
AudioConnection          patchCord32(mixer2, 0, mixer3, 1);
AudioConnection          patchCord33(dc2, envelope10);
AudioConnection          patchCord34(dc3, 0, waveformMod10, 1);
AudioConnection          patchCord35(dc3, 0, waveformMod11, 1);
AudioConnection          patchCord36(envelope10, 0, mixer8, 1);
AudioConnection          patchCord37(waveformMod11, 0, mixer8, 0);
AudioConnection          patchCord38(mixer3, 0, filter1, 0);
AudioConnection          patchCord39(waveformMod10, 0, multiply1, 1);
AudioConnection          patchCord40(mixer8, 0, filter1, 1);
AudioConnection          patchCord41(multiply1, 0, mixer7, 0);
AudioConnection          patchCord42(filter1, 0, multiply1, 0);
AudioConnection          patchCord43(filter1, 0, mixer7, 1);
AudioConnection          patchCord44(mixer7, freeverbs1);
AudioConnection          patchCord45(mixer7, delay1);
AudioConnection          patchCord46(mixer7, 0, mixer5, 1);
AudioConnection          patchCord47(delay1, 0, mixer6, 1);
AudioConnection          patchCord48(delay1, 0, mixer7, 3);
AudioConnection          patchCord49(freeverbs1, 0, mixer5, 0);
AudioConnection          patchCord50(freeverbs1, 1, mixer6, 0);
AudioConnection          patchCord51(mixer5, 0, dacs1, 0);
AudioConnection          patchCord52(mixer5, 0, usb1, 0);
AudioConnection          patchCord53(mixer6, 0, dacs1, 1);
AudioConnection          patchCord54(mixer6, 0, usb1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=3125,523
// GUItool: end automatically generated code

Bounce button24 = Bounce(24, 15);
float hz2;
float cutoff = 19000;
float reso = 1.11;
float revol = 0.1;//0.0
float rsize = 0.2;//0.1
float atk = 1.;
float dcy = 35;
float sus = 1;
float rls = 0;
float atkf = 10.5;
float dcyf = 35;
float susf = 0.5;
float rlsf = 300;
float md = 0.0;
float phs = 0;
int swc = 0;
int swc2 = 0;
int wavfrm;
int wavfrm2;
int srlswc = 0;
float nse1 = 0.0;
float pnk1 = 0.0;
float amp2 = 0.00;
float vely = 0.00;
float shpwm = 0.00;
float shpwm2 = 0.00;
float lfofreq = 0.00;
float lfopitch = 0.00;
float lfoampf = 0.00;//mod pour test origine 0
float pitch = 0;
elapsedMillis timeout = 0;
int valueconvert;
extern const int16_t myWaveform[256];  // defined in myWaveform.ino
float delayfeedback = 1;
#define POLYPHONY 8  // Max # simultaneous notes
#define WAVEFORM WAVEFORM_SAWTOOTH

byte notesSounding[POLYPHONY] = {0};

void OnControlChange(byte channel, byte control, byte value){//LPD 8 CONTROL SURFACE// SERIAL BUTTON SWITCH
  if (control == 1) {        //CUTOFF    
    cutoff = (pow(value, 2.04))+20;  
  }
  if (control == 2) {        //RESO
    reso = (value / 29.53)+1.11;
      
  }
  if (control == 19) {             //REVERB VOL
    revol = (value / 381.00);         
  }
  if (control == 20) {            //REVERB SIZE
    rsize = (value / 254.00);         
  } 
                        //ADSR                            
  if (control == 13) {           //A
    atk = pow(value, 1.70);          
  }
  if (control == 14) {           //D
    dcy = pow(value, 1.70);           
  }
  if (control == 15) {           //S
    sus = (value / 127.00);        
  }
  if (control == 16) {           //R
    rls = pow(value, 1.91);             
  }
                       //ADSR VCF
  if (control == 9) {            //A  
    atkf = pow(value, 1.70);             
  }
  if (control == 10) {           //D
    dcyf = pow(value, 1.70);        
  }
  if (control == 11) {           //S
    susf = (value / 127.00);        
  }
  if (control == 12) {           //R
    rlsf = pow(value, 1.91);        
  }                              
  if (control == 3) {            // MOD DEPTH
    md = (value / 127.00);          
  }  
  if (control == 4) {            //PHASE 
     phs = (value / 254.00);
  }
  if (control == 5) {             // SWITCH
    swc = value;}
  if (control == 22) {             // SWITCH LFO
    swc2 = value;}  
  if (control == 6) {             // NOISE 
    nse1 = (value/254.00);}
  if (control == 7) {             // PINK 
    pnk1 = (value/254.00);}    
  if (control == 8) {             //3 and 4 OSC VOL's
    amp2 = (value / 254.00);}   
  if (control == 24) {            //SHAPE WAVEFORM
    shpwm = (value / 127.000);}  
  if (control == 23) {            //LFO SHAPE WAVEFORM
    shpwm2 = (value / 127.000);} 
  if (control == 17) {            //LFO AMOUNT
    lfopitch = (value / 127.00);} 
  if (control == 21) {            //LFO FILTER AMOUNT
    lfoampf = (value / 127.00);} 
  if (control == 18) {            //LFO FREQ
    lfofreq = pow(value, 2.04);}
       if (srlswc == HIGH){                                   //TASTO SWITCH SERIALE
  
  Serial.print("CC, ch=");
  Serial.print(channel);
  Serial.print(", ctrl= ");
  Serial.print(control);
  Serial.print(", value=");
  Serial.print(value);

  Serial.print("   A=");
  Serial.print(atk);
  Serial.print("   D=");
  Serial.print(dcy);
  Serial.print("   S=");
  Serial.print(sus);
  Serial.print("   R=");
  Serial.print(rls);
  
  Serial.print("   Af=");
  Serial.print(atkf);
  Serial.print("   Df=");
  Serial.print(dcyf);
  Serial.print("   Sf=");
  Serial.print(susf);
  Serial.print("   Rf=");
  Serial.print(rlsf);
  Serial.print("  SWC=");
  Serial.print(swc);
  Serial.print("  SWC2=");
  Serial.print(swc2);
  Serial.println();
       }
    
         if(swc2 <= 14){
      Serial.print ("LFO = SINE ");
      Serial.println ();}
      if(swc2 > 14 && swc2 <= 28){
      Serial.print ("LFO = TRIANGLE ");
      Serial.println ();}
      if(swc2 > 28 && swc2 <= 42){
      Serial.print ("LFO = TRIANGLE VAR ");
      Serial.println ();}
      if(swc2 > 42 && swc2 <= 56){
      Serial.print ("LFO = SAWTOOTH ");
      Serial.println ();}
      if(swc2 > 56 && swc2 <= 70){
      Serial.print ("LFO = SAWTOOTH REV ");
      Serial.println ();}
      if(swc2 > 70 && swc2 <= 84){
      Serial.print ("LFO = SQUARE ");
      Serial.println ();}
      if(swc2 > 84 && swc2 <= 98){
      Serial.print ("LFO = PULSE ");
      Serial.println ();}
      if(swc2 > 98 && swc2 <= 113){
      Serial.print ("LFO = ARBITRARY ");
      Serial.println ();}
      if(swc2 > 113 && swc2 <= 127){
      Serial.print ("LFO = SAMPLE&HOLD ");
      Serial.println ();}
      
           Serial.print("CUTOFF=");
           Serial.print(cutoff);
           Serial.print("   Q=");
           Serial.print(reso);
           Serial.print("  MOD DEPTH=");
           Serial.print(md);
           Serial.print("   REV VOL=");
           Serial.print(revol);
           Serial.print("   REV SIZE=");
           Serial.print(rsize);
           Serial.print("   NOISE=");
           Serial.print(nse1);
           Serial.print("   PINK=");
           Serial.print(pnk1);
           Serial.print("  Ø=");
           Serial.print(phs);
           Serial.print("  V's=");
           Serial.print(amp2);
           Serial.print("  pwm=");
           Serial.print(shpwm);
           Serial.print("  LFO pwm=");
           Serial.print(shpwm2);
           Serial.print("  LFO FREQ=");
           Serial.print(lfofreq);
           Serial.print("  LFO AMOUNT=");
           Serial.print(lfopitch);
           Serial.println();
    
  }
AudioSynthWaveformModulated *waveforms[POLYPHONY] = {
  &waveformMod1,
  &waveformMod2,
  &waveformMod3,
  &waveformMod4,
  &waveformMod5,
  &waveformMod6,
  &waveformMod7,
  &waveformMod8
};
AudioEffectEnvelope *envelopes[POLYPHONY] = {
  &envelope1,
  &envelope2,
  &envelope3,
  &envelope4,
  &envelope5,
  &envelope6,
  &envelope7,
  &envelope8
};
byte currentNote = 0;
double noteToFrequency(byte note) {
  return 440.0 * pow(2, ((note - 69.0) / 12.0));
}
       
byte getFreeWaveform() {
  for (byte i = 0; i < POLYPHONY; i++) {
    if (notesSounding[i] == 0) {
      return i;
    }
  }
    
  return 0;
}

void onNoteOn(byte channel, byte note, byte velocity) {       // VELOCITY
    vely = (velocity / 181.42)+0.07;                      
 
   

  envelope9.noteOn();
 

  byte index = getFreeWaveform();
  
  
  AudioSynthWaveformModulated *waveform = waveforms[index];
  waveform->frequency(noteToFrequency(note));
  
  AudioEffectEnvelope *envelope = envelopes[index];
  envelope->noteOn();
    
  notesSounding[index] = note;

  hz2  = 440 * pow (2.0, ((note +  7) - 69.0) / 12.0); 

  if (srlswc == HIGH){
  Serial.print("ON,       ch=");
  Serial.print(channel);
  Serial.print(", note=");
  Serial.print(note);
  Serial.print(", velocity=");
  Serial.print(velocity);
  Serial.print(", vely=");
  Serial.print(vely);
  Serial.println();
  }
}
void onNoteOff(byte channel, byte note, byte velocity) {

  envelope9.noteOff();
  
  
  for (byte i = 0; i < POLYPHONY; i++) {
    if (notesSounding[i] == note) {
      AudioEffectEnvelope *envelope = envelopes[i];
      envelope->noteOff();
      notesSounding[i] = 0;
    }
  }
                                       //SERIAL
  if (srlswc == HIGH){
  Serial.print("OFF,     ch=");
  Serial.print(channel);
  Serial.print(", note=");
  Serial.print(note);
  Serial.print(", velocity=");
  Serial.print(velocity);
  Serial.println();
}
}
void setup() {                 //                     S  E  T  U  P

//pinMode(0, INPUT_PULLUP);
  //dacs1.analogReference(EXTERNAL); //augmente le son du dac interne
  
  pinMode(24, INPUT_PULLUP);
  Serial.begin(9600);
  AudioMemory(20);

  mixer5.gain(1, 0.5);
  mixer6.gain(1, 0.5);
  mixer8.gain(2, 0.0);
  mixer8.gain(3, 0.0);

  waveformMod1.arbitraryWaveform(myWaveform, 172.0);
  waveformMod2.arbitraryWaveform(myWaveform, 172.0);
  waveformMod3.arbitraryWaveform(myWaveform, 172.0);
  waveformMod4.arbitraryWaveform(myWaveform, 172.0);
  waveformMod5.arbitraryWaveform(myWaveform, 172.0);
  waveformMod6.arbitraryWaveform(myWaveform, 172.0);
  waveformMod7.arbitraryWaveform(myWaveform, 172.0);
  waveformMod8.arbitraryWaveform(myWaveform, 172.0);
  waveformMod9.arbitraryWaveform(myWaveform, 172.0);
  
  for (byte i = 0; i < POLYPHONY; i++) {
    waveforms[i]->amplitude(0.5);
    waveforms[i]->begin(WAVEFORM);
    waveforms[i]->frequency(lfopitch);
    waveforms[i]->frequencyModulation(0);
    envelopes[i]->delay(0.0);
    envelopes[i]->hold(0.0);
  }

  envelope9.delay(0);
  envelope9.hold(0);

  
  //usbMIDI.setHandleControlChange(OnControlChange);
  usbMIDI.setHandleNoteOn(onNoteOn);
  usbMIDI.setHandleNoteOff(onNoteOff);

  delay1.delay(0, 500);
  delay(1000);
  delay1.disable(2);
  delay1.disable(3);
  delay1.disable(4);
  delay1.disable(5);
  delay1.disable(6);
  delay1.disable(7);

  freeverbs1.damping(1.0);
  filter1.octaveControl(12);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.1);
}
void loop() {                        //                L   O   O   P
button24.update();
   srlswc = digitalRead(24);
   int cutoff = analogRead(A14) *20;
   //analogReadAveraging(10);
   Serial.println(cutoff);
   delay(100);



//Serial.print(cutoffpot);

//Serial.println(cutoff);
//delay(100);
    int lfofreqpot = analogRead(A15);
     int lfofreq = lfofreqpot/127;
     delay(100);
       int delayfeedback = analogRead(A19);
  float feedback = (float)delayfeedback / 1050.0;
  mixer7.gain(3, feedback);
  /*  int shpwmpot = analogRead(A19);
     int shpwm = shpwmpot/127;//désactivé pour tester le delay*/
Serial.print(lfofreq);
delay(100);
    int lfoampfpot = analogRead(A16);
     int lfoampf = lfoampfpot/127;
delay(100);
    int lfopitchpot = analogRead(A17);
     int lfopitch = lfopitchpot/127;
delay(100);
    int swcpot = analogRead(A18);
     int swc = swcpot/1023;
delay(100);
if(swcpot <= 113){
    wavfrm = WAVEFORM_SINE;}
    if(swcpot > 114 && swcpot <= 226){        //TRIANGLE
    wavfrm = WAVEFORM_TRIANGLE;}
    if(swcpot > 227 && swcpot <= 340){        //TRIANGLE VAR
    wavfrm = WAVEFORM_TRIANGLE_VARIABLE;}
    if(swcpot > 341 && swcpot <= 453){        //SAWTOOTH
    wavfrm = WAVEFORM_SAWTOOTH;}
    if(swcpot > 454 && swcpot <= 567){        //SAWTOOTH REV
    wavfrm = WAVEFORM_SAWTOOTH_REVERSE;}
    if(swcpot > 568 && swcpot <= 681){        //SQUARE
    wavfrm = WAVEFORM_SQUARE;}
    if(swcpot > 682 && swcpot <= 795){        //PULSE
    wavfrm = WAVEFORM_PULSE;}
    if(swcpot > 796 && swcpot <= 909){       //ARBITRARY
    wavfrm = WAVEFORM_ARBITRARY;}
    if(swcpot > 910 && swcpot <= 1023){      //SAMPLE&HOLD
    wavfrm = WAVEFORM_SAMPLE_HOLD;}
    //
 
   if (button24.fallingEdge()) {
    Serial.print("button24");
    timeout = 0;
  envelope1.noteOn();
  envelope2.noteOn();
  envelope3.noteOn();
  envelope4.noteOn();
  envelope5.noteOn();
  envelope6.noteOn();
  envelope8.noteOn();
    
  }
  //if (delayfeedback<= 1){
   if (button24.risingEdge()) {
    
  envelope1.noteOff();
  envelope2.noteOff();
  envelope3.noteOff();
  envelope4.noteOff();
  envelope5.noteOff();
  envelope6.noteOff();
  envelope8.noteOff();
    timeout = 0;
    Serial.println("noteofffb");
  }

  waveformMod9.begin(0.3, 440, wavfrm);  //loader waveform
  waveformMod9.frequency(lfofreq);
  waveformMod9.amplitude(amp2);

  waveformMod10.begin(0.3, 440, wavfrm2);
  waveformMod10.frequency(lfofreq);
  waveformMod10.amplitude(lfoampf);

  waveformMod12.begin (0.3, 440, wavfrm);
  waveformMod12.frequency(lfofreq);
  waveformMod12.amplitude(lfopitch);
  //waveformMod12.offset(lfopitch);
 
  envelope1.attack(atk);
  envelope1.decay(dcy);
  envelope1.sustain(sus);
  envelope1.release(rls);
  
  envelope2.attack(atk);
  envelope2.decay(dcy);
  envelope2.sustain(sus);
  envelope2.release(rls);

  envelope3.attack(atk);
  envelope3.decay(dcy);
  envelope3.sustain(sus);
  envelope3.release(rls);

  envelope4.attack(atk);
  envelope4.decay(dcy);
  envelope4.sustain(sus);
  envelope4.release(rls);

  envelope5.attack(atk);
  envelope5.decay(dcy);
  envelope5.sustain(sus);
  envelope5.release(rls);

  envelope6.attack(atk);
  envelope6.decay(dcy);
  envelope6.sustain(sus);
  envelope6.release(rls);  

  envelope7.attack(atk);
  envelope7.decay(dcy);
  envelope7.sustain(sus);
  envelope7.release(rls);  

  envelope8.attack(atk);
  envelope8.decay(dcy);
  envelope8.sustain(sus);
  envelope8.release(rls);

  envelope9.attack(atk);
  envelope9.decay(dcy);
  envelope9.sustain(sus);
  envelope9.release(rls);  



  filter1.frequency(cutoff);
  filter1.resonance(reso);
     mixer7.gain(2, 0.5);
  mixer7.gain(3, 0.3);//delay feedback
  //mixer7.gain(3, feedback * 2.0);     //double le feedback 

  delay1.delay(0,phs);      //stereoize
  
  dc1.amplitude(shpwm);     //pwm
  dc3.amplitude(shpwm2);    //Lfo waveform pwm
 

  pink1.amplitude(pnk1);
  noise1.amplitude(nse1);
  freeverbs1.roomsize(rsize);
   mixer5.gain(0, revol);
  mixer6.gain(0, revol);
 
  
    for (byte i = 0; i < POLYPHONY; i++) {
     waveforms[i]->begin(wavfrm);
     waveforms[i]->amplitude(vely); 
    }
   
  usbMIDI.read();
}
 
Last edited:
Maybe just delete some or all of this?

Code:
   if (button24.risingEdge()) {
    
  envelope1.noteOff();
  envelope2.noteOff();
  envelope3.noteOff();
  envelope4.noteOff();
  envelope5.noteOff();
  envelope6.noteOff();
  envelope8.noteOff();
    timeout = 0;
    Serial.println("noteofffb");
  }

Also, in Arduino press CTRL-T to automatically fix the indenting of your code. It makes everything easier to read & understand.
 
and how the note will be stopped? note on and note off are the only part of audio library I really don t understand for the moment, for this project I studdied some other teensy synths but no one was using a push button on board they were all only midi
i ll try to remove that and see! thanks!
if you have other tips for my push button I ll take it with pleasure!
 
and how the note will be stopped?

How do you want it to stop?

In you question, you said "I want that feedback to continue when note off is send". You did not say you want the note to end, but to continue.


note on and note off are the only part of audio library I really don t understand for the moment,

The envelope effect is basically a variable gain amplifier. The noteOn() function causes the gain to increase from 0 (completely off) to 1.0, and then decrease slightly. The gain remains at the "sustain" level. The idea idea is similar to what happens when you blow into a wind instrument or strike a string. The sound quickly ramps up, then decays slightly as the tube or string settles to a steady resonance at whatever frequency it creates. The noteOn() function causes the gain to change in that manner over a short time, until it gets to the sustain level. Later when you call noteOff(), the gain decreases slowly to zero. It's similar to when you stop blowing into a wind instrument. There is pressurized air in the tube which continues making sound for a while. The release setting is meant to mimic that effect.

So if you want the sound to continue and slowly fade out, you could just configure a longer release time. The envelope effect supports up to 11 seconds release time.

Or if you want to achieve some other way of ending the sound, there is probably some method to accomplish it, maybe using a combination of effects from the library and code in Arduino. But how can I help you when I do not understand how you want to sound to end?
 
Status
Not open for further replies.
Back
Top