Monday, July 6, 2015

Shepard Tones and Similar Madness

Today's inaugural post is about Shepard tones. Shepard tones are tones that seem to be moving eternally upward or downward. (For ease of explanation, I will talk about the downward motion, but there is very little difference)

Wikipedia defines the 
Shepard tone as "a sound consisting of a superposition of sine waves separated by octaves". What a useless definition.

The 
Shepard tone is the sonic equivalent of a barbershop pole: Multiple descending or ascending sounds which create an eternally descending or ascending sound (Or both with the help of the mighty tritone)



Pretty much the same thing


Some examples of the 
Shepard tone:

  • Pink Floyd - Echoes (22:30)
  • Godspeed You! Black Emporer - The Dead Flag Blues (7:15)
  • Wolves In The Throne Room - Subternean Initiation (3:30)
  • Wolvserpent - A Breathe In The Shade Of Time (14:45)

Creating the Shepard Tone in SuperCollider

SuperCollider is "a programming language for real time audio synthesis and algorithmic composition." We will be using SuperCollider today to make a Shephard Tone generator. After that, we will have some more abstract conversation on expanding the Shepard Tone beyond Sine oscillators. 

First, we need a synth. We're going to create a basic sine oscillator with an enveloper to add some sustain to our tones. We want to be able to control the tone's frequency, volume, and sustain.


1
2
3
4
5
6
7
(
SynthDef(\synth, { |freq = 440, amp = 0.2, sustain = 1|
 var sig;
 sig = SinOsc.ar(freq, 0, amp) * EnvGen.kr(Env.perc(sustain, 1), doneAction: 2);
 Out.ar(0, sig ! 2);    // sig ! 2 is the same as [sig, sig] AKA stereo
}).add;
)


Let's play a simple tone through our new synth



1
Synth(\synth, [freq: 440, amp: 1/2, sustain: 1]).play;

Here we have a synth at 440 hz played at 50% volume for 1 second.

Here's our meat and potatoes, the base sound we will use. The interesting part is up next: There are probably many ways to make a 
Shepard tone. We will be creating our tone by first generating a downward sweep. Next, that sweep is repeated at least a few times before the first sweep ends.

Let's Start With A Sweep!

So we know how to play a tone, as seen earlier. Now we need to take 12 (Or however many) of those tones and make a sweep. We can do this by creating an array of all the notes in our sweep and then iterating over that array.



1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
(
t = Task({
 var cScale = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49];//12 notes descending starting at C
 
 //For every note in the array, convert that note to midi and then make some sounds
 cScale.do({ |midi|  
  var octaves = 1;
  
  octaves.do({ |i|   
   Synth(\synth, [
    freq: (midi + (12 * i)).midicps, //(12 * i) adds octaves
    amp: 1/cScale.size, 
    sustain: cScale.size]);
  });
  
  (1/cScale.size).wait;
 });
}).play;
)
This simple code plays 12 notes in succession. In order for this to be a Shepard tone, we need to play it over and over again. How do we do that? Simple! Just surround our previous code with loop {}



1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
(
t = Task({
 loop {
  var cScale = [60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49];//12 notes descending starting at C
  
  //For every note in the array, send that note to midi and then make some sounds
  cScale.do({ |midi|  
   var octaves = 4;
   
   octaves.do({ |i|   
    Synth(\synth, [
     freq: (midi + (12 * i)).midicps, //(12 * i) adds octaves
     amp: 1/cScale.size, 
     sustain: cScale.size]); //this is important - the first note should end as the loop ends
   });
   
   (1/cScale.size).wait;
  });
 }
}).play;
)


We now have a 
Shepard tone! Behold it's mind-melting glory, listen into it's abyss and feel the sound of death.

Ahem.




The Tritone Paradox


We can do more with this. Remember earlier in the post, when I mentioned that the Shepard tone can both ascend and descend? It turns out that this is really easy, we just need to make two Shepard tones separated by a tritone (Half an octave). If you don't know about tritones, you may enjoy reading up on them - Often called diabolus in musica ("the Devil in music"). Tritonic intervals seem to have a quality about them that's almost too symmetrical...It's hard to tell if you're moving up or down or at all. This sounds like exactly the kind of disorientation our Shepard tone could use!

There's only going to be two small changes. First, we need a synth that will play two notes instead of one, a tritone apart


1
2
3
4
5
6
7
8
(
SynthDef(\synthTritone, { |freq = 440, amp = 0.2, sustain = 1|
    var sig;
    sig = [SinOsc.ar(freq, 0, amp) * EnvGen.kr(Env.perc(sustain, 1), doneAction: 2),
  SinOsc.ar(freq + (freq / 2), 0, amp) * EnvGen.kr(Env.perc(sustain, 1), doneAction: 2)];
 Out.ar(0, SelectX.ar(0, sig) ! 2);
}).add;
)


We also need to change the code to use this synth - Change this line


1
Synth(\synth, [


to


1
Synth(\synthTritone, [


There you go, we've now got a tritonic, perception-defying, disorienting wall of sound!

Ideas for Further Development

This idea could be taken further with different scales, notes, etc.

No comments:

Post a Comment