Skip to content

Commit

Permalink
Add Delay example
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulStoffregen committed Oct 6, 2014
1 parent de39e6f commit 9bcfe36
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 3 deletions.
60 changes: 60 additions & 0 deletions examples/Effects/Delay/Delay.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Delay demonstration example, Teensy Audio Library
// http://www.pjrc.com/teensy/td_libs_Audio.html
//
// Creates a chirp on the left channel, then
// three delayed copies on the right channel.
//
// Requires the audio shield:
// http://www.pjrc.com/store/teensy3_audio.html
//
// This example code is in the public domain.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>

// GUItool: begin automatically generated code
AudioSynthWaveformSine sine1; //xy=158,74
AudioEffectEnvelope envelope1; //xy=232,156
AudioEffectDelay delay1; //xy=393,238
AudioMixer4 mixer1; //xy=532,205
AudioOutputI2S i2s1; //xy=611,61
AudioConnection patchCord1(sine1, envelope1);
AudioConnection patchCord2(envelope1, delay1);
AudioConnection patchCord3(envelope1, 0, i2s1, 0);
AudioConnection patchCord4(delay1, 0, mixer1, 0);
AudioConnection patchCord5(delay1, 1, mixer1, 1);
AudioConnection patchCord6(delay1, 2, mixer1, 2);
AudioConnection patchCord7(delay1, 3, mixer1, 3);
AudioConnection patchCord8(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=195,272
// GUItool: end automatically generated code

void setup() {
// allocate enough memory for the delay
AudioMemory(120);

// enable the audio shield
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);

// configure a sine wave for the chirp
// the original is turned on/off by an envelope effect
// and output directly on the left channel
sine1.frequency(1000);
sine1.amplitude(0.5);

// create 3 delay taps, which connect through a
// mixer to the right channel output
delay1.delay(0, 110);
delay1.delay(1, 220);
delay1.delay(2, 330);
}

void loop() {
envelope1.noteOn();
delay(36);
envelope1.noteOff();
delay(4000);
}
6 changes: 3 additions & 3 deletions gui/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -1521,9 +1521,9 @@ <h3>Functions</h3>
silent. If this channel is the longest delay, memory usage is
automatically reduced to accomodate only the remaining channels used.
</p>
<!--<h3>Examples</h3>
<p class=exam>File &gt; Examples &gt; Audio &gt;
</p>-->
<h3>Examples</h3>
<p class=exam>File &gt; Examples &gt; Audio &gt; Effects &gt; Delay
</p>
<h3>Notes</h3>
<p>Memory for the delayed signal is take from the memory pool allocated by
<a href="http://www.pjrc.com/teensy/td_libs_AudioConnection.html" target="_blank">AudioMemory()</a>.
Expand Down

0 comments on commit 9bcfe36

Please sign in to comment.