#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformModulated waveformMod1; //xy=217,453
AudioMixer4 mixer3; //xy=429,468
AudioSynthWaveformModulated waveformMod2; //xy=593,289
AudioOutputAnalogStereo dacs1; //xy=717,407
AudioOutputI2S i2s2; //xy=815,289
AudioConnection patchCord1(waveformMod1, 0, mixer3, 0);
AudioConnection patchCord2(mixer3, 0, waveformMod2, 0);
AudioConnection patchCord3(mixer3, 0, dacs1, 1);
AudioConnection patchCord4(mixer3, 0, dacs1, 0);
AudioConnection patchCord5(waveformMod2, 0, i2s2, 0);
AudioConnection patchCord6(waveformMod2, 0, i2s2, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=587,139
// GUItool: end automatically generated code
float pot[16] = {0};
float freq[16] = {};
uint32_t cm, prev[20];
void setup() {
AudioNoInterrupts();
AudioMemory(50);
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
waveformMod1.begin(1, 1, WAVEFORM_TRIANGLE);
waveformMod2.begin(1, 220, WAVEFORM_SINE);
mixer3.gain(0, 1);
analogReadResolution(12);
AudioInterrupts();
}
void loop() {
cm = millis();
if (cm - prev[1] > 4 ) {
prev[1] = cm;
pot[0] = analogRead(A18) / 4095.00;
pot[1] = (analogRead(A19) / 2048.00) -1.00;
pot[2] = analogRead(A15) / 400.0 ;
waveformMod1.frequency(pot[2]);
static float offa = .005;
float at1 = pot[0] - offa;
if (at1 < 0) {
at1 = 0;
}
waveformMod1.offset( pot[1]);
waveformMod1.amplitude( pot[0]);
}
if (cm - prev[3] > 200) {
prev[3] = cm;
Serial.print(AudioProcessorUsageMax());
Serial.print(" ");
Serial.println(AudioMemoryUsageMax());
Serial.print( pot[0], 4);
Serial.print( " ");
Serial.print( pot[1], 4);
Serial.print( " ");
Serial.println( pot[2]);
AudioProcessorUsageMaxReset();
AudioMemoryUsageMaxReset();
}
}