Arduino Audio Tools (Music Player, Music Recorder supporting I2S, Microphones, DAC, ADC, A2DP, Url, MP3, AAC, AudioKit, ES8388)
Go to file
Phil Schatzmann f0f4dd8509 Broken links
2021-05-07 21:48:13 +02:00
basic-api A2DP stream support 2021-05-07 16:21:39 +02:00
docs Documentation add used Arduino Classes 2021-05-05 21:19:22 +02:00
examples Broken links 2021-05-07 21:48:13 +02:00
sandbox A2DP stream support 2021-05-07 16:21:39 +02:00
src Mozzi support 2021-05-07 20:47:56 +02:00
.DS_Store Documentation add used Arduino Classes 2021-05-05 21:19:22 +02:00
Doxyfile Documentation add used Arduino Classes 2021-05-05 21:19:22 +02:00
library.properties Rename sound to audio 2021-04-29 22:50:28 +02:00
License.txt I2S 2021-04-29 11:52:46 +02:00
README.md Broken links 2021-05-07 21:48:13 +02:00
Scenarios.md Stream support 2021-05-05 19:17:13 +02:00

Arduino Audio Tools

Some basic header-only C++ classes that can be used for Audio Processing provided as Arduino Library:

  • a simple I2S class (to read and write to the internal I2S)
  • a simple ADC class (to read analog data with the help of I2S)
  • Additional Stream implementations: MemoryStream, UrlStream, I2SStream, A2DPStream, PrintStream
  • Converters
  • Musical Notes (with frequencies of notes)
  • SineWaveGenerator (to generate a sine tone) and Mozzi for more complex scenario
  • NBuffer (Multi buffer for writing and reading of (audio) data)
  • TimerAlarmRepeating (e.g. for sampling audio data using exact times) [ESP32 only]
  • A Wav Encoder and Decoder
  • AudioOutputWithCallback class to provide callback integration e.g. with ESP8266Audio

This functionality provides the glue which makes different audio processing components and libraries work together. We also provide plenty of examples that demonstrate how to implement the different scenarios. The design philosophy is based on the Arduino conventions: we use the begin() and end() methods to start and stop the processing and we propagate the use of Streams. We all know the Arduino Streams: We use them to write out print messages and sometimes we use them to read the output from Serial devices. The same thing applies to my “Audio Streams”: You can read audio data from “Audio Sources” and you write them to “Audio Sinks”.

As “Audio Sources” we will have e.g.:

As “Audio Sinks” we will have e.g:

Here is an simple example which streams a file from the Flash Memory and writes it to I2S:

#include "AudioTools.h"
#include "StarWars30.h"

using namespace audio_tools;  

uint8_t channels = 2;
uint16_t sample_rate = 22050;

MemoryStream music(StarWars30_raw, StarWars30_raw_len);
I2SStream i2s;  // Output to I2S
StreamCopyT<int16_t> copier(i2s, music); // copies sound into i2s

void setup(){
    Serial.begin(115200);

    I2SConfig config = i2s.defaultConfig(TX_MODE);
    config.sample_rate = sample_rate;
    config.channels = channels;
    config.bits_per_sample = 16;
    i2s.begin(config);
}

void loop(){
    if (!copier.copy2()){
      i2s.end();
      stop();
    }
}

A complete list of the supported Audio Stream classes and scenarios can be found in the Scenarios Document

Examples

The examples follow the following naming convention: "scenario type"-"source"-"destination". For the scenario types we might have base (using basic api functionality), stream for examples using Streams and test for the test cases.

For the source we currently have adc for analog input devices like analog microphones, i2s for digital input devices (e.g. digital microphones), file for SD files and a2dp for input from Bluetooth A2DP (e.g. from a Mobile Phone).

For the destination we use dac for analog output (e.g. to an amplifier), i2s for digital output devices (e.g. an external DAC), file for SD files and a2dp for output to Bluetooth A2DP (e.g. a Bluetooth Speaker).

Here is the list of examples:

Stream API

Here are a couple of simple test sketches to demo different output destinations:

And some more useful examples:

... these are just a few examples, but you can combine any Input Stream with any Output Stream as you like...

Basic API

Optional Libraries

Dependent on the example you might need to install some of the following libraries:

Installation

You can download the library as zip and call include Library -> zip library. Or you can git clone this project into the Arduino libraries folder e.g. with

cd  ~/Documents/Arduino/libraries
git clone pschatzmann/arduino-audio-tools.git

Documentation

Here is the generated Class documentation.

You also might find further information in one of my blogs

Project Status

This is currently work in progress:

Functionality Status
Analog input - ADC tested
I2S tested
Files (RAW, MP3...) tested
Streams tested
WAV encoding/deconding open
AAC encoding/deconding open
int24_t tested