In audio programming, we are concerned with using computers to capture, measure, analyze and manipulate audio signals. If you are working with audio or DSP you will have to understand some basics of wave interaction.

## What is a Wave?

For our most basic case, we can understand a wave as representing a *scalar* quantity. That is to say, that we are *only* concerned with the magnitude of the wave (voltage, pressure, etc). Any wave is expressed mathematically as a function. We will call this *f*. It is common to express how this wave changes over time. We often denote this as *f*(*x*) where *x* is the *x*-axis and this represents time. [1]

All waves have at least three variables:

- Amplitude (expressed as some number)
- Frequency (expressed in Hz)
- Phase (expressed as degrees ϕ, radians θ)

Therefore, we write *f*(*x*) as follows: *f*(*x*) = *a*·sin(2πf*x*+θ)

Where *a* is the amplitude as linear gain, ‘f’ is the frequency in Hz, *x* is time (but is sometimes denoted as *t*), θ is the phase in radians.

Here are some ideas relating to these three variables. The following set of graphs demonstrates these concepts. Please note that all code to create these images be found on my Github as a Python file:

- The higher the amplitude, the bigger the wave on the plot. This relates to perceived loudness of a wave (loudness is actually more complicated).
- The lower the frequency, the longer the wavelength and the lower the perceived pitch.
- The higher the frequency, the shorter the wavelength and the higher the perceived pitch.
- Changes in phase, shift the value of the wave at the point of observation.

## Wave Superposition – Phase Interactions

Understanding waves in this manner is crucial. As waves are scalar quantities, you can superimpose (*add*) them on to each other. This means that waves can be summed together to produce a new wave by a process of *constructive* or *destructive* interference. The graph below gives the result of summing two waves together. In the following plot, each wave (*dotted-lines*) is of the same *amplitude* and *frequency* but different *phases* and the result of the summation is the solid line. [2]

Notice how when the waves are:

*In-Phase*the result is a wave of double the amplitude. Please note that the two waves are of the same amplitude and frequency. Therefore, they occupy the same points on the graph.*Out of Phase*we get a resulting waveform that is also out of phase- In
*anti-phase*the result is no wave or*cancellation*.

This is important as the results can get more complicated when you sum waves of different frequencies or amplitudes or when you sum many waves together.

## Wave Superposition – Fourier Series & Fourier Analysis

Joseph Fourier was a French physicist and mathematician who lived in the early 1800s. He was investigating heat distribution on a ring and Newton’s Law of Cooling when he came up with an important theory that we use in DSP (as well as everywhere else in engineering). He stated that:

Any periodic mathematical function can be expressed as an infinite sum of sine waves.

Sine waves are the simplest wave as they have one *frequency*, *amplitude *and *phase*component. While this is not a mathematics lecture, both metal rings and sine waves are periodic (they repeat). [1]

I would like to take the time to prove this idea of his; by taking a set of sine waves and plotting out the result of their summation. Summing waves in an organized fashion can give us familiar waveforms.

This process of taking a wave, and deconstructing it into its component sine waves is known as *Fourier Analysis*. The resulting set of sine waves used in the summation is called a *Fourier Series*. The plots below are the frequency domain representations of the plots above. Essentially, each peak denotes a component frequency. Going from the time domain (above) representation to the frequency domain representation (below) and back is called a *Fourier Transform*. [2]

## Conclusion

Waves have a few variables to manipulate. These are *amplitude*, *frequency* and *phase*. By summing a series of waves, one can create any other wave. It is important to think about how these variables are affected by systems such as speakers, filters and other such signal processors in order to anticipate *behavior*, *correctness* and *stability*. I hope this helps guide your understanding so that you can create and troubleshoot things with greater capability on your next project.

Be good to each other and take it easy…

-Will ☜(ﾟヮﾟ☜)

Will Fehlhaber is an Acoustics Engineer and Audio Programmer from the UK and Bay Area.

## Bibliography/Citations/Resources:

[1] Acoustics and Psychoacoustics

[2] Fundamentals of Musical Acoustics: Second, Revised Edition (Dover Books on Music)

## Related Posts

- Abbey Road Red Hackathon 2019
- Who’s in LA next week? Music and Tech Maker’s Meetup
- The Audio Programmer Podcast Episode 09 – Mark Watt (SpaceCraft Synth)
- The Audio Programmer Podcast 08 – Nick Thompson (Creative Intent) Announces His New JUCE Module!
- The Audio Programmer Podcast 07 – Jules Storer (Founder of JUCE / SOUL)

## Recent Comments