Skip to content

todbot/mozzi_experiments

Repository files navigation

mozzi_experiments

Experiments with Mozzi, mostly on SAMD21- and RP2040-based boards

Sketches

Demos

How to install Mozzi

Mozzi 2 is now in the Arduino Library Manager! And it's much easier to configure. To install Mozzi, find it in the Arduino Library Manager and install it and its dependencies.

Configuring Mozzi

You can now configure Mozzi in your sketch intead of editing Mozzi library files.

The hardware configuration section of the Mozzi docs is very helpful.

The pattern is that you put this at the top of your sketch:

#include "MozziConfigValues.h"  // for named option values
// your system-specific configuration defines, including MOZZI_CONTROL_RATE
#include "Mozzi.h"

The configs I've used so far. Some of these configs are the defaults but I like to be explicit.

  • SAMD21 boards using DAC on A0 as output:

    #include "MozziConfigValues.h"  // for named option values
    #define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_NONE
    #define MOZZI_CONTROL_RATE 128 // mozzi rate for updateControl()
    #include "Mozzi.h"
  • RP2040 boards (including Raspberry Pi Pico) using PWM audio out:

    #include "MozziConfigValues.h"  // for named option values
    #define MOZZI_OUTPUT_MODE MOZZI_OUTPUT_PWM
    #define MOZZI_ANALOG_READ MOZZI_ANALOG_READ_NONE
    #define MOZZI_AUDIO_PIN_1 0  // GPIO pin number, can be any pin
    #define MOZZI_AUDIO_RATE 32768
    #define MOZZI_CONTROL_RATE 128 // mozzi rate for updateControl()
    #include "Mozzi.h"
  • RP2040 boards using I2S DAC audio out:

    #include "MozziConfigValues.h"  // for named option values
    #define MOZZI_AUDIO_MODE MOZZI_OUTPUT_I2S_DAC
    #define MOZZI_AUDIO_CHANNELS MOZZI_STEREO 
    #define MOZZI_AUDIO_BITS 16
    #define MOZZI_AUDIO_RATE 32768
    #define MOZZI_I2S_PIN_BCK 20
    #define MOZZI_I2S_PIN_WS (MOZZI_I2S_PIN_BCK+1) // HAS TO BE NEXT TO pBCLK, i.e. default is 21
    #define MOZZI_I2S_PIN_DATA 22
    #define MOZZI_CONTROL_RATE 128 // mozzi rate for updateControl()
    #include "Mozzi.h"

Using Mozzi

  • Mozzi is very particular about what is in loop(). Do not put anything else in there. Instead put it in the void updateControl() function. See the sketches for examples.

Any questions?

Open up an issue on this repo or contact me on @todbot@mastodon.social!

About

Experiments with Mozzi, mostly on SAMD21 & RP2040 chips

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages