Octatonic Scales in SuperCollider

You can generate your own Octatonic scale in an arbitrary Equal Temperament using the following code.

Change octaveRatio to the ratio you’d like and steps to the number of steps. The Scale is saved to the global variable o;

(

var octaveRatio = 2, steps = 12;
var ratio, tuning_arr, tuning, octatonic_arr, octatonicScale, index;

ratio = octaveRatio.pow(steps.reciprocal);

tuning_arr = steps.collect({|i| ratio.pow(i).ratiomidi });
tuning = Tuning(tuning_arr, octaveRatio);

index = 0;
octatonic_arr =[];

{index < steps }.while({
	octatonic_arr = octatonic_arr.add(index);
	index = index+2;
	(index <= steps).if({
		octatonic_arr = octatonic_arr.add(index);
	});
	index = index + 1;
});


octatonicScale = Scale(octatonic_arr, tuning: tuning);

o = octatonicScale;
)

You can then use this in a Pbind by using \scale. For example:

(
Pbind(
	\scale, o,
	\degree, Prand((0..7), 7)
).play
)

Try out different Equal Temperaments

Note: Code for this post is available on github here.

Tuning scales is about ratios. We multiply the root frequency by a given ratio to get a note in the scale. In Equal Temperament, all ratios are equal, the 12th root of 2. Which is 21⁄12. We multiply a frequency by that to get the next frequency in the scale. When we’ve gone through all 12, we get the octave. (21⁄12)12 = 2.

Let’s say we want the 3rd note in the chromatic scale. We have the root and multiply by the ratio for the second and then for the third. For the fourth, we do it three times. For the fifth, four times. Therefore, for any chromatic scale step 𝘯, we multiply the root by 2(𝘯-1)⁄12

But, especially when we’re using computers, we can try out putting the notes in different places! What if we have 10 steps per octave? Then our ratio is Which is 21⁄10. The composer William Sethares has written music using 10 tone equal temperament and in other unusual tunings, which you can listen to on his web page.

We can even forego octaves entirely. The Bohlen-Pierce scale is based on divisions of 3, rather than 2. When people use equal temperament with that scale, they typically have 13 steps in the octave, which makes their ratio 31⁄13. The composer Elaine Walker is one of many who has written music using Bolhen Pierce and you can find examples on her website.

We can also try out different tunings ourselves! Below, you can try out different Equally Tempered scales. Change the steps value for the number of divisions you want. If you want to try out Bohlen-Pierce, change the octave ratio to 3. Or try whatever tickles your fancy.





Your tuning ratio is 21⁄12, which is equal to 1.0594630943592953

12tet’s ratio of 21⁄12 is equal to 1.0594630943592953

It can sometimes be difficult to hear the differences in pitches just going up and down a chromatic scale. Modes like major and minor are very strongly tied to a 12 note chromatic scale and it doesn't make sense to try to, say, play a 10 note major scale. However, the octatonic scale is a mode that can potentially work for any tuning. It alternates whole and half steps. Perhaps listening to the octatonic versions of your scale and 12tet will demonstrate the differences more clearly.


Or we can try a phrase by Debussy:


Science of Sound Week 2

Frequency

Previously, we talked about wave length and frequency. We measure frequency in Herz, abbreviated as Hz. A 1Hz sine wave goes through a complete cycle one time per second. A 440Hz sound wave goes through a complete cycle 440 times per second. The frequency is the reciprocal of the duration. A single cycle of a 440 Hz sine wave is  \frac {1} {440}th of a second.

We also talked about the speed of sound, which is 340 m/s at 20 degrees celsius. If we have a 1 Hz wave, travelling at 340m/s, it takes one full second to get through the complete cycle. Which means that the front of the sound wave is 340 metres away from the back. The wavelength is 340 metres.

A 2 Hz sine wave also travels 340m/s. The time it takes to get through each cycle is half a second. In half a second, the front has travelled 170 metres, which is to say that’s the wave length.

A 10 Hz sine wave lasts \frac{1}{10}th of a second, so the wave length is \frac{340}{10}, which is to say 34 metres.

A 100 Hz sine wave is \frac{340}{100} = 3.4 metres. The octave higher, 200 Hz, is 1.7 metres. The wave length is the speed of sound (c in the formula) divided by the frequency. \lambda = \frac{c}{f}

Tuning

We mentioned 440 Hz in the first paragraph. If that sounds familiar, it’s because it’s also the frequency of most tuning forks. It’s the defined frequency for A.

MusicSheetViewerPlugin 4.1

We also know that if we double the frequency to 880, that’s also and A. Or if we halve it to 220.

MusicSheetViewerPlugin 4.1

110 Hz, 55 Hz and 27.5 Hz are also As. As we get lower the frequencies get closer together and as we get higher they’re farther apart. 7040 Hz and 14080 Hz are also As.

We know that all As are 440 multiplied or divided by a power of 2. We also know that doubling any frequency gives us an octave of that frequency. We can generalise from this to come up with a formula for a one note scale based on the octave. Where f is frequency, f \times x = 2f. It’s obvious here that x is 2.

What if we want a two note scale that uses Equal Temperament? This is a system where all the notes are equally distant from each other perceptually. We know that this has to be based on multiplication. We want an equal ratio between all the notes. Therefore to get from the bottom note to the next one, we need to multiply by some number x. And then to get from the middle note to the octave, we multiply by x again. f \times x \times x = 2f We can simplify those two xs.  \therefore f \times x^2 = 2f And divide both sides by f.  \therefore x^2 = 2 Solving for x:  \therefore x = \sqrt{2}. Our two note scale is 440, 622.25, 880. This is because  440 \times \sqrt{2} = 622.25 and  622.25 \times \sqrt{2} = 880

What about a three note scale? f \times x \times x \times x = 2f Which means  \therefore x^3 = 2 and so  \therefore x = \sqrt[3]{2} To work out this scale,  440 \times \sqrt[3]{2} = 554.37,  554.37 \times \sqrt[3]{2} = 698.46, and 698.46 \times \sqrt[3]{2} = 880.

If we want a 4 note scale, we can use \sqrt[4]{2} or for a five note scale \sqrt[5]{2}. But for a piano, we want 12 notes, including all the white and black keys.

Therefore, the tuning used by the piano, called “12 Tone Equal Temperament” (or 12tet) uses \sqrt[12]{2}.

We know that the frequencies are exponential, but perceptually, the difference between a C and and A is the same in any octave. Our scales and keyboards and the musical concept of pitch is linear. Every octave may double in frequency, but it’s always only 12 semitones.

Figure 5: “Logarithmic plot of frequency in hertz versus pitch of a chromatic scale starting on middle C.” via https://en.wikipedia.org/wiki/Musical_note. Image by Jono4174, public domain via Wikimedia Commons.

You now know enough to work out the frequency for every single note on the piano. (Or, you can look it up on wikipedia.) You can also work out the wavelength for every frequency on the keyboard. If the lowest note is A0, the frequency is 27.5 Hz, so the wavelength \lambda = \frac {340}{27.5} = 12.4 metres. And the highest note, C8 is 4186 Hz, so \lambda = \frac {340}{4186} = 0.081 metres. What a range! And that’s not even the highest note we can hear!

Going Further

Not all scales are based on octaves! The Bohlen-Pierce scale is based on multiplying frequencies by 3. How could you compute an equally tempered scale for Bohlen Pierce? If you wanted the scale steps to be roughly the same size as 12tet, how many scale steps would you use?

TuningLib

Yesterday, I added a new Quark to Supercollider, called TuningLib. It requires a recent version of MathLib, one with the Bessel.sc file included. There are several classes in the new Quark, all realted to tuning.

Stuff from Jascha

Scala – This class is based on the SCL class from Jascha Narveson, but updated so it’s a subclass of the newer Tuning class. It opens Scala Files, which means you can use the large and interesting scala file library of thousands of tunings.
Key – Jascha’s SCL file also did a bunch of other interesting tuning-related things that the newer Tuning class does not, so I put these features in Key. It tracks your key changes and can interpolate between a given frequency or tuning ratio and the current active Scale.

Dissonance Curves

DissonanceCurve – is, I think, the most interesting part of the TuningLib. It generates Tunings, on the fly, for a given timbre. Give it your spectrum as lists of frequencies and amplitudes, or as a FFT buffer or as the specs for an FM tone, and it makes two different scales.
The first kind of scale it makes is the sort described by Bill Sethares. If you want to see the generated curve, you can plot it. Or you can get a Tuning from it. Or, you can get a scale made up of the n most consonant Tuning ratios. This is used in the second section of my piece Blakes 9
The other sort of tuning it does is based on a similar idea, but using the classic Just Intonation notions of consonance. Like with Sethares’ algorithm, every partial of a timbre’s spectrum is compared against every partial of the proposed tuning. It calculates the ratio between the frequencies. This could be 3/2, for example, or 115/114 or any whole number ratio. The numerator and denominator of that ratio are summed. In just intonation, smaller numbers are considered more consonant, so the smaller the sum, the more consonant the ratio. (This sum is related to Clarence Barlow‘s ideas of ‘digestibility.’) Then, the resultant sum is scaled by the amplitude of the quieter of the two partials. So if they are 3/2 and one has an amplitude of 0.2 and the other of 0.1, the result will be 0.5 ( = (3 + 2) * 0.1). This process repeats for every partial, and the results for each are summed, giving the level of dissonance (or digestibility) of the proposed tuning.
After computing the relative dissonance of all 1200 possible tunings in an octave, the next step is to figure out which ones to select as members of a scale. For this, the algorithm uses a moving window of n potential tunings. For a given tuning, if it is the most consonant of the n/2 tunings below it and the n/2 tunings above it, then it gets added to the Tuning returned by digestibleTuning.
I don’t have any sound examples for this usage yet, but I’m working on some. I don’t know of any pieces by anybody else using this algorithm either, but I’m sure I’m not the first person to think of it. If you know of any prior work using this idea, please leave a comment.

Tuning Tables

Lattice – This is based on some tuning methods that Ellen Fullman showed me a few years ago. Based on the numbers you feed it, which should be an array of 2 and then odd numbers, it generates a tuning table. for [2, 5, 3, 7, 9], it creates:

 1/1  5/4  3/2  7/4  9/8
 8/5  1/1  6/5  7/5  9/5
 4/3  5/3  1/1  7/6  3/2
 8/7  10/7 12/7 1/1  9/7
 16/9 10/9 4/3  14/9 1/1

You can use this class to navigate around in your generated table. For otonality, adjacent fractions are horizontal neighbors, so they share a denominator. For utonality, neighbors are on the vertical axis, so they have the same numerator. Three neighboring ratios make up a triad. You can walk around the table, so that you’re playing a triad, and then pick a member f that triad to be a pivot. Then, create a new triad on the other axis that contains your pivot as one of the members.
For example, one possible walk around the table, starting at 0,0 would be [1/1, 5/4, 3/2], [5/4, 1/1, 5/3], [3/2, 4/3, 5/3], [8/5, 4/3, 8/7], [8/7, 9/7, 1/1] etc. As you can (hopefully) see, the table wraps around at the edges.
I’ve done several pieces using this class, usually initializing it with odd numbers up to 21. Two examples are Beep and Bell Tolls

Undocumented

There is also a class FMSpectrum that will compute the spectrum for a FM tone if given the carrier frequency, the modulation frequency and depth (in Hz). I would like to also add in a class to calculate the spectrum of phase-modulated signals, but I don’t have the formula for this. If you know it (or where to find it), leave a comment!

More Tuning

While continuing to ponder tuning, I realized that it would be possible to create a dissonance curve for just intonation. Instead of judging how close the frequencies are to each other to look for roughness, you would look at what tuning ratio they described. If one frequency was 1.5 times the other, then that’s a ratio of 3 / 2. Then add the numerator and denominator to get 5. Then scale by amplitude.
In Sethares’ dissonance curves, you get scale degrees by searching for minima in the curve, but that approach is not a meaningful way to sort just ratios. Instead, they can be sorted by their relative dissonance.
I’ve updated my class, DissonanceCurve.sc (and fixed the url. sorry) so it can do just curves also. I ran it with the following (rough draft-ish) code:

 b = Buffer.alloc(s,1024); // use global buffers for plotting the data
 c = BufferTool.open(s, "sounds/a11wlk01.wav"); 

// when that's loaded, evaluate the following
(

 Task({

   d = SynthDef(foo, 
    { FFT(b, PlayBuf.ar(1, c.bufnum, BufRateScale.kr(c.bufnum))); 0.0 }).play;

  0.2.rand(3.7).wait;

   e = DissonanceCurve.newFromFFT(b, 1024, highInterval: 2, action: {arg dis;
 
    var degr, top5;
 
    d.free;

     dis.scale.do({ |deg|
  
      postf(" % / %,",
        deg.numerator, deg.denominator);
     });
    "n---just---".postln;
    dis.scale.size.max(25).do({ |index|
 
     degr = dis.just_scale[index];
        postf(" % / %,",
         degr.numerator, degr.denominator);
     }); 

 
   });
 
 
 }).play
)

And, after seriously heating up my computer, and waiting a bit, I got the following output:

 1 / 1, 29 / 28, 6 / 5 , 5 / 4 , 33 / 26, 4 / 3, 15 / 11, 29 / 21, 7 / 5, 10 / 7, 
3 / 2 , 8 / 5, 5 / 3, 27 / 16, 49 / 29, 12 / 7, 67 / 39, 7 / 4, 17 / 9, 2 / 1, 
---just---
 1 / 1, 3 / 2, 2 / 1, 4 / 3, 5 / 4, 6 / 5, 7 / 6, 9 / 8,  8 / 7, 10 / 9, 5 / 3, 
12 / 11, 15 / 14, 13 / 12, 11 / 10, 16 / 15, 9 / 7, 7 / 5, 14 / 13, 22 / 21, 7 / 4, 
10 / 7, 21 / 20, 11 / 8, 11 / 9,

The top section is the Sethares algorithm dissonance curve. I made a minor adjustment so that it looks at fractions one cent on either side of them minima and grabs the simpler one if it exists. (This is optional, add “simplify: false” to the method invokation to turn it off.)
The bottom section is the 25 least dissonant just ratios. Looking first at those, note that 1/1 is the least dissonant,as one would expect. Usually, 2/1 would be next, but note that in this case, it’s 3/2 instead. The algorithm does favor low number ratios, which is logical. Notice, also, that it tends to favor smaller numbers. There are a lot of (d+1)/d fractions: 4/3, 5/4, 6/5, 7/6, 9/8. It hugely favors these numbers. The top half of the octave is under represented. I do not know why this is so.
But Sethares’ algorithm, because it uses the critical band, tends to favor higher pitches as more consonant. However, since we search for minima rather than order the intervals by dissonance, this tendency’s effect on the results is reduced.
Both of these computations of dissonance seem to give meaningful data that does seem to have some kind of correlation to each other. On both lists we find, 6/5, 5/4, 4/3, etc. However, the length of the list of just ratios is arbitrary. If we take only the Sethares intervals that are in the top 5% most consonant (least dissonant) just intervals, we are left with:

 1/1, 29/28, 6/5, 5/4, 4/3, 15/11, 7/5, 10/7, 3/2, 8/5, 5/3, 12/7, 7/4,
2/1

Of those, 29/28 is the most dissonant, by both measures, so it may not be a the best scale degree. If that’s the case, then the top 5% is not the best cutoff. So what is? How do we choose it?
On the other hand, one way that just intonation is corralled is through factorization limits. For example, 7-limit tuning means that all the numbers in the ratios must be multiples of numbers that are less than 7. So 14 is ok (7 * 2), but 11 and 13 are not, as they’re prime and greater than 7. If we were to apply a 7-limit to the Sethares curve, the scale we would have is

1/1, 6/5, 5/4, 4/3, 7/5, 10/7, 3/2, 8/5, 5/3, 27/16, 12/7, 7/4, 2/1

Is that better? Does the 27/16 (aka: (3*3*3)/(4*4)) impact that?
Alas, we can’t use our ears because we don’t know what moment of the source was measured. But we can use our ears with a synthetic sound whose frequency content is known.

f = [50] ++ ( [50/27, 18/7, 54/25, 25/27, 9/7, 27/25, 25/54, 9/14, 27/50] * 300);
a = [0.055, 0.1, 0.1, 0.1, 0.105, 0.105, 0.105, 0.11, 0.11, 0.11];
e = DissonanceCurve.new(f, a, 2);

With some print statements, abbreviated for the sake of not being too boring, we get a Sethares scale of 1, 7/6, 25/21, 25/18, 36/25, 42/25, 12/7, 2, which, note, falls within a 7-limit. For the top 8 just results, we get, 1, 3/2, 6/5, 5/4, 7/5, 5/3, 34/27, 10/9. A list which does not include 2! And if we do the top 5% thing described above, we get, 1, 7/6, 25/21, 25/18, 36/25, 2. And we can compare these aurally:

(
 SynthDef("space", {|out = 0, freq = 440, amp 0.2, dur = 1, pan = 0|
  var cluster, env, panner;
 
  // detune
  freq = freq + 2.0.rand2;
 
  cluster = 
  SinOsc.ar(50, 1.0.rand, 0.055 * amp) + 
  SinOsc.ar((freq * 50/27) + 1.0.rand2, 1.0.rand, 0.1 * amp) + 
  SinOsc.ar((freq * 18/7) + 1.0.rand2, 1.0.rand, 0.1 * amp) + 
  SinOsc.ar((freq * 54/25) + 1.0.rand2, 1.0.rand, 0.1 * amp) + 
  SinOsc.ar((freq * 25/27) + 1.0.rand2, 1.0.rand, 0.105 * amp) + 
  SinOsc.ar((freq * 9/7) + 1.0.rand2, 1.0.rand, 0.105 * amp) + 
  SinOsc.ar((freq * 27/25) + 1.0.rand2, 1.0.rand, 0.105 * amp) + 
  SinOsc.ar((freq * 25/54) + 1.0.rand2, 1.0.rand, 0.11 * amp) + 
  SinOsc.ar((freq * 9/14) + 1.0.rand2, 1.0.rand, 0.11 * amp) + 
  SinOsc.ar((freq * 27/50) + 1.0.rand2, 1.0.rand, amp * 0.11);
 
  env = EnvGen.kr(Env.perc(0.05, dur + 1.0.rand, 1, -4), doneAction: 2);
  panner = Pan2.ar(cluster, pan, env);
  Out.ar(out, panner);
 }).send(s);
)
(
   Pbind(
  //Sethares
    freq,  Prand([1, 7/6, 25/21, 25/18, 36/25, 42/25, 12/7, 2] *300, 27),
    dur,  0.3,
    instrument,  space,
    amp,  0.2,
    pan,  0
   ).play   
)
(
   Pbind(
  // Just
    freq,  Prand([1, 3/2, 6/5, 5/4, 7/5, 5/3, 34/27, 10/9] *300, 27),
    dur,  0.3,
    instrument,  space,
    amp,  0.2,
    pan,  0
   ).play   
)

(
   Pbind(
  // Top 5%
    freq,  Prand([1, 7/6, 25/21, 25/18, 36/25, 2] *300, 27),
    dur,  0.3,
    instrument,  space,
    amp,  0.2,
    pan,  0
   ).play   
)

Which of those pbinds do you think sounds best? Leave a comment.

Questions about Differing Approaches to Tuning

Let’s start by all admitting that Equal Temperament is a compromise and that computers can do better. They’re fast at math and nothing physical needs to move, so we can can do better and be more in tune. (The next admission is that I haven’t had the attention span to actually read all the way through the Just Intonation Primer, although it is a very informative book and everyone should buy a copy and actually read it. Nor have a I read Tuning Timbre Spectrum Scale, alas.)
When we say “in tune,” what does that actually mean? On the one hand, we are talking about beating. You know that when you’re trying to tune two sound-generating objects playing the same note, there’s weird phasing and stuff that happens until you get it right. The beating sound you get when tuning a guitar. There’s also just a sort of roughness you hear when you play two notes that are really close to each other, like a C and a C# together. Both of these things seem to have something to do with being in tune and both suggest possible approaches.
Just Intonation, seem to be all about beating and zero crossings. Note relationships described with ratios in which the numerator and denominator are small, whole numbers have less beating. This is because when the waveforms cross, it’s at the low energy position, so they don’t interfere. 3/2 is thus very in tune. You can compute the amount of dissonance by adding the numerator to the denominator. Lower numbers are more in tune.
Bill Sethares, though, likes ten tone equal temperament (and writing songs in Klingon) and came up with some timbres that sound good in such a strange tuning. He’s got some math about dissonance curves. The roughness mentioned above has to do with how our ears work and critical bandwidth. If we hear two tones that are close to each other in pitch, the ear hairs they stimulate overlap, so the interfere with each other and create roughness. We can take a timbre and see how much internal roughness it has and then transpose it a bit and measure the roughness of the original and the transposed version played at the same time. Do this a bunch of times and you get a curve. The minima on the curve are good scale degrees.
Both of these approaches are perceptual and both seem to be in conflict. They both seem to use different parts of our perception, one more around critical band and the other more around amplitude and phase. So I wonder how to get them to work together? I can compute a dissonance curve that goes from 1 -1200 cents, but if I do it from a FFT’s spectrogram, the data I’m putting in is inexact. It only knows 512 frequencies, each of them slightly blurred and I’m using it with 1200 transpositions. Also, the transpositions are appropriately logarithmic, but the bins of the FFT are not, they’re linear. Should I do a similarly linear comparison and save myself a lot of unnecessary computation or does it make sense to do it by cents? Since I know there are artifacts in the spectrogram, should I find the minima and then search for “good” tuning ratios near them? Should the internal dissonance in the sample change the approach that I use?
I ported Sethares’ code to SuperCollider. You can download a working draft of DissonanceCurve.sc, if you desire. It’s quite math intensive for FFTs, but I have a synthDef made up of SinOsc, which is easy to analyze, since all the frequencies and amplitudes are known and there aren’t many of them. The freqs are in f and the amps are in a:

f = [50] ++ ( [50/27, 18/7, 54/25, 25/27, 9/7, 27/25, 25/54, 9/14, 27/50] * 300);
a = [0.055, 0.1, 0.1, 0.1, 0.105, 0.105, 0.105, 0.11, 0.11, 0.11];

e = DissonanceCurve.new(f, a, 2);
e.scale.do({ |deg|
  
 postf("Interval % - Dissonance %tRatio % / % n",
  deg.interval, deg.dissonance, deg.numerator, deg.denominator);
});

Which prints

Interval 1 - Dissonance 0.93194694734913 Ratio 1 / 1 
Interval 1.1667536657322 - Dissonance 1.1967977845161 Ratio 7 / 6 
Interval 1.1905817347928 - Dissonance 1.1395899373121 Ratio 25 / 21 
Interval 1.3883134504798 - Dissonance 0.92933737113208 Ratio 118 / 85 
Interval 1.4405968618317 - Dissonance 0.95473900132736 Ratio 85 / 59 
Interval 1.6798510690642 - Dissonance 0.79165734602377 Ratio 42 / 25 
Interval 1.7141578884562 - Dissonance 0.80288033573481 Ratio 12 / 7 
Interval 2 - Dissonance 0.49046268655094 Ratio 2 / 1 

118 / 85 is not a ratio of small, whole numbers, but it’s apparently less dissonant than 7 / 6 or even 85/59 or even the internal dissonance of the source sound! But, if we look in the curve, we can find the ratios 1 cent distant on either side of 118 / 85:

Interval 1.3875117607442 - Dissonance 0.9386025721761 Ratio 111 / 80 
Interval 1.3883134504798 - Dissonance 0.929337371132 Ratio 118 / 85 
Interval 1.3891156034233 - Dissonance 0.92966297781753 Ratio 25 / 18 

25 / 18 is a much smaller ratio and a distance of 1 cent is not perceivable, so it’s probably a better number. But I am still slightly confused / unconvinced. Note also, that sounds closer to 2/1 are all, in general, less dissonant that sounds closer to 1/1, because of the nature of the algorithm / critical bandwidth. But for just intonation, an inversion is barely more or less dissonant than it’s non-inverted form.
Also, an issue: the width of the critical band changes in different frequency ranges and I think it might help to use the Bark scale or something in the Dissonance Curve code, but the math is, as yet, a bit beyond me.
For the purposes of showing off, here’s a silly example with FFTs, which is not at all real time:(WARNING: THIS IS SLOW!)

 b = Buffer.alloc(s,1024); // use global buffers for plotting the data
 c = BufferTool.open(s, "sounds/a11wlk01.wav"); 
 d = { FFT(b, PlayBuf.ar(1, c.bufnum, BufRateScale.kr(c.bufnum))); 0.0 }.play;

// when that's playing, evaluate the following

 e = DissonanceCurve.newFromFFT(b, 1024, highInterval: 2, action: {arg dis;
 
  dis.scale.do({ |deg|
  
   postf("Interval % - Dissonance %tRatio % / % n",
    deg.interval, deg.dissonance, deg.numerator, deg.denominator);
  });
 });

Go and get a snack while that’s going. Make a cup of tea. You won’t be able to do anything else with SuperCollider until it finishes, so leave some comments about tuning. How should I be trying to combine dissonances curves and Just Intonation?
(My result for the code above (timing matters) was:

Interval 1 - Dissonance 2.4284846123288 Ratio 1 / 1 
Interval 1.0346671040459 - Dissonance 2.9055490440413 Ratio 30 / 29 
Interval 1.0557976305092 - Dissonance 2.9396229209406 Ratio 19 / 18 
Interval 1.0588513011885 - Dissonance 2.9394283497832 Ratio 18 / 17 
Interval 1.0625273666152 - Dissonance 2.9404120579786 Ratio 17 / 16 
Interval 1.0767375682475 - Dissonance 2.9248076874065 Ratio 14 / 13 
Interval 1.1114938763335 - Dissonance 2.8528563216285 Ratio 10 / 9 
Interval 1.1250584846888 - Dissonance 2.8384180012931 Ratio 9 / 8 
Interval 1.1302693892732 - Dissonance 2.8422250578475 Ratio 26 / 23 
Interval 1.1335384537169 - Dissonance 2.8404168678269 Ratio 17 / 15 
Interval 1.1667536657322 - Dissonance 2.773742908553 Ratio 7 / 6 
Interval 1.2002486666653 - Dissonance 2.6741210623142 Ratio 6 / 5 
Interval 1.2497735102289 - Dissonance 2.5747254321313 Ratio 5 / 4 
Interval 1.2628354511916 - Dissonance 2.5907859768328 Ratio 24 / 19 
Interval 1.2664879348481 - Dissonance 2.5910058160679 Ratio 19 / 15 
Interval 1.2856518332381 - Dissonance 2.5784271202225 Ratio 9 / 7 
Interval 1.3332986770912 - Dissonance 2.4554262314412 Ratio 4 / 3 
Interval 1.3503499461682 - Dissonance 2.4863589672953 Ratio 27 / 20 
Interval 1.3573881591926 - Dissonance 2.4874055968135 Ratio 19 / 14 
Interval 1.3755418181397 - Dissonance 2.469278592016 Ratio 11 / 8 
Interval 1.3811148862791 - Dissonance 2.4674194148261 Ratio 29 / 21 
Interval 1.3843096285337 - Dissonance 2.4676720796587 Ratio 18 / 13 
Interval 1.3891156034233 - Dissonance 2.4680185402198 Ratio 25 / 18 
Interval 1.4003945316219 - Dissonance 2.4587789993728 Ratio 7 / 5 
Interval 1.4289941397411 - Dissonance 2.432946313225 Ratio 10 / 7 
Interval 1.5000389892858 - Dissonance 2.2587031579717 Ratio 3 / 2 
Interval 1.5262592089606 - Dissonance 2.3003029027958 Ratio 29 / 19 
Interval 1.529789693524 - Dissonance 2.299895874529 Ratio 26 / 17 
Interval 1.5333283446696 - Dissonance 2.2993307022943 Ratio 23 / 15 
Interval 1.555631119012 - Dissonance 2.2871143779032 Ratio 14 / 9 
Interval 1.5619338268699 - Dissonance 2.2878440907054 Ratio 25 / 16 
Interval 1.6002899594453 - Dissonance 2.2385589006945 Ratio 8 / 5 
Interval 1.6114208563635 - Dissonance 2.2381572659306 Ratio 29 / 18 
Interval 1.6188844330948 - Dissonance 2.236239217168 Ratio 34 / 21 
Interval 1.625443414535 - Dissonance 2.2331690259349 Ratio 13 / 8 
Interval 1.6663213678518 - Dissonance 2.1624083601251 Ratio 5 / 3 
Interval 1.68763159226 - Dissonance 2.1765673941027 Ratio 27 / 16 
Interval 1.7141578884562 - Dissonance 2.1648475763908 Ratio 12 / 7 
Interval 1.7501759894904 - Dissonance 2.1359651045669 Ratio 7 / 4 
Interval 1.8004197968362 - Dissonance 2.0659411117752 Ratio 9 / 5 
Interval 1.8340080864093 - Dissonance 2.0362153732133 Ratio 11 / 6 
Interval 2 - Dissonance 1.6432830079835 Ratio 2 / 1 

Yikes)

Quick JJiCalc Tutorial

Launching JJiCalc

After you download the software to your computer, you can run it by
double-clicking on JJiCalc.jar. Or, if you have a command prompt,
you can type “java -jar JJiCalc.jar” .

Opening Files

Once the software is launched, click on the file menu and select open.
A dialog box will come up listing files and directories on your computer.
This box may look different from ones that you are used to. On OS X, the
box will list files in the root directory. If you want to get to your
home directory, click on the Users folder, then on your directory name.
Go to the directory where you put the software. In the JJiCalc folder,
there is a folder called tuning. Go there and open the file called
old_grandad.jic
Eight tuning ratios will appear in the top of the tuning table. The
title “Old Grandad” will appear in the title bar. (If you want to change
the name, just type in the title field.) On the top right hand side
of the application window are some buttons. One of them is called
“Comments.” If you click on comments, you can view the comments made about
the scale.

Lattice

Click the button marked “Lattice” to see the tuning lattice for the scale.
A new window will pop up, which shows ratios connected by lines. If you
want to hear a tuning ratio, you can click on it in the lattice. Click
on 3/2. The box around the ratio will turn gray and you should hear the
sound of the ratio being played. If you don’t hear anything and you’ve made
sure that sounds are working on your computer, you may need to update
your Java libraries, especially Swing.
If you click again on the ratio, it will stop playing. You can play
any number of ratios at the same time as you would like. Click on 3/2,
5/4 and 1/1.

Pop-up Menus

You can also play ratios directly from the tuning table. If you have a
multi-button mouse, right click on the numerator or denominator of one of
the ratios. If you are on a macintosh with a single-button mouse, option
click on the numerator or denominator. A pop-up menu will appear with
the options “Enable Sound”, “Freeze this Cell”, and “Clear this Cell”. To
hear the ratio, select “Enable Sound.” To stop hearing the ratio, right
or control click again and select “Disable Sound.”
Frozen cells can’t be played. Also, they can’t be cleared and will not
be sorted. To freeze a cell, right or control click on the cell for the
pop-up menu. To defrost a cell, do the same thing again, but select
“Defrost this Cell”. To erase the contents of a cell and remove a ratio
from the table, select “Clear this Cell”.

Cents, Hertz, Fret Position

In the middle of the bottom of the application, there is a section of
buttons labelled “View As.” Click the one labelled “ET +-Cents”. This
will calculate the closest Equally Tempered pitches, plus or minus the
cents needed to get your tuning. In the gray boxes below each ratio,
you should see a postive or negative number indicating the cents to add
or subtract, with the closest ET pitch below that. The JJiCalc assumes
that 1/1 is C0, so therefore 5/4 is E0 -13.7 cents.
To calculate Hertz, click the button marked Hertz in the “View As”
section. 1/1 defaults to 440. If you would like to use a different
base frequency, on the bottom right is a section called “base frequency.”
Type in what frequency you would like in the text area marked “1/1 freq”.
Then, click the button “Update Base”. If you play the ratios, they will
sound at the new frequencies. The displayed Hertz will not change,
however, until you click the “Hertz” button again in the “View As” area.
If you click the button “fret pos”, it will calculate fret positions
for you. The top number is the integer part of the fret position and the
bottom number is the decimal section. Below 3/2, there is 0. in the top
box and 3333 in the bottom box. Thus, for a string 1 meter long,
the fret position for 3/2 would be at 0.3333 meters.
You can change the string length by typing it in the text area labelled
“Str. Len.” and then clicking the button labelled “string len”. This will
cause your fret positions to recompute. There is a known bug: The
recomputed numbers will be incorrect.
After you change the String
Length, click the “fret pos” button again to figure out the correct fret
positions.

Adding New Ratios

Go to an empty table cell and (left) click in the numerator box. type
15 and then in the denominator box, type 16. This adds a 15/16 minor
second. If you click the lattice button, you will see your new
fraction in the lattice.
The JJiCalc automatically reduces your fractions for you. In another empty
cell, enter in 32/30. As soon as you click off of the cell, it will
reduce to 16/15. There is an option under the Configuration menu to turn
this reduction off. This is a known bug: Your fractions will always
reduce.

The Configuration Menu

One thing that works in the configuration menu is changing the wave
form setting. You can hear your fractions played as sine waves,
square waves or sawtooth waves.

Sorting

all of our tunings are in scale order except for the new one, 16/15.
On the right is a button marked “Sort”. Click it to but the ratios
in order from smallest to largest.
All of the things in the gray boxes below the ratios will clear when
you hit sort.

Saving

When you save your file, all of the data including the 1/1 frequency,
the title, the comments, the ratios and the stuff written in the gray
boxes below the ratios all get saved. Saving a tuning gives you the same
kind of dialog box you got when you openned old_grandad.jic. If you
type in the name of a file that already exists, a box will appear to
ask if you’re sure you want to overwrite the old file.

Other Formats

If you don’t want to save anyhting but the title, the comments and the
ratios (but not the stuff in the gray boxes), go to the File menu, then
look in the Export submenu and select “Ratios only.”
JJiCalc also supports the Scala file format. To save your tuning as a
Scala file, select “Scala File” under the Export menu. There is a very
large set of tunings in the Scala format that you can download from http://www.xs4all.nl/~huygensf/doc/scales.zip. To open
these tunings, select “Scala File” from the import menu. Not all Scala
tunings are Just Intoned. If the Scala tuning that you open contains
some non-just tunings, JJiCalc will approximate them as fractions.

Lovely Day

Not only was it a Wednesday, a relatively happy day during the week, since I don’t have too many stressful classes, but the weather was so nice that it felt like home. I could walk around with only a shirt and light swearer and feel nice.

I gave my presentation about tuning during class today. It was a bit of a disaster. Aaron said it was ok and that people were just scared of math, but I think maybe he was just being nice. Nobody knows what it means to be out of tune. I said, “out of tune notes beat. Beating is out of tune. the paino beats, so therefore it is out of tune.” I didn’t help that I was showing them a Pythagorean Tuning Lattice. That lattice has really nice fifths, fourths and octaves and horrible thirds, so it’s very very similar to Equal Temperment. I was on the way to talking about 5 limit intonation (which has wonderful thirds), when I played an example of the 7th and said, “that’s a terrible 7th.” and then I said something about how it didn’t matter that thirds were terrible because they weren’t considered consonant. And then the ethno types wanted to argue with me about consonance and dissonance. The ancient greeks thought it was consonant!! No, only string players would have used this tuning because it’s horribly out of tune. No, it’s in tune according to what they thought. Tuning is culturally constructed!
tuning is based on the overtone series. It is not socially constructed because it is centered around a physical fact. some notes are out of tune. the piano is out of tune and you’re wrong, because not everything is culturally constructed.
uh yeah

the to-do list of doom

old items

  • pedagogy things is done, now i need to write a syllabus for an intro to harmony class, due in 2 weeks
  • i now owe six instrument definitions, and i’ve done none of them.
  • still the world’s most clueless TA. I think we might be doing a realization of I am Sitting in a Room
  • I’m on the ITS comittee of the OtherMinds Board now. they didn’t ask me to run for secretary. (If you are a potential donor and want to go to a party wihtout me, let me know, and I’ll get you onto the list)
  • listened to Krystalnacht by John Zorn. Too many issues on top of the piece to say much about it, really. If you try to look at it abstractly and not as a programatic work, some of the tracks do not stand up on their own. the second track could never have been written about a non-programatic topic.
  • so, this morning, i thought i should put the JJICalc on Aaron’s computer before I left for school, to see if it would be loud enough. the program wouldn’t run. I ran out the door and charged off to school. got to the bike rack and realized that I left my keys sitting on my porch railing. Went back for my keys. Went back to school, now late for class and printed my handouts. Walked late into class. at the break went to try to find a key to the room where the Mac Truck is kept, so I could grab a laptop from it. the secretaries say that it’s very strictly against the rules and this is exactly why the mac truck is kept locked (and why grad students don’t get keys). then they let me have one anyway and it runs JJICalc just fine. The problem is that I compiled the calc on a new version of java and some macs are running older version of java and apparently there’s no backwards compatibility. I need to compile the program on an old machine so that it can run on other old machines. Write once, compile everywhere.
  • Haven’t touched OSC, but my perl script can get themes off of moo objects
  • emailed music prof about Joan of Arc mystery play. this prof doesn’t send prompt replies, so i may have to drop the research.
  • I’m going to analyze Turtle Dreams by Meredith Monk for my composition seminar. I don’t know if a score exists. Neely seems to think that a score is unnecessary.
  • The five minute piece is for piano. It’s started. Only god knows when it’s due.
  • none of the other composers know what’s going on either

new things

  • Must read inch-thick handout about Stravinsky by next wednesday
  • Aaron has organized a house concert where all the composition students will present five minutes worth of stuff. I must figure out what to do, as it is this saturday, I don’t think I can make people learn my SolReSol duet
  • Must return overdue library books and enquire as to the status of the books that i requested via inter-library loan
  • Must find and speak with a bell maker, but first, must find out how to find and speak with a bell maker.

Talking about Tuning

I’m scheduled to teach “anything” to my seminar on Wednesday. I though I should tackle tuning. This talk is just written and the sound samples and diagrams have not yet been generated.

what is Just Intonation?

Lou Harrison said that “Just Intonation is the best intonation.” An intonation is a type of tuning. Just tuning is a tuning that uses fractions. In just intonation, pitches are set using whole number ratios. To understand this, let’s look at the harmonic series.

Harmonic Series

The fundamental is the base frequency. (sound sample)
The first overtone is twice the base frequency. It’s relationship to the base frequency is 2/1. In other words, the base frequency * 2 = the first overtone. this makes a perfect (or just) octave. (sound sample)
The second overtone is 3 times the base frequency. It makes an octave plus a fifth. this fifth is perfectly in tune with the base frequency and the first overtone. (sound sample) but is an octave too high to use in a scale between those two notes. We can divide it by 2 to make it an octave lower. this new pitch, the fifth between the base frequency and the octave, is related to the base frequency by a ratio of 3/2. (sound sample) The three comes from it’s place in the harmonic series. The two comes from dividing it down to be in the first octave.

2’s and octaves

All notes in the first octave, will be between the ratios of the base frequency, which is 1/1 and the octave, which is 2/1. If something is too small, it is below 1/1, and if it’s too large it’s over 2/1. We can transpose it to the correct octave by multiplying or dividing by 2.

Therefore 2’s are very important for transposition, but they don’t change a pitch, except by octave. If the base frequency is C and we multiply it by 3, we get a G. If we multiply it by 3/2s, we also get a G, but in the first octave. so 2’s are “for free” you can multiply and divide by them any time you need to change the octave and you will still have the same note as before, just an octave higher or lower.

Inversion

the inversion of a fifth is a fourth. So we can invert the fifth fraction to get a fourth. the inversion of 3/2 is 2/3. But 2/3 is too small. It is not between 1/1 and 2/1. We can multiply it by 2, to get 4/3, a perfect just fourth. (sound sample)

You can do this with any tuning fraction. Invert it to find the inversion, then multiply or divide it by 2 to put it in the correct octave.

Pythagoras

3/2, the perfect, just fifth is a ratio made up of small, whole numbers. Small numbers sound more in tune because they are lower in the harmonic series. 3/2 is the most in-tune sounding note that you can get aside from the perfect octave.

There’s a story that pythagoras was walking by blacksmith shop and heard very harmonius sounds. After experimenting with the smiths, he discovered two excellent intervals, 3/2 and 9/8.

9/8 is a major second and since it still has small numbers, it sounds really good. (sound sample)

From this, he hypothesized that good rations were made up of powers of 3 over powers of 2 and their inversions. You know that the circle of fifths will eventually take you through all 11 notes in an octave. According to pythagoras, you can use this to tune all the notes. First, turn the first two strings as a perfect 3/2 fifth. Then tune from the 3/2 to the next fifth, a 9/8. then tune from the 9/8 to the next fifth, the 27/16. Notice that everyone of these ratios is a power of 3 over a power of 2.

Lattices

You can create a chart of these (pass out handout) called a tuning lattice. a lattice of powers of 3 over powers of 2 is called a Pythagorean tuning lattice. The line on your handouts at the top is a pythagorean tuning lattice. Below that, is chart of them in oder of the notes in the scale. Notice that E, the third is not a small number ratio. It is 81/64. This was considered ok at the time because thirds weren’t considered consonant. Notice also, that the octaves don’t line up. The octave, instead of being 2/1 is 243/128.

this is a sound sample of the tuning lattice going around the circle of fifths. (sound sample). This is a sound sample of it climbing the scale diatonically and then chromatically (sound sample). And this sound sample shows the difference between 243/128 and a 2/1 octave.

N-limit tuning

That last example demonstrates why mixing in other numbers than just three is a good idea. People often use 5’s, 7’s and sometimes higher prime numbers like 11’s. Your tuning system draws it’s name from the largest prime number that you use. A tuning that used 2’s and 3’s is a 3-limit tuning. One that uses 2’3, 3’s and 5’s is a 5-limit tuning.

(if I have time)

5-limit tuning

(Draw on blackboard) this is a tuning lattice of 5’s. This note 5/4 is a just third. The ratio has much smaller numbers than the pythagorean third. This is the pythagorean third (sound sample). This is the 5-limit third (sound sample). there’s almost a quarter-tone difference between them (sound sample).

N-limit lattices

When you are drawing lattices, every new prime number gets a new axis. so a tuning lattice could be thought of as an N-dimensional array, where N is the number of prime numbers. this one, with 5’s and 3’s is a two dimensional array. If we added 7’s, we’d need a new axis and we’d have a three dimensional array.

We can add notes to our lattice that are multiples of 5’s and 3’s. (draw on blackboard) All of these notes are the note right below it multiplied by 3/2s. Remember before, that multiplying fractions was raising them. Like 3/2 * 3/2 makes a note a fifth above. So because all of these notes are multiplies by 3/2s, they are all a fifth higher than the notes below them.

this is useful for two reasons. One is that 6/5 is the smallest numbers ratio we’ve yet seen for d#, the minor third. (sound sample). So adding lines like this helps us find extra ratios. the other thing that it’s good for is transposing. All of these notes are the same as the ones right below it, but raised by a fifth. So you might use this when you modulate to a new key.

Uses of Lattices

composers use lattices like these to figure out what tunings they want to use in their piece and then manipulate them for key changes and transpositions. they then use this to give instructions to instrumentalists or to program them into synthesizers.

One composer that uses tuning lattices to figure out how to tune her instrument is Ellen Fullman. She uses larger prime numbers to tune the many strings of her Long String Instrument. This track is based on a sweep of the harmonics of a C chord. (sound sample)

Pythagorean tuning lattices

Pythagoras really liked threes. A lot. You probably remember this from school. What they don’t tell you in grammer school is that the tuning ratio 3/2 is a perfect fifth. Pythagoras is creditted with discovering that. The story goes that he walked into a shop where metal smithing was going on and the smithing was very consonant and melodic sounding. He ordered the smiths to switch hammers and pieces of metal. In his experiments, he discovered that the tuning was not in the arms of the smiths or in the hammers, but in the strips of metal they were hitting. Somehow, he got from this discovery to 3/2, which is obviously completely perfect because it has a three in it and three is the most perfect of all numbers. Pythagoras really liked threes
Alas, it was downhill from there. You may recall the circle of fiths. It leads around to every note in the scale and is a nifty trick for remembering sharps and flats. So, theoretically, if you really liked fifths, you could tune every fifth from the fifth below it. The fraction for note N = 3/2 * (N-1). So the first note is 1/1. The second is 3/2. the third is 9/8. The fourth is 27/16. The fifth is 81/64. Every note is 3^^x/2^^y. This tuning was invented by Pythagoras and the list of notes you get from it it called a Pythagorean Tuning Lattice.
Not really a very good tuning system, but one used for hundreds of years. Anyway, Kyle Gann wrote a paper on tuning for beginners: http://home.earthlink.net/~kgann/tuning.html. In it, he says, “Equal temperament could be described as the musical equivalent to eating a lot of red meat and processed sugars and watching violent action films.” I knew it!