Code:
///////////////////////////////////
// copy the Design Tool code here
///////////////////////////////////
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveformSine sine2; //xy=585,367
AudioSynthWaveformSine sine1; //xy=606,308
AudioMixer4 mixer1; //xy=794,343
AudioOutputI2S i2s1; //xy=981,350
AudioConnection patchCord1(sine2, 0, mixer1, 1);
AudioConnection patchCord2(sine1, 0, mixer1, 0);
AudioConnection patchCord3(mixer1, 0, i2s1, 0);
AudioConnection patchCord4(mixer1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=866,505
// GUItool: end automatically generated code
void setup() {
Serial.begin(9600);
AudioMemory(20);
sgtl5000_1.enable();
sgtl5000_1.volume(0.32);
sine1.frequency(200);
sine1.amplitude(0.5);
sine2.frequency(200);
sine2.amplitude(0.5);
}
float in, out = 0;
void loop() {
if (in > 6.283){in=0;}
else{in = in + 0.01;}
out = sin(in) *0.5 + 0.5 ;
Serial.println(out);
// sine1.amplitude(out); // why does my volume not vary when this or the next line are active?
mixer1.gain(0, out);
mixer1.gain(1, 0.0);
mixer1.gain(2, 0.0);
mixer1.gain(3, 0.0);
delay(100);
}
All I'm trying to do is vary a sine waves volume over time, but I get no change in volume, I've also tried without the mixer, to no avail. What basic concept am I missing here!?
Serial monitor says I've a value varying between 0-1, at 0 it cuts out, is the float out of range?
Just using a Teensy3.2+shield at the moment.