Waveshaping

Waveshaping is one of the basic ways of distortion synthesis. In its simplest form it works like any overdrive effect by limiting a signal with a non-linear shaping function. Depending on the implementation, these shaping functions can have any form.

Shaping Function

The following example shows a simple tangential shaping function $y=\mathrm{tanh}(g x)$. For high pre-gain values, the function converges towards a step function and the output of a sinusoidal imput signal becomes a square wave.

Faust

Faust is a functional audio programming language, developed at GRAME, Lyon. It is a community-driven, free open source project. Faust is specifically suited for quickly designing musical synthesis and processing software and compiling it for a large variety of targets. The fastest way for getting started with Faust in the Faust online IDE which allows programming and testing code in the browser, without any installation. The online materials for the class Sound Synthesis- Building Instruments with Faust introduce the basics of the Faust language and give examples for different synthesis techniques.

Faust and Web Audio

Besides many targets, Faust can also be used to create ScriptProcessor nodes (Letz, 2015).

References

2015

  • Stephane Letz, Sarah Denoux, Yann Orlarey, and Dominique Fober. Faust audio dsp language in the web. In Proceedings of the Linux Audio Conference. 2015.
    [details] [BibTeX▼]

Realtime Weather Sonification

OpenWeatherMap

This first, simple Web Audio sonification application makes use of the Weather API for real-time, browser-based sonification of weather data. For fetching data, a free subscription is necessary: https://home.openweathermap.org

Once subscribed, the API key can be used to get current weather information in the browser:

https://api.openweathermap.org/data/2.5/weather?q=Potsdam&appid=eab7c410674e15bfdd841f66941a92c2


JSON Data Structure

The resulting output in JSON looks like this:

{
  "coord": {
    "lon": 13.41,
    "lat": 52.52
  },
  "weather": [
    {
      "id": 804,
      "main": "Clouds",
      "description": "overcast clouds",
      "icon": "04d"
    }
  ],
  "base": "stations",
  "main": {
    "temp": 9.74,
    "feels_like": 6.57,
    "temp_min": 9,
    "temp_max": 10.56,
    "pressure": 1034,
    "humidity": 93
  },
  "visibility": 8000,
  "wind": {
    "speed": 4.1,
    "deg": 270
  },
  "clouds": {
    "all": 90
  },
  "dt": 1604655648,
  "sys": {
    "type": 1,
    "id": 1275,
    "country": "DE",
    "sunrise": 1604643143,
    "sunset": 1604676458
  },
  "timezone": 3600,
  "id": 2950159,
  "name": "Berlin",
  "cod": 200
}

All entries of this data structure can be used as synthesis parameters in a sonification system with Web Audio.

Temperatures to Frequencies

Mapping

In this example we are using a simple frequency modulation formula for turning temperature and humidity into more or less pleasing (annoying) sounds. The frequency of a first oscillator is derived from the temperature:

\(\displaystyle f_1 = 10 \frac{1}{{T^2 / C^{\circ} }}\)

The modulator frequency is controlled by the humidity \(H\):

\(y = sin(2 \pi (f_1 + 100 \cdot \sin(2 \pi H t))t)\)


The Result

The resulting app fetches the weather data of a chosen city, extracts temperature and humidity and sets the parameters of the audio processes:

Where would you rather be?

What does the weather sound like in ...?



A Brief History

Beginnings of Computer Music

First experiments on digital sound creation took place 1951 in Australia, on the CSIRAC computer system. Besides from these experiments, the development of digital sound synthesis dates back to the first experiments of Max Mathews at Bell Labs in the mid 1950s. Mathews created the MUSIC I programming language for generating musical sounds through synthesis of a single triangular waveform on an IBM 704. The Silver Scale, realized by psychologist Newman Guttman in 1957, is one of the first ever digitally synthesized piece of music (Roads, 1980).


MUSIC and its versions (I, II, III, ...) are direct or indirect ancestors to most recent languages for sound processing. Mathews defined the building blocks for digital sound synthesis and processing in these frameworks (Mathews, 1969, p. 48). This concept of unit generators is still used today. Although the first experiments sound amusing from today's perspective, he already anticipated the potential of the computer as a musical instrument:

“There are no theoretical limitations to the performance of the computer as a source of musical sounds, in contrast to the performance of ordinary instruments.” (Mathews, 1963)

Mathews created the first digital musical pieces himself, but in order to fully explore the musical potential, he was joined by composers, artists and other researchers, such as Newman Guttman, James Tenney and Jean Claude Risset. Risset contributed to the development of electronic music by exploring the possibilities of spectral analysis-resynthesis (1:20) and psychoacoustic phenomena like the Shepard tone (4:43):


Later, the Bell Labs were visited by many renowned composers of various styles genres, including John Cage, Edgard Varèse and Laurie Spiegel (Park, 2009). The work at Bell Labs will be in focus again in the section on additive synthesis.


A Pedigree

The synthesis experiments at Bell Labs are the origin of most music programming languages and methods for digital sound synthesis. On different branches, techniques developed from that seed (Bilbao, 2009):

/images/basics/bilbao_history.png

The following family tree focuses on the tools used in this class and is thus without any claim to completeness:

/images/basics/computer_music_pedegree.png

Chowning & CCRMA

The foundation for many further developments was laid when John Chowning brought the software MUSIC VI to Stanford from a visit at Bell Labs in the 1060s. After migrating it to a PDP-6 computer, Chowning worked on his groundbreaking digital compositions, such as Turenas (1972), using the frequency modulation synthesis (FM) and spatial techniques. Although in particular known for discovering the FM synthesis, these works are far more than mere studies of technical means:


Puckette & IRCAM

Most of the active music programming environments, such as Puredata, Max/MSP, SuperCollider or CSound, are descendants of the MUSIC languages. Graphical programming languages like Max/MSP and Puredata were actually born as patching and mapping environments. Their common ancestor, the Patcher (Puckette, 1986; Puckette, 1988), developed by Miller Puckette at IRCAM in the 1980s, was a graphical environment for connecting MAX real-time processes and for controlling MIDI instruments.

The new means of programming and the increase in computational power allowed musique mixte with digital signal processing means. Pluton (1988-89) by Philippe Manoury is one of the first pieces to use MAX for processing piano sounds in real time (6:00-8:30):



References

2011

  • John Chowning. Turenas: the realization of a dream. Proc. of the 17es Journées d’Informatique Musicale, Saint-Etienne, France, 2011.
    [details] [BibTeX▼]

2009

  • Bilbao, Stefan. Numerical Sound Synthesis. Wiley Online Library, 2009. ISBN 9780470749012. doi:10.1002/9780470749012.
    [details] [BibTeX▼]
  • Ananya Misra and Perry R Cook. Toward Synthesized Environments: A Survey of Analysis and Synthesis Methods for Sound Designers and Composers. In Proceedings of the International Computer Music Conference (ICMC 2009). 2009.
    [details] [BibTeX▼]
  • Tae Hong Park. An interview with max mathews. Computer Music Journal, 33(3):9–22, 2009.
    [details] [BibTeX▼]

1991

  • Julius O. Smith. Viewpoints on the History of Digital Synthesis. In Proceedings of the International Computer Music Conference, 1–10. 1991.
    [details] [BibTeX▼]

1988

  • Miller S. Puckette. The patcher. In Proceedings of the International Computer Music Conference (ICMC). 1988.
    [details] [BibTeX▼]

1986

  • Emmanuel Favreau, Michel Fingerhut, Olivier Koechlin, Patrick Potacsek, Miller S. Puckette, and Robert Rowe. Software developments for the 4x real-time system. In Proceedings of the International Computer Music Conference (ICMC). 1986.
    [details] [BibTeX▼]

1980

  • Curtis Roads and Max Mathews. Interview with max mathews. Computer Music Journal, 4(4):15–22, 1980.
    [details] [BibTeX▼]

1969

  • Max V. Mathews. The Technology of Computer Music. MIT Press, 1969.
    [details] [BibTeX▼]

1963

  • Max V Mathews. The Digital Computer as a Musical Instrument. Science, 142(3592):553–557, 1963.
    [details] [BibTeX▼]

SynthDefs

Sending a SynthDef to a Server

SynthDefs are templates for Synths, which are sent to a server:

// define a SynthDef and send it to the server
(

SynthDef(\sine_example,
{
   // define arguments of the SynthDef
   |f = 100, a = 1|

   // calculate a sine wave with frequency and amplitude
   var x = a * SinOsc.ar(f);

   // send the signal to the output bus '0'
   Out.ar(0, x);

}).send(s);

)

Create a Synth from a SynthDef

Once a SynthDef has been sent to the server, instances can be created:

// create a synth from the SynthDef
~my_synth = Synth(\sine_example, [\f, 1000, \a, 1]);

// create another synth from the SynthDef
~another_synth = Synth(\sine_example, [\f, 1100, \a, 1]);

Changing Synth Parameters

All parameters defined in the SynthDef of running synths can be changed, using the associated variable on the client side:

// set a parameter
~my_synth.set(\f,900);

Removing Synths

Running synths with a client-side variable can be removed from the server:

// free the nodes
~my_synth.free();
~another_synth.free();

Control Rate and Audio Rate

Like many other audio programming environments, PD makes a difference between control signals and audio signals. They run at different rates and can not be combined, unless converted. Audio operations require the DSP to be activated, whereas control rate signal work at any time. Objects define whether an outlet gets or outputs control or audio rate signals. Objects with audio inputs or outputs are usually named with a ~. Control rate connections are thinner than audio rate signals. The example rates.pd simply shows an audio and a control rate connection, with audio connections being thicker:

/images/basics/pd-rates.png

The example also introduces the osc~ oject, which generates a sine wave at 1234 Hz. The message on the bottom of the patch is a patch-based way of activating the DSP, which can be very helpful when working with automated and background processes.


Audio to Control

Converting audio signals to control rate signals can be achieved with the snapshot~ object, as done in the example audio-to-control.pd. A possible application is an envelope follower. This object needs to be triggered to grab a snapshot, which is done with a metro object at 100 Hz in this example. The output is a level indicator for the LFO at 0.1 Hz:

/images/basics/pd-audio-to-control.png

Control to Audio

Usually, control signals can be connected to audio inlets. The conversion shown in the example audio-to-control.pd is thus less frequent. However, in some cases it might be necessary to convert control signals to audio rate. This is done with the sig~ object:

/images/basics/pd-control-to-audio.png

Raspberry Pi

The class Sound Synthesis at TU Berlin makes use of the Raspberry PI as a development and runtime system for sound synthesis in C++ (von Coler, 2017). Firtly, this is the cheapest way of setting up a computer pool with unified hard- and software. In addition, the PIs can serve as standalone synthesizers and sonification tools. All examples can be found in a dedicated software repository.

The full development system is based on free, open source software. The examples are based on the JACK API for audio input and output, RtAudio for MIDI, as well as the liblo for OSC communication and libyaml-cpp for data and configuration files.

The advantage and disadvantage of this setup is that every element needs to be implemented from scratch. In this way, synthesis algorithms can be understood in detail and customized without limitations. For quick solutions it makes sense to switch to a framework with more basic elements. The source code can also be used on any Linux system, provided the necessary libraries are installed.


The Gain Example

The gain example is the entry point for coding on the PI system: https://github.com/anwaldt/sound_synthesis_pi


References

2017

  • Henrik von Coler and David Runge. Teaching sound synthesis in c/c++ on the raspberry pi. In Proceedings of the Linux Audio Conference. 2017.
    [details] [BibTeX▼]

The Karplus-Strong Algorithm

The Karplus-Strong algorithm is not exactly a physical model, but it can be considered a preliminary stage to waveguides. The algorithm is based on a ringbuffer, filled with (white) noise, which is then manipulated. With very simple means, Karplus-Strong can synthesize sounds with the characteristics of plucked strings. Although not entirely realistic, the result has a intriguing individual character.


The Ringbuffer

Ringbuffers are the central element of the Karplus-Strong algorithm. As the name suggests, they are FIFO (first in - first out) buffers, with beginning and end connected. A ringbuffer with N samples can be visualized as follows:


White Tone from White Noise

If a ringbuffer is filled with a sequence of white noise, it can be used for creating a white tone - a harmonic sound with a strong overtone structure. Without resampling, the ring buffer can be shifted by one sample each $1/f_s$ seconds. The resulting pitch of the sound is then determined by the buffer size:

$$f_0 = \frac{f_s}{N}$$

For a sampling rate of $48000$ Hz, a ringbuffer with a length of $N=200$ samples, results in the following pitch:

$$f_0 = \frac{ 48000 }{ 200 } = 240.0\ \mathrm{Hz}$$

The sound of this harmonic signal is similar to a buzzer:


Spectrum

The spectrum of the white tone includes all harmonics up to the Nyquist frequency with a random amplitude. The overtone structure is individual for every white noise sequence, as is the timbre. These are three versions, started with an individual noise sequence of $N=400$ samples.

Version 1

Version 2

Version 3


Karplus-Strong

Karplus-Strong makes use of the random buffer and combines it with a moving average filter. In the most basic form, two samples are read from the buffer $b$, starting from index $i$ (the playhead), and the average of both samples is written to the buffer. An additional gain factor - set to $0.95$ in this example, results in a faster decay:

$$ b[i] = 0.5 (b[i] + b[i+1])$$

$b[i]$ is directly sent to the output $y$ in each step:

$$y[i] = b[i]$$

$i$ is increased, until it reaches $N$ and continues from the beginning. The following image shows this for $i=3$:

The result of this circular smoothing is a gradual decrease in high frequencies. The sound begins with a metallic transient:


Increasing the Filter Size

A faster decay of high frequencies can be achieved by larger moving average filters. This example uses a moving average of $10$ samples and a gain of $0.95$.

Families of Subtractive Synthesis

During the past decades, the subtractive principle has been implemented in many different ways, evolving along with the technology. Although based on the same principle, different families of subtractive synthesizers can be identified, all based on the same basic components. Representatives of these families have different characteristics and are used for different musical applications. Without claim to completeness these families are:

  • Analog modular

  • Analog monophonic

  • Analog polyphonic

  • Virtual analog / analog modeling


Analog Modular

The first subtractive synthesizers were large, cupboard-like devices and rather expensive. Although multiple voices are possible, they were designed as monophonic instruments. Two well known and opposite examples are the first models released by Bob Moog on the US east coast and Don Buchla on the west coast. The latter makes use of distortion techniques, whereas the Moog systems used the standard subtractive paradigm.

Moog Synthesizer (1965)

  • Switched on Bach, Wendy Carlos, 1968

    Bob Moog brought the typical VCO-VCA-VCF approach in a rack with a keyboard. It could hence be performed like a typical piano-like instrument. In productions like Switched on Bach it was made polyphonic through dubbing with tape recording techniques. This video shows the artist, Wendy Carlos, in an interview (since the LP is not available there):


Analog Monophonic

Analog monophonic synthesizers used the same techniques, yet in a more compact design and not fully modular. This made them more affordable and hence more disseminated and used.

Minimoog Model D (1970)

The idea of monophonic analog subtractive synthesis - and maybe of the synthesizer in general - is usually associated with the Minimoog.

/images/Sound_Synthesis/subtractive/moog1.jpg

Designed as a fully integrated musical instrument, the Minimoog could be used in virtuous expressive musical performances, was portable and affordable. Chick Corea's Minimoog solo, starting at 4:20, is an example of a virtuous performance, making use of modwheel and pitchbend:


EMS VCS 3 (1969)

The semi-modular EMS allows access to the signal flow with a patching matrix. It is thus especially suited for experimental sounds, as used by Pink Floyd in Welcome to the Machine for the wobbling machine sounds in the beginning:


Roland TB 303 (1982)

Although released several years later - and for a different application - the TB303 fits best into this family. The TB 303 was intended to be used as an accompanying instrument for musicians. It has a different interface, a programmable step sequencer.


/images/Sound_Synthesis/subtractive/tb303big.jpg

Due to the quirky filters it failed as a bass accompaniment but gave birth to techno and related genres. It creates the typical acid basses and leads:


Analog Polyphonic

After the monophonic analog synths of the 70s, which were intended as solo instruments, came the polyphonic ones. Polyphonic analog synthesizers shaped the sound of 80s pop (and especially synth-pop) music with their recognizable sound, often used as pads and harmonic foundation or for bass lines.


Yamaha CS-80 (1977)


Oberheim OBx (1979)



Virtual Analog

When digital technology was ready, it took over and various synthesizers were released which emulated the principles of subtractive synthesis. These devices were much cheaper and the digital means could provide more voices with better memory options. Virtual analog synthesizers were the backbone of trance development. They lack some of the analog warmth but are tighter in sound. Some examples:

Clavia Nord Lead

  • 1995

Roland JP-8000

  • 1996

    The Supersaw

Access Virus

  • 1997

Yamaha AN1x

  • 1997

AM & Ringmodulation: Example

The following example shows both AM and ring modulation:

Carrier Frequency

Modulator Frequeny

Modulator Offset

Output Gain:

Time Domain:

Frequency Domain: