ClassyBoots
New member
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioSynthWaveformSine sine1;
AudioOutputI2S i2s1;
AudioInputAnalog adc1;
AudioAnalyzeFFT1024 fft;
AudioConnection patchCord1(fft, adc1);
AudioConnection patchCord2(sine1, i2s1);
AudioControlSGTL5000 audioShield;
const int freq_range = 32768;
const int bins = 1024;
const int bin_width = freq_range/bins;
double mag[bins];
void setup() {
// put your setup code here, to run once:;
analogReadResolution(12);
AudioMemory(40);
audioShield.enable();
audioShield.inputSelect(AUDIO_INPUT_MIC);;
audioShield.micGain(63);
audioShield.volume(2);
fft.windowFunction(AudioWindowHanning1024);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=0; i<(bins/2); i++)
{
mag=fft.read(i);
Serial.println(mag, 1);
}
sine1.frequency(500);
sine1.amplitude(0.95);
delay(1000);
}
I am playing a sine wave with a 500Hz frequency, and that is working but the input settings for the microphone seem to be wrong. I am using a Teensy 4.1 with audio board revision D. The speaker is connected via an amplifier to the 3.5mm jack and the mic is soldered to the mic and gnd labeled holes. I have also tried to set the mic up the same way as the speaker with i2s2 instead of adc1. Looked for the last couple hours through the Audio Projects listed to see their setups but wasn't able to get a working reading. Probably something stupid on my end
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioSynthWaveformSine sine1;
AudioOutputI2S i2s1;
AudioInputAnalog adc1;
AudioAnalyzeFFT1024 fft;
AudioConnection patchCord1(fft, adc1);
AudioConnection patchCord2(sine1, i2s1);
AudioControlSGTL5000 audioShield;
const int freq_range = 32768;
const int bins = 1024;
const int bin_width = freq_range/bins;
double mag[bins];
void setup() {
// put your setup code here, to run once:;
analogReadResolution(12);
AudioMemory(40);
audioShield.enable();
audioShield.inputSelect(AUDIO_INPUT_MIC);;
audioShield.micGain(63);
audioShield.volume(2);
fft.windowFunction(AudioWindowHanning1024);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
for(int i=0; i<(bins/2); i++)
{
mag=fft.read(i);
Serial.println(mag, 1);
}
sine1.frequency(500);
sine1.amplitude(0.95);
delay(1000);
}
I am playing a sine wave with a 500Hz frequency, and that is working but the input settings for the microphone seem to be wrong. I am using a Teensy 4.1 with audio board revision D. The speaker is connected via an amplifier to the 3.5mm jack and the mic is soldered to the mic and gnd labeled holes. I have also tried to set the mic up the same way as the speaker with i2s2 instead of adc1. Looked for the last couple hours through the Audio Projects listed to see their setups but wasn't able to get a working reading. Probably something stupid on my end