@@ -0,0 +1,137 @@ | |||
// Freeverb - High quality reverb effect | |||
// | |||
// | |||
// The SD card may connect to different pins, depending on the | |||
// hardware you are using. Uncomment or configure the SD card | |||
// pins to match your hardware. | |||
// | |||
// Data files to put on your SD card can be downloaded here: | |||
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html | |||
// | |||
// This example code is in the public domain. | |||
#include <Audio.h> | |||
#include <Wire.h> | |||
#include <SPI.h> | |||
#include <SD.h> | |||
#include <SerialFlash.h> | |||
// GUItool: begin automatically generated code | |||
AudioPlaySdWav playSdWav1; //xy=163,135 | |||
AudioMixer4 mixer1; //xy=332,167 | |||
AudioEffectFreeverb freeverb1; //xy=497,105 | |||
AudioMixer4 mixer2; //xy=650,190 | |||
AudioOutputI2S i2s1; //xy=815,198 | |||
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0); | |||
AudioConnection patchCord2(playSdWav1, 1, mixer1, 1); | |||
AudioConnection patchCord3(mixer1, freeverb1); | |||
AudioConnection patchCord4(mixer1, 0, mixer2, 1); | |||
AudioConnection patchCord5(freeverb1, 0, mixer2, 0); | |||
AudioConnection patchCord6(mixer2, 0, i2s1, 0); | |||
AudioConnection patchCord7(mixer2, 0, i2s1, 1); | |||
AudioControlSGTL5000 sgtl5000_1; //xy=236,248 | |||
// GUItool: end automatically generated code | |||
// Use these with the Teensy Audio Shield | |||
#define SDCARD_CS_PIN 10 | |||
#define SDCARD_MOSI_PIN 7 | |||
#define SDCARD_SCK_PIN 14 | |||
// Use these with the Teensy 3.5 & 3.6 SD card | |||
//#define SDCARD_CS_PIN BUILTIN_SDCARD | |||
//#define SDCARD_MOSI_PIN 11 // not actually used | |||
//#define SDCARD_SCK_PIN 13 // not actually used | |||
// Use these for the SD+Wiz820 or other adaptors | |||
//#define SDCARD_CS_PIN 4 | |||
//#define SDCARD_MOSI_PIN 11 | |||
//#define SDCARD_SCK_PIN 13 | |||
void setup() { | |||
Serial.begin(9600); | |||
// Audio connections require memory to work. For more | |||
// detailed information, see the MemoryAndCpuUsage example | |||
AudioMemory(10); | |||
// Comment these out if not using the audio adaptor board. | |||
// This may wait forever if the SDA & SCL pins lack | |||
// pullup resistors | |||
sgtl5000_1.enable(); | |||
sgtl5000_1.volume(0.5); | |||
SPI.setMOSI(SDCARD_MOSI_PIN); | |||
SPI.setSCK(SDCARD_SCK_PIN); | |||
if (!(SD.begin(SDCARD_CS_PIN))) { | |||
// stop here, but print a message repetitively | |||
while (1) { | |||
Serial.println("Unable to access the SD card"); | |||
delay(500); | |||
} | |||
} | |||
mixer1.gain(0, 0.5); | |||
mixer1.gain(1, 0.5); | |||
mixer2.gain(0, 0.9); // hear 90% "wet" | |||
mixer2.gain(1, 0.1); // and 10% "dry" | |||
} | |||
void playFile(const char *filename) | |||
{ | |||
Serial.print("Playing file: "); | |||
Serial.println(filename); | |||
// Start playing the file. This sketch continues to | |||
// run while the file plays. | |||
playSdWav1.play(filename); | |||
// A brief delay for the library read WAV info | |||
delay(5); | |||
elapsedMillis msec; | |||
// Simply wait for the file to finish playing. | |||
while (playSdWav1.isPlaying()) { | |||
// while the music plays, adjust parameters and print info | |||
if (msec > 250) { | |||
msec = 0; | |||
float knob_A1 = 0.9; | |||
float knob_A2 = 0.5; | |||
float knob_A3 = 0.5; | |||
// Uncomment these lines to adjust parameters with analog inputs | |||
//knob_A1 = (float)analogRead(A1) / 1023.0; | |||
//knob_A2 = (float)analogRead(A2) / 1023.0; | |||
//knob_A3 = (float)analogRead(A3) / 1023.0; | |||
mixer2.gain(0, knob_A1); | |||
mixer2.gain(1, 1.0 - knob_A1); | |||
freeverb1.roomsize(knob_A2); | |||
freeverb1.damping(knob_A3); | |||
Serial.print("Reverb: mix="); | |||
Serial.print(knob_A1 * 100.0); | |||
Serial.print("%, roomsize="); | |||
Serial.print(knob_A2 * 100.0); | |||
Serial.print("%, damping="); | |||
Serial.print(knob_A3 * 100.0); | |||
Serial.print("%, CPU Usage="); | |||
Serial.print(freeverb1.processorUsage()); | |||
Serial.println("%"); | |||
} | |||
} | |||
} | |||
void loop() { | |||
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format | |||
delay(500); | |||
playFile("SDTEST2.WAV"); | |||
delay(500); | |||
playFile("SDTEST3.WAV"); | |||
delay(500); | |||
playFile("SDTEST4.WAV"); | |||
delay(1500); | |||
} | |||
@@ -0,0 +1,145 @@ | |||
// Freeverb - High quality reverb effect | |||
// | |||
// Teensy 3.5 or higher is required to run this example | |||
// | |||
// The SD card may connect to different pins, depending on the | |||
// hardware you are using. Uncomment or configure the SD card | |||
// pins to match your hardware. | |||
// | |||
// Data files to put on your SD card can be downloaded here: | |||
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html | |||
// | |||
// This example code is in the public domain. | |||
#include <Audio.h> | |||
#include <Wire.h> | |||
#include <SPI.h> | |||
#include <SD.h> | |||
#include <SerialFlash.h> | |||
// GUItool: begin automatically generated code | |||
AudioPlaySdWav playSdWav1; //xy=163,135 | |||
AudioMixer4 mixer1; //xy=332,167 | |||
AudioEffectFreeverbStereo freeverbs1; //xy=490,92 | |||
AudioMixer4 mixer3; //xy=653,231 | |||
AudioMixer4 mixer2; //xy=677,152 | |||
AudioOutputI2S i2s1; //xy=815,198 | |||
AudioConnection patchCord1(playSdWav1, 0, mixer1, 0); | |||
AudioConnection patchCord2(playSdWav1, 1, mixer1, 1); | |||
AudioConnection patchCord3(mixer1, 0, mixer2, 1); | |||
AudioConnection patchCord4(mixer1, freeverbs1); | |||
AudioConnection patchCord5(mixer1, 0, mixer3, 1); | |||
AudioConnection patchCord6(freeverbs1, 0, mixer2, 0); | |||
AudioConnection patchCord7(freeverbs1, 1, mixer3, 0); | |||
AudioConnection patchCord8(mixer3, 0, i2s1, 1); | |||
AudioConnection patchCord9(mixer2, 0, i2s1, 0); | |||
AudioControlSGTL5000 sgtl5000_1; //xy=236,248 | |||
// GUItool: end automatically generated code | |||
// Use these with the Teensy Audio Shield | |||
#define SDCARD_CS_PIN 10 | |||
#define SDCARD_MOSI_PIN 7 | |||
#define SDCARD_SCK_PIN 14 | |||
// Use these with the Teensy 3.5 & 3.6 SD card | |||
//#define SDCARD_CS_PIN BUILTIN_SDCARD | |||
//#define SDCARD_MOSI_PIN 11 // not actually used | |||
//#define SDCARD_SCK_PIN 13 // not actually used | |||
// Use these for the SD+Wiz820 or other adaptors | |||
//#define SDCARD_CS_PIN 4 | |||
//#define SDCARD_MOSI_PIN 11 | |||
//#define SDCARD_SCK_PIN 13 | |||
void setup() { | |||
Serial.begin(9600); | |||
// Audio connections require memory to work. For more | |||
// detailed information, see the MemoryAndCpuUsage example | |||
AudioMemory(10); | |||
// Comment these out if not using the audio adaptor board. | |||
// This may wait forever if the SDA & SCL pins lack | |||
// pullup resistors | |||
sgtl5000_1.enable(); | |||
sgtl5000_1.volume(0.5); | |||
SPI.setMOSI(SDCARD_MOSI_PIN); | |||
SPI.setSCK(SDCARD_SCK_PIN); | |||
if (!(SD.begin(SDCARD_CS_PIN))) { | |||
// stop here, but print a message repetitively | |||
while (1) { | |||
Serial.println("Unable to access the SD card"); | |||
delay(500); | |||
} | |||
} | |||
mixer1.gain(0, 0.5); | |||
mixer1.gain(1, 0.5); | |||
mixer2.gain(0, 0.9); // hear 90% "wet" | |||
mixer2.gain(1, 0.1); // and 10% "dry" | |||
mixer3.gain(0, 0.9); | |||
mixer3.gain(1, 0.1); | |||
} | |||
void playFile(const char *filename) | |||
{ | |||
Serial.print("Playing file: "); | |||
Serial.println(filename); | |||
// Start playing the file. This sketch continues to | |||
// run while the file plays. | |||
playSdWav1.play(filename); | |||
// A brief delay for the library read WAV info | |||
delay(5); | |||
elapsedMillis msec; | |||
// Simply wait for the file to finish playing. | |||
while (playSdWav1.isPlaying()) { | |||
// while the music plays, adjust parameters and print info | |||
if (msec > 250) { | |||
msec = 0; | |||
float knob_A1 = 0.9; | |||
float knob_A2 = 0.5; | |||
float knob_A3 = 0.5; | |||
// Uncomment these lines to adjust parameters with analog inputs | |||
//knob_A1 = (float)analogRead(A1) / 1023.0; | |||
//knob_A2 = (float)analogRead(A2) / 1023.0; | |||
//knob_A3 = (float)analogRead(A3) / 1023.0; | |||
mixer2.gain(0, knob_A1); | |||
mixer2.gain(1, 1.0 - knob_A1); | |||
mixer3.gain(0, knob_A1); | |||
mixer3.gain(1, 1.0 - knob_A1); | |||
freeverbs1.roomsize(knob_A2); | |||
freeverbs1.damping(knob_A3); | |||
Serial.print("Reverb: mix="); | |||
Serial.print(knob_A1 * 100.0); | |||
Serial.print("%, roomsize="); | |||
Serial.print(knob_A2 * 100.0); | |||
Serial.print("%, damping="); | |||
Serial.print(knob_A3 * 100.0); | |||
Serial.print("%, CPU Usage="); | |||
Serial.print(freeverbs1.processorUsage()); | |||
Serial.println("%"); | |||
} | |||
} | |||
} | |||
void loop() { | |||
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format | |||
delay(500); | |||
playFile("SDTEST2.WAV"); | |||
delay(500); | |||
playFile("SDTEST3.WAV"); | |||
delay(500); | |||
playFile("SDTEST4.WAV"); | |||
delay(1500); | |||
} | |||
@@ -384,6 +384,8 @@ span.mainfunction {color: #993300; font-weight: bolder} | |||
{"type":"AudioEffectChorus","data":{"defaults":{"name":{"value":"new"}},"shortName":"chorus","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectFlange","data":{"defaults":{"name":{"value":"new"}},"shortName":"flange","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectReverb","data":{"defaults":{"name":{"value":"new"}},"shortName":"reverb","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectFreeverb","data":{"defaults":{"name":{"value":"new"}},"shortName":"freeverb","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectFreeverbStereo","data":{"defaults":{"name":{"value":"new"}},"shortName":"freeverbs","inputs":1,"outputs":2,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectEnvelope","data":{"defaults":{"name":{"value":"new"}},"shortName":"envelope","inputs":1,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectMultiply","data":{"defaults":{"name":{"value":"new"}},"shortName":"multiply","inputs":2,"outputs":1,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
{"type":"AudioEffectDelay","data":{"defaults":{"name":{"value":"new"}},"shortName":"delay","inputs":1,"outputs":8,"category":"effect-function","color":"#E6E0F8","icon":"arrow-in.png"}}, | |||
@@ -2407,6 +2409,92 @@ double s_freq = .0625;</p> | |||
</div> | |||
</script> | |||
<script type="text/x-red" data-help-name="AudioEffectFreeverb"> | |||
<h3>Summary</h3> | |||
<div class=tooltipinfo> | |||
<p>High quality Reverb effect, based on Freeverb by Jezar at Dreampoint. | |||
</p> | |||
</div> | |||
<h3>Audio Connections</h3> | |||
<table class=doc align=center cellpadding=3> | |||
<tr class="top"><th>Port</th><th>Purpose</th></tr> | |||
<tr class="odd"><td align="center">In 0</td><td>Input</td></tr> | |||
<tr class="odd"><td align="center">Out 0</td><td>Output</td></tr> | |||
</table> | |||
<h3>Functions</h3> | |||
<p class=func><span class=keyword>roomsize</span>(amount);</p> | |||
<p class=desc>Sets the amount of reverberant echo or apparent room | |||
size, from 0 (smallest) to 1.0 (largest); | |||
</p> | |||
<p class=func><span class=keyword>damping</span>(amount);</p> | |||
<p class=desc>Sets the damping factor, from 0 to 1.0. More damping | |||
causes higher frequency echo to decay, creating a softer sound, | |||
similar to a large room filled with people or materials which | |||
absorb some sound as it travels between reflecting surfaces. | |||
Lower damping simulates a harsher reverberant field. | |||
</p> | |||
<h3>Examples</h3> | |||
<p class=exam>File > Examples > Audio > Effects > Freeverb | |||
</p> | |||
<h3>Notes</h3> | |||
<p>Freeverb mono consumes about 21% of the CPU time on Teensy 3.2 and | |||
requires about 22K of RAM.</p> | |||
</script> | |||
<script type="text/x-red" data-template-name="AudioEffectFreeverb"> | |||
<div class="form-row"> | |||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | |||
<input type="text" id="node-input-name" placeholder="Name"> | |||
</div> | |||
</script> | |||
<script type="text/x-red" data-help-name="AudioEffectFreeverbStereo"> | |||
<h3>Summary</h3> | |||
<div class=tooltipinfo> | |||
<p>High quality stereo Reverb effect, based on Freeverb by Jezar at Dreampoint. | |||
</p> | |||
<p>Teensy 3.5 or 3.6 required to run stereo version.</p> | |||
</div> | |||
<h3>Audio Connections</h3> | |||
<table class=doc align=center cellpadding=3> | |||
<tr class="top"><th>Port</th><th>Purpose</th></tr> | |||
<tr class="odd"><td align="center">In 0</td><td>Input</td></tr> | |||
<tr class="odd"><td align="center">Out 0</td><td>Left Output</td></tr> | |||
<tr class="odd"><td align="center">Out 1</td><td>Right Output</td></tr> | |||
</table> | |||
<h3>Functions</h3> | |||
<p class=func><span class=keyword>roomsize</span>(amount);</p> | |||
<p class=desc>Sets the amount of reverberant echo or apparent room | |||
size, from 0 (smallest) to 1.0 (largest); | |||
</p> | |||
<p class=func><span class=keyword>damping</span>(amount);</p> | |||
<p class=desc>Sets the damping factor, from 0 to 1.0. More damping | |||
causes higher frequency echo to decay, creating a softer sound, | |||
similar to a large room filled with people or materials which | |||
absorb some sound as it travels between reflecting surfaces. | |||
Lower damping simulates a harsher reverberant field. | |||
</p> | |||
<h3>Examples</h3> | |||
<p class=exam>File > Examples > Audio > Effects > Freeverb_Stereo | |||
</p> | |||
<h3>Notes</h3> | |||
<p>Freeverb mono consumes about 18% of the CPU time on Teensy 3.6 and | |||
requires about 45K of RAM.</p> | |||
<p>Teensy 3.2 does not have enough RAM to | |||
run this effect while playing WAV file and implementing USB Serial.</p> | |||
</script> | |||
<script type="text/x-red" data-template-name="AudioEffectFreeverbStereo"> | |||
<div class="form-row"> | |||
<label for="node-input-name"><i class="fa fa-tag"></i> Name</label> | |||
<input type="text" id="node-input-name" placeholder="Name"> | |||
</div> | |||
</script> | |||
<script type="text/x-red" data-help-name="AudioEffectEnvelope"> | |||
<h3>Summary</h3> | |||
<div class=tooltipinfo> |