Hello guys,
I have some issues with sampling the I2S microphone ( without the shield ) by T4.1.
The microphone that I'm using is:
The pin is connected:
mic board -> T4.1
WCLK -> 20
SCLK -> 21
Data -> 8
I hade try to run the next code to sample and do fft on the signal, found the code in this forum. Not working for me. all the value i got from the code are static without changes
Can anyone guide me to the right solution?
In the first step, I want to sample this microphone and print every sample on the serial monitor.
Is there any guide for the Audio\I2S lib, I want to manage the Bclock freq and more. like sample 8 of the same mics?
Thanks
Felix
I have some issues with sampling the I2S microphone ( without the shield ) by T4.1.
The microphone that I'm using is:
The pin is connected:
mic board -> T4.1
WCLK -> 20
SCLK -> 21
Data -> 8
I hade try to run the next code to sample and do fft on the signal, found the code in this forum. Not working for me. all the value i got from the code are static without changes
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioInputI2S i2s1; //xy=139,91
AudioAnalyzeFFT1024 fft1024; //xy=467,147
// Create Audio connections between the components
//
AudioConnection c2(i2s1, 0, fft1024, 0);
// GUItool: end automatically generated code
// The scale sets how much sound is needed in each frequency range to
// show all 8 bars. Higher numbers are more sensitive.
float scale = 60.0;
// An array to hold the 16 frequency bands
float level[16];
// This array holds the on-screen levels. When the signal drops quickly,
// these are used to lower the on-screen level 1 bar per update, which
// looks more pleasing to corresponds to human sound perception.
int shown[16];
void setup() {
delay(200);
Serial.println("Start Setup");
// Audio requires memory to work.
AudioMemory(12);
//i2s1.begin();
fft1024.windowFunction(AudioWindowHanning1024);
Serial.println("End Setup");
}
void loop() {
if (fft1024.available()) {
// read the 512 FFT frequencies into 16 levels
// music is heard in octaves, but the FFT data
// is linear, so for the higher octaves, read
// many FFT bins together.
level[0] = fft1024.read(0);
level[1] = fft1024.read(1);
level[2] = fft1024.read(2, 3);
level[3] = fft1024.read(4, 6);
level[4] = fft1024.read(7, 10);
level[5] = fft1024.read(11, 15);
level[6] = fft1024.read(16, 22);
level[7] = fft1024.read(23, 32);
level[8] = fft1024.read(33, 46);
level[9] = fft1024.read(47, 66);
level[10] = fft1024.read(67, 93);
level[11] = fft1024.read(94, 131);
level[12] = fft1024.read(132, 184);
level[13] = fft1024.read(185, 257);
level[14] = fft1024.read(258, 359);
level[15] = fft1024.read(360, 511);
// See this conversation to change this to more or less than 16 log-scaled bands?
// https://forum.pjrc.com/threads/3267...-for-FFT-bin-selection-for-any-given-of-bands
// if you have the volume pot soldered to your audio shield
// uncomment this line to make it adjust the full scale signal
//scale = 8.0 + analogRead(A1) / 5.0;
for (int i=0; i<16; i++) {
Serial.print(level);
// TODO: conversion from FFT data to display bars should be
// exponentially scaled. But how keep it a simple example?
int val = level * scale;
if (val > 8) val = 8;
if (val >= shown) {
shown = val;
} else {
if (shown > 0) shown = shown - 1;
val = shown;
}
//Serial.print(shown);
Serial.print(" ");
}
Serial.println("");
}
}
Can anyone guide me to the right solution?
In the first step, I want to sample this microphone and print every sample on the serial monitor.
Is there any guide for the Audio\I2S lib, I want to manage the Bclock freq and more. like sample 8 of the same mics?
Thanks
Felix