Other
ArduinoSound
Arduino <info@arduino.cc>
[EXPERIMENTAL] A simple way to play and analyze audio data using Arduino.
Currently only supports SAMD21 boards and I2S audio devices.
Go to repositoryArduino Sound Library
This library provides simple way to play and analyze audio data using Arduino on SAMD21 based boards using the I2S bus.
To use this library:
1#include <ArduinoSound.h>
amplitudeAnalyzer.input()`
Description
Set the input of the analyzer.
Syntax
1amplitudeAnalyzer.input(in);
Parameters
in: input to analyze (type AudioIn)
Returns
0 on failure, 1 on success
Example
1/*2 This example reads audio data from an InvenSense ICS-43432 I2S microphone3 breakout board, and prints out the amplitude to the Serial Monitor. The4 Serial Plotter built into the Arduino IDE (Tools -> Serial Plotter) can be5 used to plot the audio amplitude data.6
7 Circuit:8 * Arduino Zero, MKR Zero or MKR1000 board9 * ICS-43432:10 * GND connected GND11 * 3.3V connected 3.3V (Zero) or VCC (MKR1000, MKR Zero)12 * WS connected to pin 0 (Zero) or pin 3 (MKR1000, MKR Zero)13 * CLK connected to pin 1 (Zero) or pin 2 (MKR1000, MKR Zero)14 * SD connected to pin 9 (Zero) or pin A6 (MKR1000, MKR Zero)15
16 created 23 November 201617 by Sandeep Mistry18 */19
20#include <ArduinoSound.h>21
22// create an amplitude analyzer to be used with the I2S input23AmplitudeAnalyzer amplitudeAnalyzer;24
25void setup() {26 // Open serial communications and wait for port to open:27 // A baud rate of 115200 is used instead of 9600 for a faster data rate28 // on non-native USB ports29 Serial.begin(115200);30 while (!Serial) {31 ; // wait for serial port to connect. Needed for native USB port only32 }33
34 // setup the I2S audio input for 44.1 kHz with 32-bits per sample35 if (!AudioInI2S.begin(44100, 32)) {36 Serial.println("Failed to initialize I2S input!");37 while (1); // do nothing38 }39
40 // configure the I2S input as the input for the amplitude analyzer41 if (!amplitudeAnalyzer.input(AudioInI2S)) {42 Serial.println("Failed to set amplitude analyzer input!");43 while (1); // do nothing44 }45}46
47[Read more](https://github.com/arduino-libraries/ArduinoSound)48
49export const _frontmatter = {}
amplitudeAnalyzer.available()
amplitudeAnalyzer.read()