Primitives for Generating Tones

Just a warning, make sure your volume isn’t too loud when playing the samples on this page.

This article is going to cover primitive wave types and generating simple versions of their functions. These primitives waves are just building blocks. Most audio is not primitive waves but more complex forms of sound – but we’ll save that for another day.

Sine Wave

The most foundational wave is the sine wave. Ironically, from a mathematical perspective, it’s incredibly complex – it’s derivatives are self-referential infinite times! It’s got a section in the trigonometry curriculum! Some of its properties are defined by the most famous irrational number!

It’s also known as a pure tone – think of it as the “primary color” of audio. More on that later.

A sine wave.

It sounds pretty smooth. When looking at its shape and hearing how it sounds, it’s almost as if the sine wave is the path a string takes moving up-and-down when plucked or hit with a hammer (i.e., a piano).

A sine wave normally takes 2π units to make a complete circle (a.k.a., “cycle”). If we’re dealing with frequencies and hertz, we need to make sure to increase its speed by that much to make it 1 cycle a second (1 Hz).

Sawtooth Wave

The sawtooth wave is called such because of its similarity to the teeth of a saw. I’m sure anyone and everyone could have figured that out, but I needed a reason to have a sentence with the word in it to embed the Wikipedia link!

A sawtooth wave.

It has a scratchy sound. When looking at its shape and hearing how it sounds, think of it like the string of a bowed instrument. The bow pulls the string for a while, then it loses its grip, and the string springs back, only to be snagged by the bow again.

Some notes on its formula. Depending on technical issues and quality, creating a sawtooth wave may not be that simple. In practice, a good audio sawtooth wave is created by adding sine waves together. That will be the same caveat for all these signal types that involve straight lines. But we’ll leave that conversation for another day.

It’s also the simple atomic part of what’s called a supersaw, which is the backbone of a lot of electronic music genres.
For an introduction to supersaws, and for a sample of what they sound like, check out this SeamlessR tutorial.

And it’s doesn’t have to have an ascending slant. Here’s the sawtooth in reverse.

An inverted sawtooth wave.

Sounds the same but slightly grainier? Yea, I think so too.

Triangle Wave

Well, it’s not a mystery where the triangle wave gets it’s name from.

It sounds pretty smooth but also has a little edge to it. It looks like how it sounds, like a medium between the sine wave and the saw wave.

And again, some more interactive notes.

Square Wave

Square wave! Another wave who’s name visually does it justice.

A square wave.

It’s pretty shrill! Go fourth young ones, and create distorted rock music and brostep!

White Noise

No illustrations or anything, but it’s basically just randomness. It’s not really a wave, but it’s mentioned here because it is a primitive building block for noise.

White noise.

There really isn’t an equation to generate this except for whatever random number generation functions are available to you.

Colored Noises

A spectrogram of white noise, generated in FL Studio and visualized in its Wave Candy plugin. Note how it’s mostly filled with a consistent red color – but it’s not perfectly even everywhere; kind of randomly grainy.

The sun is white and emits white light (whether it stays white after scattering through Earth’s atmosphere is a separate topic). That white light is said to be an equal mix of all visible wavelengths. The same is true about white noise. It’s basically made of randomness and said to have an equal amount of different frequencies – at least in theory, this may not be exactly the case in practice.

There are other types of noise that sound similar but have biases in their spectrum. The noises are named after colors, describing where the bias of their frequencies is and where the color is on the color spectrum order.

Brownian noise sounds like the ocean wind gushing through an open car window – I could fall asleep to it.

Brownian noise, originally from Wikipedia.

So those are the low-level primitives that are often available on DAWs.

The standard-issue 3x Osc synth in FL Studio. It provides 3 different oscillators, each with a selection of different primitive wave types (in red).

But really, any wave can be sent to the speaker to make noise. And if it’s repeating at a periodic rate, it will generate a tone. Constructing more complex tones will be covered next time.

– Stay strong, code on. William Leu

Explore more articles here.
Explore more audio articles here.