Adafruit Library
Adafruit_CPlay_Mic.h
1 // Adafruit Circuit Playground microphone library
2 // by Phil Burgess / Paint Your Dragon.
3 // Fast Fourier transform section is derived from
4 // ELM-ChaN FFT library (see comments in ffft.S).
5 
6 #ifndef ADAFRUIT_CPLAY_MIC_H
7 #define ADAFRUIT_CPLAY_MIC_H
8 
9 #ifdef __GNUC__
10  #define DEPRECATED(func) func __attribute__ ((deprecated))
11 #elif defined(_MSC_VER)
12  #define DEPRECATED(func) __declspec(deprecated) func
13 #else
14  #pragma message("WARNING: You need to implement DEPRECATED for this compiler")
15  #define DEPRECATED(func) func
16 #endif
17 
18 #include "Adafruit_ZeroPDM.h"
19 
20 
21 /**************************************************************************/
25 /**************************************************************************/
27  public:
28  Adafruit_CPlay_Mic(void) {}; // Empty constructor
29  int peak(uint16_t ms) __attribute__ ((deprecated));
30  void capture(int16_t *buf, uint16_t nSamples),
31  fft(uint16_t *spectrum);
32 
33  float soundPressureLevel(uint16_t ms);
34 
35 private:
36 #if defined(ARDUINO_ARCH_SAMD)
37  static Adafruit_ZeroPDM pdm;
38 #endif
39 };
40 
41 #endif // ADAFRUIT_CPLAY_MIC_H
Class that stores state and functions for the microphone on CircuitPlayground boards.
Definition: Adafruit_CPlay_Mic.h:26
void capture(int16_t *buf, uint16_t nSamples)
capture the passed number of samples and place them in buf.
Definition: Adafruit_CPlay_Mic.cpp:86
int peak(uint16_t ms) __attribute__((deprecated))
Reads ADC for given interval (in milliseconds, 1-65535). Uses ADC free-run mode w/polling on AVR...
Definition: Adafruit_CPlay_Mic.cpp:66
void fft(uint16_t *spectrum)
AVR ONLY: Performs one cycle of fast Fourier transform (FFT) with audio captured from mic on A4...
Definition: Adafruit_CPlay_Mic.cpp:286
float soundPressureLevel(uint16_t ms)
Returns somewhat-calibrated sound pressure level.
Definition: Adafruit_CPlay_Mic.cpp:203