• This repository has been archived on 01/Apr/2024
  • Stars
    star
    155
  • Rank 240,864 (Top 5 %)
  • Language
    C
  • License
    GNU General Publi...
  • Created about 3 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Arduino ADF/Audiokit HAL (support for ESP32-A1S, AI-Thinker, LyraT for ES7148, ES7210, ES7243, ES8311, ES8347, ES8388, TAS5805M, AC101 audio chips)

Arduino ADF/AudioKit HAL

There are different ESP32 Audio boards available that can be programmed with the Espressif ADF Framework.

Audio Kit

The ADF Framework contains an abstraction layer to support different codec audio chips (ES8388, ES8311, AC101...) which need to be configured usually via I2C.

Unfortunately ADF can not be used in Arduino, but it would be quite useful to have this functionality also available.

Because I wanted to have a proper support of the AudioKit for my Arduino Audio Tools library and since my Audio Tools are header only, I decided to provide this functionality in a separate project.

I converted the audio_boards and their related drivers into an Arduino Library and provide an easy to use C++ class which configures both the CODEC and I2S. I also tried to abstract away all ESP32 specific funcationality.

The following functionality is supported

  • management of different audio codec (starting, stopping, setting volume etc)
  • optional I2S output (ESP32 only)
  • optional SD support via SPI
  • information about board specific pins

So with this project it should now get quite easy to use these boards also in Arduino.

Configuration

You must define your board and the default settings in the libraries/arduino-audiokit/src/AudioKitSettings.h file. Please note that the functionlity will not work properly if this is done in the Sketch.

 * @brief AUDIOKIT_BOARD selects a specic board:
 * 1) lyrat_v4_3
 * 2) lyrat_v4_2 - DRAFT Not Tested
 * 3) lyrat_mini_v1_1 - DRAFT Not Tested
 * 4) esp32_s2_kaluga_1_v1_2 - DRAFT Not Tested
 * 5) ai_thinker (ES8388) 2957 3478 A149 2762
 * 6) ai_thinker (AC101) 2762 2957
 * 7) ai_thinker (ES8388) 2957
 * 8) esp32_s3_box DRAFT Not Tested
 * 9) esp32_s3_box_lite.h DRAFT Not Tested
 * 10) generic_es8388
 * 11) generic_es8311
 */

#define AUDIOKIT_BOARD 1

Here the lyrat v4.3 has been selected. Further information can be found in the Wiki

Unfortunately AI Thinker created a big mess with their boards using different Audio chips and pin assingments, all of them using the same version number. You might need to make an educated guess by looking at the number after the version and if you have a 2957 board, you need to check all 3 options!

Example Sketch

Here is an example sketch that writes audio data to the audio kit board via I2S. By default I2S is set up as master and the codec as slave, the sample size is 16 bits and the sample rate is 44.1k/sec - if you did not change the default settings.

You can adjust these parameters by setting your requested values in the cfg below:

#include "AudioKitHAL.h"
#include "SineWaveGenerator.h"

AudioKit kit;
SineWaveGenerator wave;
const int BUFFER_SIZE = 1024;
uint8_t buffer[BUFFER_SIZE];

void setup() {
  Serial.begin(115200);
  // open in write mode
  auto cfg = kit.defaultConfig(KitOutput);
  cfg.sample_rate = AUDIO_HAL_22K_SAMPLES;
  kit.begin(cfg);

  // 1000 hz
  wave.setFrequency(1000);
  wave.setSampleRate(cfg.sampleRate());
}

void loop() {
  size_t l = wave.read(buffer, BUFFER_SIZE);
  kit.write(buffer, l);
}

However I recommend to use my Arduino Audio Tools Library which implements an easy to use Stream API with additional functionality on top of this and it has plenty of examples.

You can also use this functionality just to set up the codec chip w/o doing any input or output. In this case you can set cfg.is_i2s_active = false;

Logging

The functionality has a built in logger. The default log level has been set to Warning. You can change it like this:

  LOGLEVEL_AUDIOKIT = AudioKitDebug; // or AudiKitInfo, AudioKitWarning, AudioKitError

Documentation

Here is the documentaion of the AudioKit class.

Further information can be found in the Wiki and my Blogs.

Support

I spent a lot of time to provide a comprehensive and complete documentation. So please read the documentation first and check the issues and discussions before posting any new ones on Github.

Open issues only for bugs and if it is not a bug, use a discussion: Provide enough information about

  • the selected scenario/sketch
  • what exactly you are trying to do
  • your hardware
  • your software versions
  • what exactly your problem is

to enable others to understand and reproduce your issue.

Finally, don't send me any e-mails or post questions on my personal website!

Installation in Arduino

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 https://github.com/pschatzmann/arduino-audiokit.git

If you want to use the library in PlatformIO, you can find a detailed description in the Wiki.

Supported Devices / Processors

The examples have been tested with a AI Thinker v2.2: both versions - the one with the ES8388 and the other with the AC101. I also tested with a LyraT. I do not own any other AudioKit devices, so I can't guarantee that they work properly. I also made sure that the code is compiling on other processors, but I did not perform any tests. Please note that in this case because I2S is not standardized in Arduino, you need to take care of the I2S initialization and processing yourself on non ESP32 boards.

More Repositories

1

ESP32-A2DP

A Simple ESP32 Bluetooth A2DP Library (to implement a Music Receiver or Sender) that supports Arduino, PlatformIO and Espressif IDF
C++
1,599
star
2

arduino-audio-tools

Arduino Audio Tools (a powerful Audio library not only for Arduino)
C
1,400
star
3

logic-analyzer

Arduino Logic Analyzer API supporting the SUMP protocol (for sigrok, pulseview)
C++
106
star
4

arduino-libhelix

A simple MP3 and AAC Decoder (not only) for Arduino based on libhelix
C
68
star
5

pico-arduino

Arduino API Library for the Raspberry Pico
C
62
star
6

arduino-audio-driver

Flexible driver library for audio boards and codec chips e.g AC101 ES8388 ES8311 CS43l22 ES7243 etc
C
57
star
7

esp32_radio

Web Radio Player which is also working with a ESP32 Micro Controller
Vue
46
star
8

arduino-stk

The Synthesis ToolKit in C++ (STK) Library for Arduino
C++
42
star
9

arduino-snapclient

Snapcast client for Arduino
C++
37
star
10

Arduino-Emulator

A simple Arduino Emulator that can be used in Windows, Linux or OS/X
C++
34
star
11

arduino-midi

Midi support for Arduino (Midi over Serial, Bluetooth, BLE and TCP/IP, Apple MIDI)
C
26
star
12

arduino-flite

A small fast portable speech synthesis system
C
25
star
13

esp32_vue_example

C++
24
star
14

arduino-espeak-ng

eSpeak NG is an open source speech synthesizer that supports more than hundred languages and accents.
C
22
star
15

arduino-vs1053

An Arduino library for VS1053, VS1003 Codec Breakout Boards
C++
21
star
16

rp2040-i2s

Work in progress...
C
20
star
17

arduino-liblame

A simple mp3 encoder (not only) for Arduino using LAME
C
20
star
18

arduino-SAM

Software Automatic Mouth - Tiny Speech Synthesizer
C
20
star
19

arduino-libmad

A simple mp3 decoder (not only) for Arduino using libmad
C
19
star
20

stm32-i2s

I2S Arduino Library for STM32 Microcontrollers
C++
19
star
21

arduino-fdk-aac

A simple AAC Encoder and Decoder library (not only) for Arduino
C++
18
star
22

ArduinoMavlinkDrone

A Simple Arduino Mavlink Drone Library e.g. to implement a RC airplane which uses QGroundControl as Remote Controller.
C
18
star
23

arduino-libopus

The Opus Codec for Arduino
C
17
star
24

jupyterlab-viewer-3d

A JupyterLab extension for rendering 3d files (stl, amf, obj, 3mf, gcode, collada)
TypeScript
13
star
25

arduino-simple-tts

A simple TTS solution based on pre-recorded audio
C
13
star
26

TinyHttp

Arduino Http Server
C++
13
star
27

jupyter-openscad-kernel

Jupyter kernel for OpenSCAD
Python
11
star
28

arduino-libsbc

sbc codec library for Arduino
C
11
star
29

SIDPlayer

Playing Commodore 64 SID Audio on Arduino
C
10
star
30

SpektrumSatellite

Spektrum Satellite protocol for Arduino
C++
10
star
31

TinyFTPClient

Remote Files - A simple Arduino FTP client library (for all architectures)
C++
9
star
32

arduino-libflac

libflac codec library for Arduino
C
7
star
33

arduino-freertos-addons

Additions to FreeRTOS: C++ API
C++
7
star
34

arduino-libvorbis-tremor

Vorbis decoder
C
7
star
35

adpcm

Lean ADPCM codec implementation from FFMpeg
C
7
star
36

smart-EDGAR

EDGAR XBRL Processing
HTML
6
star
37

Investor

Easy to use Java Library to implement and evaluate automatic stock trading strategies.
Java
5
star
38

stm32f411-adc

Arduino library for stm32f411 providing ADC via DMA
C++
5
star
39

idf-example-a2dp

Demo which shows how to use the ESP-A2DP library as component in IDF
CMake
4
star
40

openscad-models

OpenSCAD
4
star
41

arduino-midi-fileparser

A simple MIDI file parser library
C
4
star
42

docker-beakerx-lab

Dockerfile for Jupyter Lab with BeakerX kernel
Dockerfile
4
star
43

arduino-fatfs

Work in progress...
C++
4
star
44

arduino-libfaad

Freeware Advanced Audio (AAC) Decoder including SBR decoding
C
4
star
45

arduino-posix-fs

Arduino Posix API for data in PROGMEM - used by espeak-ng
C++
3
star
46

docker-cron

Docker file for time based batch processor which is driven by docker labels using cron syntax
Dockerfile
3
star
47

tinyusb-cpp

A simple C++ extension for TinyUSB
C++
3
star
48

arduino-libg7xx

Reference implementations of the CCITT G.711, G.721 and G.723 voice compressions
C
3
star
49

stm32h7-arduino

Introduction to STM32H743VIT6 using Arduino
C
3
star
50

jupyterlab-openscad-syntax-highlighting

Syntax-Highlighting for OpenSCAD in Jupyterab
JavaScript
2
star
51

RP2040-A2DP

Work in progress..
C++
2
star
52

arduino-dlna

Work in progress
C
2
star
53

docker-data-science

Jupyter Lab with BeakerX kernel including the most important data science libraries
Dockerfile
2
star
54

arduino-lcd

LCD library
C++
2
star
55

jflightcontroller4pi

Simple flight controller for airplanes implemented in Java - for the Raspberry PI (zero)
Java
2
star
56

docker-flume

Dockerfile for apache flume log consolidator on Alpine
1
star
57

docker-websvn

Dockerfile for websvn on Alpine
PHP
1
star
58

docker-h2o

Docker File for H2O.ai
Dockerfile
1
star
59

docker-jenkins

Dockerfile for jenkins on Alpine
1
star
60

docker-svnserve

Docker file for subversion server on Alpine
Dockerfile
1
star
61

scad4j

OpenSCAD generator API for the JDK
Java
1
star
62

docker-cron-impl

Implementation of docker-cron scheduler
JavaScript
1
star
63

Resources

Jupyter Notebook
1
star
64

news-digest

News-Digest: Accessing the History of News Headlinesยถ
Java
1
star
65

SmartEdgar-Blogs

Jupyter Workbooks using the Smart-EDGAR project
Jupyter Notebook
1
star
66

Investor-ml

Extension for Investor for deeplearning4j
Java
1
star
67

Investor-Blogs

Jupyter Notebooks for the Investor Framework in Scala
Jupyter Notebook
1
star
68

Arduino-Emulator-Target

C++
1
star
69

arduino-libilbc

Arduino iLBC Speech Codec
C
1
star