Rich Schupbach

Audio Synthesizer

I designed the hardware and firmware for this audio synthesizer in 2001. The use of assembly language seems ancient by today’s standards. But at the time, it was common practice in our company to use assembly language targeting Atmel microcontrollers for new hardware projects. We had a well established code library and tools for this development work.

We also used C extensively for some projects, but when working with an 8-bit micro with very limited resources (i.e. only 8kB of flash, and 256 bytes of RAM), it was critical to be as efficient as possible. In this environment, writing assembly code offered many advantages.

Advantages of Using Assembly Language

Pricise Hardware Control
Speed and Performance Optimization
Deterministic Behavior
Smaller Code Size

Hardware

Below is an image of the hardware. Features include:

  • Supports tunes 1-255
  • Four output channels, with independent local volume control
  • Remote tune selection via serial communication
  • Remote volume control via serial communication
  • RS485 serial communication
  • Numeric display of currently playing tune number
  • In-circuit reprogramming capability
Pricise Hardware Control

Schematic

The schematic was created using Protel schematic capture (later acquired by Altium). Below is a screenshot of one page of the schematic. A complete PDF of the schematic is available at the GitHub link below.

Pricise Hardware Control

GitHub

As development of this project pre-dates GitHub, the following repo is used for sharing purposes only. It is not a development repo.

GitHub

How to get decent audio from a simple 8-bit micro

The hardware design makes use of a multi-stage passive RC low-pass filter (illustrated below), to convert the square wave output of the micro into a sinusoidal wave, useful for output to a speaker and/or amplifier.

Pricise Hardware Control

It is important to understand that you may use Fourier synthesis to create a square wave from a sinusoidal base. This is a process of adding together sine waves of specific frequencies and amplitudes. Conversely you can extract a sinusoid from a square wave by filtering harmonics of the fundamental sinusoid.

Pricise Hardware Control
Pricise Hardware Control
Pricise Hardware Control
Pricise Hardware Control
Pricise Hardware Control

Firmware

As mentioned previously, we had an extensive assembly code library to draw on for serial communication and 7-segment displays, but the audio portion of the code is completely original and of my own design.

The microcontroller code produces a square wave output at the desired frequency. That square wave is then converted to a sinusoidal wave (by hardware illustrated above), which is suitable for audio output to an amplifier and/or speaker.

This is the code for a particular tune. The data consists of:

  • The number of notes in the tune
  • A list of value and duration, for each note
Pricise Hardware Control

The algorithm uses a timer overflow to determine when to toggle the audio output. Knowing the oscillator frequency of the micro is 11.0592 MHz, I calculated the precise timer value to generate 4 octaves of 12 notes each, as detailed in the assembly code below.

Pricise Hardware Control

The entire source code is available at the GitHub link above.

Pricise Hardware Control
Pricise Hardware Control
Pricise Hardware Control
Pricise Hardware Control