Code Monkey home page Code Monkey logo

usynth's Introduction

usynth

License: MIT Donate

A scalable, polyphonic 8-bit AVR synthesizer employing wavetable synthesis - a summer project that exceeded my expectations.

Features:

  • PPG Wave 2.2 wavetables
  • 2 wavetable oscillators - independent voices or a single richer one
  • 2 ASR envelope generators per voice - gain, pitch and waveform modulation
  • 1 LFO per voice - triangle or square, with fade, provides pitch and waveform modulation
  • Cluster operation to provide greater polyphony (this hasn't been tested yet, but is already implemented in the source code and should work™)
  • 1-pole lowpass filter
  • All parameters can be adjusted as MIDI controllers
  • Presets stored in flash memory
  • MIDI pitch bend support
  • MIDI velocity sensitivity

MIDI controller mappings can be found here. If you're on Linux, you can load that file directly into midictl and use it to control µsynth right away.

If you want to build your own µsynth, the schematic is available in the hw directory.

See demo on YouTube:
Demo

A bit of technical background

The microcontroller is running at 20MHz (max allowed frequency at 5V). By default it's programmed to work with MCP4921 - a 12-bit SPI DAC and output samples at frequency of 28kHz. MIDI commands are received via UART0 at 31250 baud. Pins PD2, PD3 and PD4 are meant to drive status LEDs. I won't go into much detail here, because I think the source code is documented quite well.

The code is written mostly in C. There are some bits in the AVR assembly language responsible for more sophisticated multiplication, but that's it. The chip is utilized pretty well with ~99% flash and ~77% RAM usage.

The main loop is synced with timer interrupt and generates one sample per iteration. Since there are too many parameters to update all of them every sample, this work is distributed evenly accross each 21 samples. Splitting all the 'slow' code into equal pieces can be quite tricky to get right, but is definitely worth it, since it allows maximal processor time utilization.

Perhaps the most interesting bit is the synthesis process itself. The µC has waveform and wavetable data stored in flash in the same way as they were in PPG Wave (see here). Since the AtMega328 doesn't have enough RAM to hold all the interpolated waveforms at once, everything has to be computed on the fly. In fact, I've already described this process on my blog, so I'll just refer you there.

The block diagram below represents simplified structure of a single voice. The 2 voices can be used independently or combined as a single richer one.

Donate

If you like µsynth and want to support my future projects, you can buy me a cup of coffee below. It will be very appreciated :)

Donate

Thanks! ❤️

usynth's People

Contributors

jacajack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

usynth's Issues

Program to big

Hi there,

I just built your nice project but while compiling I get the message:

Program: 35206 bytes (107.4% Full)

and while flashing to the atmega I get:

ERROR: section ".text" does not fit into "flash" memory:
0x0 + 35174 > 32768

Am I doing something wrong? Hope you can help. Would love to test this litte synth :-)

Best wishes
Keen

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.