Code:
/*
* Generate a frequency-modulated waveform, output it
* to the right channel, and feed the input
* right channel to the left channel.
*
* In hardware, connect the right output to the right
* input, which will allow us to check the latency.
*/
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
//#define SIMPLE_TEST
#if defined SIMPLE_TEST
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=160,506
AudioSynthWaveformModulated waveformMod1; //xy=332,512
AudioSynthWaveform waveform2; //xy=348,563
AudioInputI2S i2s1; //xy=513,437
AudioMixer4 mixer1; //xy=518,531
AudioOutputI2S i2s2; //xy=721,525
AudioOutputUSB usb1; //xy=722,449
AudioConnection patchCord1(waveform1, 0, waveformMod1, 0);
AudioConnection patchCord2(waveformMod1, 0, mixer1, 0);
AudioConnection patchCord3(waveform2, 0, mixer1, 1);
AudioConnection patchCord4(i2s1, 1, i2s2, 0);
AudioConnection patchCord5(i2s1, 1, usb1, 0);
AudioConnection patchCord6(mixer1, 0, i2s2, 1);
AudioConnection patchCord7(mixer1, 0, usb1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=714,576
// GUItool: end automatically generated code
#else
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=247,249
AudioSynthWaveformDc dc1; //xy=248,295
AudioSynthWaveform waveform1; //xy=295,349
AudioEffectMultiply multiply1; //xy=386,262
AudioSynthWaveformModulated waveformMod1; //xy=480,356
AudioSynthWaveform waveform2; //xy=498,400
AudioEffectWaveshaper waveshape1; //xy=550,266
AudioMixer4 mixer1; //xy=704,285
AudioMixer4 mixer2; //xy=704,386
AudioOutputUSB usb1; //xy=917,321
AudioOutputI2S i2s2; //xy=917,361
AudioConnection patchCord1(i2s1, 1, multiply1, 0);
AudioConnection patchCord2(dc1, 0, multiply1, 1);
AudioConnection patchCord3(waveform1, 0, waveformMod1, 0);
AudioConnection patchCord4(multiply1, waveshape1);
AudioConnection patchCord5(waveformMod1, 0, mixer2, 0);
AudioConnection patchCord6(waveform2, 0, mixer2, 1);
AudioConnection patchCord7(waveshape1, 0, mixer1, 0);
AudioConnection patchCord8(mixer1, 0, usb1, 0);
AudioConnection patchCord9(mixer1, 0, i2s2, 0);
AudioConnection patchCord10(mixer2, 0, usb1, 1);
AudioConnection patchCord11(mixer2, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=906,258
// GUItool: end automatically generated code
// GUItool: end automatically generated code
#endif
const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;
void setup() {
Serial.begin(115200);
// Audio connections require memory to work. For more
// detailed information, see the MemoryAndCpuUsage example
AudioMemory(20);
// Enable the audio shield, select input, and enable output
sgtl5000_1.enable();
sgtl5000_1.inputSelect(myInput);
sgtl5000_1.volume(0.5);
waveformMod1.begin(0.8f,100.0f,WAVEFORM_TRIANGLE);
waveformMod1.frequencyModulation(1.0f);
waveform1.begin(0.5f,1.0f,WAVEFORM_TRIANGLE); // modulate @ 1Hz
waveform2.begin(0.1f,700.0f,WAVEFORM_TRIANGLE); // "marker" waveform
#if !defined(SIMPLE_TEST)
float shapeArray[]={-1.0f,-0.25f,0.0f,0.25f,1.0f};
waveshape1.shape(shapeArray,5);
dc1.amplitude(1.0f);
mixer1.gain(0,1.0f);
mixer2.gain(0,1.0f);
mixer2.gain(1,1.0f);
#endif // !defined(SIMPLE_TEST)
}
void loop() {
delay(1000);
Serial.println("blip!");
}
Cheers