Other

ArduinoSound

[EXPERIMENTAL] A simple way to play and analyze audio data using Arduino.

Currently only supports SAMD21 boards and I2S audio devices.

Go to repository

Arduino 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 microphone
3 breakout board, and prints out the amplitude to the Serial Monitor. The
4 Serial Plotter built into the Arduino IDE (Tools -> Serial Plotter) can be
5 used to plot the audio amplitude data.
6
7 Circuit:
8 * Arduino Zero, MKR Zero or MKR1000 board
9 * ICS-43432:
10 * GND connected GND
11 * 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 2016
17 by Sandeep Mistry
18 */
19
20#include <ArduinoSound.h>
21
22// create an amplitude analyzer to be used with the I2S input
23AmplitudeAnalyzer 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 rate
28 // on non-native USB ports
29 Serial.begin(115200);
30 while (!Serial) {
31 ; // wait for serial port to connect. Needed for native USB port only
32 }
33
34 // setup the I2S audio input for 44.1 kHz with 32-bits per sample
35 if (!AudioInI2S.begin(44100, 32)) {
36 Serial.println("Failed to initialize I2S input!");
37 while (1); // do nothing
38 }
39
40 // configure the I2S input as the input for the amplitude analyzer
41 if (!amplitudeAnalyzer.input(AudioInI2S)) {
42 Serial.println("Failed to set amplitude analyzer input!");
43 while (1); // do nothing
44 }
45}
46
47[Read more](https://github.com/arduino-libraries/ArduinoSound)
48
49export const _frontmatter = {}

amplitudeAnalyzer.available()
amplitudeAnalyzer.read()