Mozzi brings your Arduino to life by allowing it to produce much more complex and interesting growls, sweeps and chorusing atmospherics. These sounds can be quickly and easily constructed from familiar synthesis units like oscillators, delays, filters and envelopes.

The AudioKit is a cheap ESP32 based audio board that usually uses an ES8388 audio chip.

Quite some time ago I was working on a Mozzi integration for my AudioTools and had it usable. But because I needed to do quite some substantial changes to Mozzi, I pretty much halted this development, because I expected that a merge would not be accepted.

If you want to use Mozzi (or any other Audio Library which outputs audio via I2S to the ESP32) with the AudioKit you still have a pretty easy way to deal with this using my AudioKitHAL library directly.

So here are the steps that are necessary:

Select Your Board

There a quite of few different variants out there with different audio chips and different pin assignments, so follow the instructions that you can find in the README of the Audiokit project to select your board!

Mozzi Configuration for the ESP32

Make sure that Mozzi is using I2S with a DAC and the correct pins. This is done in AudioConfigESP32.h by using the following settings:

 // Set output mode

// For external I2S output, only: I2S_PINS
#define ESP32_I2S_BCK_PIN 27
#define ESP32_I2S_WS_PIN 25
#define ESP32_I2S_DATA_PIN 26
// Make sure we use a sample rate supported by the AudioKit

You can determine the relevant pins for your model by consulting this table.

Using the Codec

In the sketch you need to set up the audio chip of the AudioKit: We need to provide the sample rate and tell it not to mess with I2S because this is done by Mozzi:

  // setup of AudioKit codec
  auto cfg = kit.defaultConfig(audiokit::AudioOutput);
  cfg.i2s_active = false; // deactivate I2S because this is managed by mozzi
  cfg.sample_rate = AUDIO_HAL_32K_SAMPLES;

The Complete Arduino Sketch

Here is the extended SineWave Sketch that works on an AudioKit or LyraT board:

#include <MozziGuts.h>
#include <Oscil.h> // oscillator template
#include <tables/sin2048_int8.h> // sine table for oscillator
#include "AudioKitHAL.h" // Using the AudioKit

// Setup of codec
AudioKit kit;
// use: Oscil <table_size, update_rate> oscilName (wavetable), look in .h file of table #included above

// use #define for CONTROL_RATE, not a constant
#define CONTROL_RATE 64 // Hz, powers of 2 are most reliable

void setup(){
  // setup of AudioKit codec
  auto cfg = kit.defaultConfig(audiokit::AudioOutput);
  cfg.is_i2s_active = false; // deactivate I2S because this is managed by mozzi
  cfg.sample_rate = AUDIO_HAL_32K_SAMPLES;

  startMozzi(CONTROL_RATE); // :)
  aSin.setFreq(440); // set the frequency

void updateControl(){
  // put changing controls in here

AudioOutput_t updateAudio(){
  return MonoOutput::from8Bit(; // return an int signal centred around 0

void loop(){
  audioHook(); // required here

Final Remarks: Unfortunately there are some name clashes between the AudioKit and Mozzi. Mozzi does not provide any namespace, so the sequence of the imports are important!


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *