Here is a video showing what I mean.
This is just a test sketch playing a waveform through an envelope ever 500ms, but I've run some of the example sketches too, and all the audio is coming out distorted. It's a fully charged li-po, and a mini speaker - which I've tested on my laptop and it works fine.
The first few beeps sound ok - although they don't quite sound like sine waves - but then it quickly becomes distorted. Sometimes it sounds different, starting off silent as soon as I turn it on, and then slowly fading into a distorted fuzzy sound with loads of white noise.
I've used Teeny boards and the audio adapter before and not had this issue. This one's been sitting in a drawer for maybe a year or more.
Here's my code:
This is just a test sketch playing a waveform through an envelope ever 500ms, but I've run some of the example sketches too, and all the audio is coming out distorted. It's a fully charged li-po, and a mini speaker - which I've tested on my laptop and it works fine.
The first few beeps sound ok - although they don't quite sound like sine waves - but then it quickly becomes distorted. Sometimes it sounds different, starting off silent as soon as I turn it on, and then slowly fading into a distorted fuzzy sound with loads of white noise.
I've used Teeny boards and the audio adapter before and not had this issue. This one's been sitting in a drawer for maybe a year or more.
Here's my code:
C++:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=225.11111450195312,1058.3331985473633
AudioEffectEnvelope envelope1; //xy=410,1053.3333358764648
AudioOutputI2S i2s1; //xy=680.1112117767334,1050.3331985473633
AudioConnection patchCord1(waveform1, envelope1);
AudioConnection patchCord2(envelope1, 0, i2s1, 0);
AudioConnection patchCord3(envelope1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=303.1111145019531,960.333251953125
// GUItool: end automatically generated code
// Timing variables
unsigned long lastTime = 0;
void setup() {
Serial.begin(9600);
AudioMemory(10);
waveform1.begin(WAVEFORM_SINE);
waveform1.frequency(262);
waveform1.amplitude(0.8);
envelope1.attack(10);
envelope1.decay(200);
envelope1.sustain(0.25);
envelope1.release(300);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
Serial.println("hi there!");
}
void loop() {
unsigned long currentTime = millis();
if (currentTime - lastTime >= 500) {
envelope1.noteOn();
lastTime = currentTime;
Serial.println("C");
}
}