A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/sensorium/Mozzi/tree/1.1.2 below:

GitHub - sensorium/Mozzi at 1.1.2

sound synthesis library for Arduino

Tim Barrass

Currently your Arduino can only beep like a microwave oven. 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.

You can use Mozzi to generate algorithmic music for an installation or performance, or make interactive sonifications of sensors, on a small, modular and super cheap Arduino, without the need for additional shields, message passing or external synths.

Use the "code" button on Mozzi's Github page to download a ZIP file of the latest developing code. Import this into Arduino, following the instructions from the Arduino libraries guide.

In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library. At the top of the drop down list, select the option to "Add .ZIP Library".

(Note: the files in the "releases" section on Github are now legacy. The development code is recommended.)

To hear Mozzi, connect a 3.5mm audio jack with the centre wire to the PWM output on Digital Pin 9 on the Arduino, and the ground to the Ground on the Arduino. Use this as a line out which you can plug into your computer and listen to with a sound program like Audacity. Try some examples from the File > Examples > Mozzi menu.

Below is a list of the Digital Pins used by Mozzi for STANDARD_PLUS mode PWM audio out on different boards. Feedback about others is welcome.

Model Pin Tested Arduino Uno 9 yes Arduino Uno R4 A0 yes Arduino Duemilanove 9 yes Arduino Nano 9 yes Arduino Nano 33 Iot A0 yes Arduino Pro Mini 9 yes Arduino Leonardo 9 yes Arduino Mega 11 yes Arduino MBED (only the Giga has been tested, see "Hardware specific notes", below) A13 no Arduino Giga A13 (jack) yes Freetronics EtherMega 11 yes Ardweeny 9 yes Boarduino 9 yes Teensy 14 - Teensy2 B5 yes Teensy2++ B5(25) yes Teensy 3.0 3.1 LC 3.2 DAC/D yes Teensy 3.4, 3.5 DAC/D - Teensy 4.0 4.1 A8 yes Gemma M0 A0 yes Adafruit Playground Express Built in Speaker yes Sanguino 13 - STM32F1 maple core (see "Hardware specific notes", below) PB8 yes STM32F1 STM core (see "Hardware specific notes", below) PA8 yes STM32F4 STM core (see "Hardware specific notes", below) PA8 yes ESP8266 see details GPIO2 yes RP2040 0 yes

For details about HIFI mode, read the Mozzi core module documentation.

Here's a template for an empty Mozzi sketch:

#include <MozziGuts.h>   // at the top of your sketch

void setup() {
	startMozzi();
}

void updateControl(){
	// your control code
}

int updateAudio(){
	// your audio code which returns an int between -244 and 243
}

void loop() {
	audioHook();
}

There's a detailed example explaining the different parts here.

There's documentation in the doc folder in the Mozzi download and online.
There is practical help on the learn page on the Mozzi site.
Start or look up a topic on the users forum.
Also, feel free to submit any issues on the GitHub Mozzi site.
Look for code and usage changes here.

The timers can be made available with stopMozzi(), which stops audio interrupts, until you call startMozzi().

Tweaking Arduino for Faster Audio Code

If you need your synth to run faster on AVR architectures, Arduino versions above 1.5 can be tweaked to optimise compiled code for speed instead of small size.

Find Arduino’s platform.txt (on OSX you can find it by searching in Users/your_name/Library/Arduino15). Search and replace -Os with -O2. Save.

It’s explained more thoroughly (for Windows) here.

If you still need more speed, Arduino 1.0.5 produces slightly faster code.

Using external chips to produce the sound

External chips (DAC) can also be used on any platform which does not support natively the I2S protocol using an user defined audioOutput function. This can allow a greater audio quality over the native ways to output the sound (PWM for AVR Arduinos and STM32 and 12 bit DAC for Teensy 3.*). Examples are provided for the MCP492X DAC (12 bit on SPI) and for the (PT8211) 16 bit stereo DAC using SPI port to emulate the I2S protocol. The latter should be compatible with any DAC using I2S.

If you enjoy using Mozzi for a project, or have extended it, we would be pleased to hear about it and provide support wherever possible. Contribute suggestions, improvements and bug fixes to the Mozzi wiki on Github, or Fork it to contribute directly to future developments.

Mozzi is a development of research into Mobile Sonification in the SweatSonics project.

Contributions / Included Dependencies

Modified versions of the following libraries are included in the Mozzi download:

TimerOne library
FrequencyTimer2 library - now a fork with support for ATmega32u4 processors

Mozzi has also drawn on and been influenced by (among many others):

xorshift random number generator, George Marsaglia, (2003)
ead~.c puredata external (creb library) Copyright (c) 2000-2003 by Tom Schouten (GPL2)
AF_precision_synthesis by Adrian Freed, 2009
Resonant filter posted to musicdsp.org by Paul Kellett, and fixed point version of the filter on dave's blog of art and programming
State Variable filter pseudocode at musicdsp.org and here
Various examples from Pure Data by Miller Puckette
Practical synthesis tutorials by Andy Farnell

The situation on STM32-based boards is rather confusing, as there are several competing Arduino cores. Importantly:

Mozzi supports both of the latter, but currently not at the same level of completeness.

port by Thomas Friedrichsmeier

Compiles for and runs on a STM32F103C8T6 blue pill board, with a bunch of caveats (see below), i.e. on a board without a real DAC. Should probably run on any other board supported by Roger Clark's libmaple-based core (although this theory is untested).

NOTE that at the time of this writing, Stev Strong's slightliy more recent fork of this core does not work with Mozzi, apparently due to a bug in pwmWrite().

port by Thomas Friedrichsmeier

Tested on a STM32F103C8T6 blue pill board as well as an STM32F411CE black pill board, i.e. on sboards without a real DAC. Compiles and runs, with a bunch of caveats (see below). Should probably run on any other board supported by the STM32duino core (although this theory is untested). When trying any other board, you probably want to check the platform specific settings (see below), carefully, importantly, whether the desired output resolution is achievable, and whether the desired output pins are PWM capable.

Teensy 3.0/3.1/3.2/3.4/3.5/LC

This port is working with the latest version of Teensyduino (1.8.5) Extra libraries required for use with Teensy 3.*: These are included in the standard Teensyduino install unless you explicitly disable them

Some of the differences for Teensy 3.* which will affect users include:

port by Thomas Combriat

This port is working with the latest version of Teensyduino (1.8.5) Extra libraries required for use with Teensy 4.*: These are included in the standard Teensyduino install unless you explicitly disable them

Some of the differences for Teensy 4.*:

SAMD21 architecture (Arduino Circuitplayground M0 and others)

port by Adrian Freed

port by Thomas Friedrichsmeier

port by Dieter Vandoren and Thomas Friedrichsmeier

RP2040 (Raspberry Pi Pico)

port by Thomas Friedrichsmeier

Compiles and runs using this core. Can probably be ported to the Mbed core for RP2040, relatively easily, as it relies mostly on the RP2040 SDK API. Tested on a Pi Pico.

port by Thomas Friedrichsmeier & Thomas Combriat

Compiles and runs using Arduino's standard and Arduino_AdvancedAnalog libraries. This port is still experimental, testing reveals some instabilities for some configurations (in particular with USE_AUDIO_INPUT) that are under active investigations.

port by Thomas Combriat

Compiles and runs using Arduino's standard library (Renesas 0.8.7 at the time of this writing).

Mozzi is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License, which is detailed in LICENSE.txt

Disclaimer: This is a human-readable summary of (and not a substitute for) the license.

You are free to:

The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4