Category Archives: Source Code

WaveUtils updated

WaveUtils needed only a minor change for compatibility with the WaveTableOsc update—addWaveTable changes to AddWaveTable. But I added something new while I was at it. The original wave table articles advocated minimizing the number of tables necessary—one per octave—by allowing … Continue reading

Posted in Source Code, Wavetable Oscillators | 17 Comments

WaveTableOsc optimized

The wave table oscillator developed here in 2012 is pretty lightweight, but I never took a close look at optimization at the time. An efficient design is the number one optimization, and it already had that. I was curious how … Continue reading

Posted in Source Code, Wavetable Oscillators | 6 Comments

How I write code

Next article I’ll post an update of our wave table oscillator, but first I’ll take the opportunity to discuss how I write code these days. Maybe it will help make sense of some of the choices in the code I … Continue reading

Posted in Source Code | 18 Comments

More about source code

I was admonished (in not a nice way—not terribly rude, but quite to the point that I don’t know what I’m doing) by an anonymous visitor, who concluded that I don’t know much about C++ and maybe should have written … Continue reading

Posted in Source Code | 7 Comments

Envelope generators—ADSR code

First, a brief example of how to use the ADSR code: // create ADSR env ADSR *env = new ADSR(); // initialize settings env->setAttackRate(.1 * sampleRate); // .1 second env->setDecayRate(.3 * sampleRate); env->setReleaseRate(5 * sampleRate); env->setSustainLevel(.8); … // at some … Continue reading

Posted in Envelope Generators, Source Code, Synthesizers | 62 Comments

Replicating wavetables

My WaveTableOsc object uses a series of wavetables that are copies of single-cycle waveforms pre-rendered at a progressively smaller bandwidth. By “replicating wavetables” I mean taking a full-bandwidth single cycle waveform, and using it to make a complete set of … Continue reading

Posted in Oscillators, Source Code, Wavetable Oscillators | 53 Comments

About source code examples

My goal is to teach audio DSP principles in a way that is more intuitive than most available material. And part of that goal is to help you to think about the your goals and how to solve them by … Continue reading

Posted in Source Code | 2 Comments

A one-pole filter

Here’s a very simple workhorse of DSP applications—the one-pole filter. By comparison, biquads implement two zeros and two poles. You can see that our one-pole simply discards the zeros (the feed-forward delay paths) and the second pole (feedback path): We … Continue reading

Posted in DC Blocker, Digital Audio, IIR Filters, Source Code | 40 Comments

Biquad C++ source code

I don’t want to get into the business of teaching people how to code—there are a huge number of free resources available on the internet to that do that. But I’ll give a small taste for those trying to get … Continue reading

Posted in Biquads, Digital Audio, Filters, IIR Filters, Source Code | 96 Comments

A wavetable oscillator—the code

The wavetable oscillator code follows the basic structure of most audio processing blocks, with three types of functions: at the start: initialization—create the oscillator and its wavetables as needed: control—change the oscillator frequency, and pulse width for PWM every sample: … Continue reading

Posted in Digital Audio, Oscillators, Source Code, Wavetable Oscillators | 27 Comments