Hi
I am trying to use the teensy 3.6 to control some on board audio. but i am having problems getting the audio output to work. I have even tried the example code from this video - which is just making a simple ramp TEENSY-Synth PART 1: BUILD IT - YouTube and there is no audio coming out either
my code is below. I am using the teensy audio shield, i was just trying to use the DAC and the corresponding pins -but now with no sound i thought i would try the audio shield.
below is my code. Any help would be greatly appreciated
I am using a custom made sensor that I am wanting to control the sound, i'm scaling and smoothing the input and i can see that working in the serial monitor - just no sound is coming out
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioSynthWaveform waveform1; //xy=242,258
AudioOutputI2S i2s1; //xy=546,380
AudioConnection patchCord1(waveform1, 0, i2s1, 1);
AudioConnection patchCord2(waveform1, 0, i2s1, 0);
AudioControlSGTL5000 sgtl5000_1; //xy=820,60
// GUItool: end automatically generated code
// set up pot
const int STRETCH = 14;
// Define the number of samples to keep track of. The higher the number, the
// more the readings will be smoothed, but the slower the output will respond to
// the input. Using a constant rather than a normal variable lets us use this
// value to determine the size of the readings array.
const int numReadings = 100;
int readings[numReadings]; // the readings from the analog input
int readIndex = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
int inputPin = A0;//currently stretch
void setup() {
Serial.begin(9600);
AudioMemory(20); // Dynamic memory is allocated to be used exclusively by the Audio library
sgtl5000_1.enable();
sgtl5000_1.volume(0.6);
waveform1.begin(WAVEFORM_SINE);
waveform1.amplitude(0.75);
waveform1.frequency(50);
waveform1.pulseWidth(0.15);
// initialize serial communication with computer:
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++) {
readings[thisReading] = 0;
}
}
void loop() {
// subtract the last reading:
total = total - readings[readIndex];
// read from the sensor:
readings[readIndex] = analogRead(inputPin);
// add the reading to the total:
total = total + readings[readIndex];
// advance to the next position in the array:
readIndex = readIndex + 1;
// if we're at the end of the array...
if (readIndex >= numReadings) {
// ...wrap around to the beginning:
readIndex = 0;
}
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
delay(1); // delay in between reads for stability
int potValue = average;
float scaledPot = (float)potValue / 5 ;
Serial.println(scaledPot);
waveform1.frequency(scaledPot);
// bitcrusher1.bits(scaledPotTwo);
}