Skip to content

A real-time software-based audio synthesis engine written in C++.

Notifications You must be signed in to change notification settings

Ravish-Ranjan/chiptune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chiptune – A Modern C++ Real-Time Chiptune Synthesizer

C++ CMake Platform License Status

A real-time software-based audio synthesis engine written in C++.
Designed to emulate the sonic character of retro hardware such as the NES, Game Boy, and Sega Genesis, while also supporting generic 8-bit waveform modes (Classic, Square, Smooth).
The engine focuses on performance, low-level DSP accuracy, and portability.


Abstract

This project is a C++ chiptune synthesis engine that generates audio in real time using mathematical waveform generation.
It supports both hardware-inspired profiles (NES, Game Boy, Genesis) and generic modes like Square and Smooth.
The engine is built with a modular architecture powered by CMake, ensuring efficient performance and portability across platforms.


Introduction

Chiptune music originates from the real-time waveform generators of vintage consoles and computers.
Unlike sampled audio, chiptune relies on mathematically generated waveforms, filters, and modulation techniques.

This project implements:

  • Multi-style synthesis (NES, Game Boy, Sega Genesis, Square, Classic, Smooth)
  • Waveform generation from DSP math
  • Low-latency playback via audio callbacks
  • A lightweight and portable architecture, written in modern C++

The entire system avoids heavy game engines to stay close to the hardware for accuracy and speed.


Core Modules

Main Loop & Style Parser

Handles:

  • Application initialization
  • Parsing user input (e.g. genesis)
  • Mapping to an internal ChiptuneStyle enum
  • Selecting correct synthesis algorithms

Supported style keywords:

classic, nintendo, gameboy, genesis, square, smooth

Waveform Generator

Core DSP engine responsible for:

  • Generating Square, Triangle, Saw, and Noise waves
  • Emulating hardware behaviors like:
    • NES duty cycles (Ricoh 2A03-like behavior)
    • Game Boy stereo channel quirks
    • Genesis FM-inspired harmonics

Also includes pure waveform modes (Square, Smooth) that produce mathematically clean output.


Audio Callback

Provides real-time playback by:

  • Responding to audio hardware requests
  • Filling buffers with synthesized samples
  • Ensuring glitchless, low-latency output
  • Mixing channels and applying envelopes

This is the heartbeat of the entire engine.


Build Instructions

Requirements

  • C++ compiler (C++11 or later)
  • CMake
  • Platform-specific audio backend

Build

git clone https://github.com/Ravish-Ranjan/chiptune
cd chiptune
mkdir build && cd build
cmake ..
make

Run:

./chiptune <audio-file-path> <style?>

Supported Synthesis Styles

Style Mode Description
classic CLASSIC Arcade-style 8-bit tone
nintendo NINTENDO NES pulse waves + duty cycles
gameboy GAMEBOY Stereo wave-channel emulation
genesis GENESIS FM-inspired Sega Genesis tone
square SQUARE Pure, raw square wave
smooth SMOOTH Filtered, cleaner chiptune output

Default output mode: smooth


Result

Running the application produces real-time synthesized chiptune audio.
The selected style determines oscillator behavior, mixing rules, and overall timbre, giving users full control over retro sound emulation.


References


About

A real-time software-based audio synthesis engine written in C++.

Topics

Resources

Stars

Watchers

Forks