Category Archives: Source Code

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 | 22 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 | 43 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 | 19 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 | 52 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 | 15 Comments