libETG

Zi Chen

Advisor: Sharleen Smith

The libETG and it’s ice cream truck demo invokes the memory and happiness of childhood. Where we play in the summer and run back to our parents for money when we hear the ice cream truck music. I wish to enable people to reexprience those memories by creating their own ice cream truck music.

Project Website Presentation
A 3D-printed ice cream truck model on a laptop running KiCAD EDA.

Project Description

Embedded Tone Generator (libETG) is a lightweight C library designed for generating melodies and sound effects on microcontrollers. It serves as an enhanced alternative to the Arduino tone() function, offering superior sound quality with support for two independent channels. Each channel provides precise control over pitch, volume, and envelope modulation, along with the ability to play back voice clips.

The library operates without interrupting other processes, making it ideal for applications requiring background audio, such as games, interactive devices, or embedded systems. It is compatible with STM32F1, APM32F1, CH32F1, and CKS32F1 microcontrollers and can be adapted for a wide range of uses, including consumer electronics, home appliances, and creative projects.

LibETG title with a PCB and text ETG on it.

Technical Details

libETG is an STM32 library designed to emulate the sound of legacy melody chips that were discontinued around the year 2000. The library utilizes three timers: Timer A, Timer B, and Timer P.

Timer A functions as the metronome timer, governing the rhythm and timing of playback.

Timer B handles software-based audio synthesis and mixing, operating at approximately 30kHz.

Timer P drives the PWM output at around 65kHz, ensuring high-quality audio generation.

The library features two square wave oscillators (Oscillator 0 and Oscillator 1), each equipped with an envelope-controlled amplifier for dynamic sound shaping. Additionally, Oscillator 0 supports PCM-based speech synthesis, with speech data stored in ROM and melody data streamed from RAM.

Research/Context

https://archive.org/details/ht-3894-a