/8BitSynth

Libraries, programs, and hardware that convert an Arduino Mega to a four-tone wavetable synth

Primary LanguageC++

Arduino-8BitSynth

A MIDI synthesizer built for the Arduino Mega.

Features:

  • Four-tone polyphony
  • Timbre customizable with a wavetable.
  • Wavetable presets available for sine, square, and sawtooth waves.

Note that this was a personal project. Consider using more feature-rich libraries like Mozzi

Installation

To install this library, simply place it in the Libraries folder of your Arduino sketch folder location

Usage

This library contains two classes that assist in the synthesis of (audio) waveforms. Higher-level instrument creation will only need the Instrument class, but for lower-level synthesis, the SynthTimer can also be used.

SynthTimer

The synthesizers in this library rely on a wave table in the form of a byte (uint8_t) array. When synthesizing a waveform, values from the waveform are chosen periodically so that the amount of time it takes to iterate through the entire wavetable will approximately match an intended period of the wave.

SynthTimer will keep track of the current time based on the how many times its "update" function has been called, and it uses that value to compute the index of the wavetable array to output at any given time to match the waveform generated by a program to the desired frequency set with the setFrequency() or setPitch() funtions

Instrument uses four SynthTimer instances to generate a sound with up to four tones. The waveform output from the instrument is a byte (uint8_t) that can be sent to any IO register in the Arduino. Each tone can be enabled or disabled and can change pitch, however they all share the same wavetable and volume. The Instrument generates its own wavetable with the setTimber function, and changing the volume with setVolume() simply bit-shifts the output of the waveform to the right, so larger values mean more quiet sounds. A few examples on applying the Instrument library can be found the examples directory