title: Web Audio Delay Node guidance
body: <p>trying to wire up a delay effect for a little Web Audio app and can't seem to get it to sound good.  Seems simple enough but not getting the results I'd like.  Would like to have the delay note repeat over and over and slowly die away.  I can implement the gain part of that but can't seem to get the feedback loop part so the delay continues.  Can someone point me in the right direction?</p>
  
  <p>Here's the relevant code.  Added a second delay in hopes of extending but not quite what I was looking for.</p>
  
  <pre><code>            var osc = ctx.createOscillator();
              var gainNode = ctx.createGain();
  
              if (addDelay === false) {
                  osc.connect(gainNode);
                  gainNode.connect(ctx.destination);
              }
  
              else if (addDelay === true) {
                  var delay = ctx.createDelay();
                  var delay2 = ctx.createDelay();
                  delay.delayTime.value = 0.35;
                  delay2.delayTime.value = 0.5;
                  osc.connect(gainNode);
                  gainNode.connect(ctx.destination);
                  gainNode.connect(delay);
                  gainNode.connect(delay2);
                  delay.connect(gainNode);
                  delay2.connect(gainNode);
                  delay.connect(ctx.destination);
                  delay2.connect(ctx.destination);        
              }
              gainNode.gain.value = 0.0;
              gainNode.gain.setTargetAtTime(0.75, ctx.currentTime, 0.1);
              gainNode.gain.setTargetAtTime(0.0, ctx.currentTime + sustainFnl, 0.01);
              osc.frequency.value = hz * octave / 4;
              osc.type = waveType;
              osc.start();
              osc.stop(ctx.currentTime + sustainFnl + 0.01);
          }
  </code></pre>
  
  <p>Thanks!</p>