halogravity
Well-known member
Hi everyone. I have brought my test down to the most bare bones code and I am still having issues. Essentially its one button, one knob, and the audio system design tool is just a waveform into an envelope into the output. The waveform is distorted, and I can't figure out why. Can someone give me a hint? It's driving me mad.
It's a Teensy 3.6 that I have attached with headers above the audio board. The Synthplay sketch as a test runs beautifully.
It's a Teensy 3.6 that I have attached with headers above the audio board. The Synthplay sketch as a test runs beautifully.
Code:
#include <Arduino.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Bounce.h>
Bounce button0 = Bounce(0, 15);
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=497,821
AudioEffectEnvelope envelope1; //xy=709,832
AudioOutputI2S audioOut; //xy=1146,858
AudioConnection patchCord1(waveform1, envelope1);
AudioConnection patchCord2(envelope1, 0, audioOut, 0);
AudioConnection patchCord3(envelope1, 0, audioOut, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=787,955
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
//Full Synth requires some serious memory
AudioMemory(10);
sgtl5000_1.enable();
// Full volume is 1.0 which will damage speakers or ears in most cases
sgtl5000_1.volume(0.4);
pinMode(0, INPUT_PULLUP);
waveform1.begin(0.6, 440, WAVEFORM_TRIANGLE);
envelope1.attack(250);
envelope1.decay(350);
envelope1.sustain(0.6);
envelope1.release(350);
}
void loop() {
button0.update();
float knob1 = (float)analogRead(A9) / 1023.0;
waveform1.frequency(1650 * knob1 + 0.25);
if (button0.fallingEdge()) {
envelope1.noteOn();
}
if (button0.risingEdge()) {
envelope1.noteOff();
}
}