Class that stores state and functions for the microphone on CircuitPlayground boards
Reads ADC for given interval (in milliseconds, 1-65535). Uses ADC free-run mode w/polling on AVR. Any currently-installed ADC interrupt handler will be temporarily disabled while this runs.
int Adafruit_CPlay_Mic::peak(uint16_t ms) __attribute__((deprecated))
msthe number of milliseconds to sample
int max deviation from DC_OFFSET (e.g. 0-341)
capture the passed number of samples and place them in buf.
void Adafruit_CPlay_Mic::capture(int16_t *buf, uint16_t nSamples)
- int16_t *
bufthe buffer to store the samples in
nSamplesthe number of samples to take
AVR ONLY: Performs one cycle of fast Fourier transform (FFT) with audio captured from mic on A4. Output is 32 'bins,' each covering an equal range of frequencies from 0 to 4800 Hz (i.e. 0-150 Hz, 150-300 Hz, 300-450, etc). Needs about 450 bytes free RAM to operate.
void Adafruit_CPlay_Mic::fft(uint16_t *spectrum)
- uint16_t *
spectrumthe buffer to store the results in. Must be 32 bytes in length.
Returns somewhat-calibrated sound pressure level.
float Adafruit_CPlay_Mic::soundPressureLevel(uint16_t ms)
msMilliseconds to continuously sample microphone over, 10ms is a good start.
float Floating point Sound Pressure Level, tends to range from 40-120 db SPL