Exercise: Stockhausen Studie II Non-Octave Scale in SuperCollider

September 28, 2014 in Uncategorized

After my recent post about using custom just intonation scales with Patterns in SuperCollider, I was asked how one could use a scale similar to the one used by Karlheinz Stockhausen in his work Studie II, citing the description here:

For the pitches, Stockhausen built a scale in which the interval between successive steps consists of the frequency proportion of the twenty fifth root of 5 —in other words, the interval of 5:1 (two octaves plus a just major third) is divided into 25 equal parts. This differs from the traditional tempered tuning system, in which an octave consists of twelve segments, the interval between two adjacent steps being therefore defined by the ratio twelfth root of 2. The intervallic unit is a “large semitone”, about 10% larger than the semitone of the equal-tempered twelve-tone system. Beginning at 100 Hz, this scale reaches to ca. 17,200 Hz, with a total of 81 equally spaced pitches. Because of the chosen basic interval, no octave duplications can occur (Stockhausen 1964, 37). The highest pitch, 17,200 Hz, is near the upper limit of human hearing, and occurs only in a single tone mixture, as the uppermost of its five pitches (Toop 2005, 6).

The Simple Solution

This does not quite lend itself to the same Scale approach as last time since, as the description clearly states, there are no octave repetitions. In this case it makes the most sense to just create the scale as an array or frequencies. Here’s some example code where we randomly walk around the Studie II scale:

\freq, Pwalk( // random walk around our scale
// make our non-octave scale
Array.geom( // since we are dealing with frequency, we use geom rather than series
81, // 81 steps
100, // starting from 100Hz
5.pow(1/25) // the growth rate (step size) is the 25th root of 5
Pwrand([-2, -1, 0, 1, 2], [0.05, 0.1, 0.15, 1, 0.1].normalizeSum, inf), // random stepping
Pseq([1, -1], inf), // reverse direction at boundaries
40 // start in the middle of the scale
\dur, 0.125 // each note is a 1/16th

Most of the Pattern code here is straight from the Pwalk help file so I won’t talk about that too much. The main thing here is how we make the scale. In reading the description, we can see that Stockhausen started at 100Hz, and each of the 81 steps is higher by the 25th root of 5. SuperCollider’s Array.geom method is perfect for quickly giving us this:


That should be pretty straightforward. Here we say that we want 81 steps and that we will start from 100 (Hz). This much is exactly like Array.series if you are familiar with that. The only difference is that series adds the growth amount each step, whereas geom multiplies the last step by the growth amount to get the next step. Since we are working with frequency and not midi notes, we must multiply. 5.pow(1/25) is how we calculate the 25th root of 5.

A Slightly Better Solution

Now, this approach is fine and all but suffers from the same limitation I talked about in the last post: namely that you can’t use it like a true scale and pass in degrees. As I said before, it doesn’t totally make sense to think about this as a traditional scale since it has no octave equivalent notes, but it would be rather nice to be able to pass in indexes to it. This would allow us to get the “tone mixtures” that Stockhausen uses by “degree” rather than frequency. Here’s an example of just walking up the scale:

\root, 7 + (100.cpsmidi - 100.cpsmidi.round), // adjust the root to be 100Hz (g + 35 cents)
\octave, 3, // set the octave to the correct g (3)
\scale, (Array.geom(81,100,5.pow(1/25)).cpsmidi - 100.cpsmidi), // adjusted scale in midi numbers
\degree, Pseq((0..80),inf), // walk up the scale
\dur, 0.125 // each note is a 1/16th

There are a few new things going on here due to how Patterns handle scale degrees. \root specifies what pitch class (midi number between 0 and 11) will be used for \degree 0. Our scale starts from 100Hz with is midi number 43.349957715001 or G3 + 35 cents. Therefore we set the root to 7 (G) and add the cents to it with (100.cpsmidi - 100.cpsmidi.round) just to be as exact as possible. Next we set \octave to 3 to make the root G3 (5 is the default). At this point, using a degree of 0 will give us 100Hz.

How we use this with \scale is slightly different as well. Rather than using a combination of Scale and Tuning like last time, we will just give the pattern our array that we talked about earlier. However, the array from before was in Hz and scales need to be in relative midi numbers. This is easily handled with (Array.geom(81,100,5.pow(1/25)).cpsmidi - 100.cpsmidi). We simple convert our array to midi and subtract our root note from it. IMPORTANT: this must be done with both the array and root in midi scale, not frequency.

Final Thoughts

I don’t do much with with non-octave or equal division of the anything scales myself so this may not be the cleanest approach. I really just wanted to try my hand at it. I know that Tuning has a way of handling “stretched” tunings like this somehow but I haven’t quite figured it out at the moment. With this approach you should be able to pretty easily drop in your own scale array and get crackin’ pretty quickly, keeping in mind that it’s your responsibility to know if and when your scale recycles. Hope this helps in some way.

Post to Twitter Post to Facebook Post to Google Buzz Send Gmail

An Approach to Custom Scales in SuperCollider

September 26, 2014 in Tutorials

I often work with arbitrary pitch collections in Just Intonation that can change from place to place. As such, I usually deal with my pitches as harmonies or sets of ratios rather than scales or modes, but sometimes it’s nice to be able to do both.

SuperCollider has a built in mechanism for working with scales and tunings conveniently called Scale and Tuning respectively. These are particularly useful with Patterns as you can supply and change the scale and tuning you are using independent of the scale degree. Without this schema, you are stuck dealing directly with the exact pitches which, while straight forward and sometimes useful, can be limiting in certain situations.

Working with Scale and Tuning is pretty simple and well documented but there are a few quirks and redundant things to using it the way I need. My goal is to go straight from an array of ratios to something I can directly plug into a Pattern. For this, I made a simple function that handles all the subtitles:

// a function to convert an array or ratios to a Scale
~makeScale = {|ratios| // supply an array of ratios
Scale( // make a Scale
(0..ratios.size-1), // list the steps in the scale from 0 to the number of ratios
ratios.size, // how many steps we have in our scale
Tuning( // make a Tuning
ratios.ratiomidi // first we convert out ratios to midi
% 12 // then we mod 12 to put everything
).sort // lastly we sort it from low to high

// three JI scales, each with different root
a = ~makeScale.value([1,9/8,6/5,4/3,3/2,8/5,7/4]); // our initial scale
b = ~makeScale.value((5/4)*[1,9/8,6/5,4/3,3/2,8/5,7/4]); // same scale transposed a 5/4
c = ~makeScale.value((3/2)*[1,9/8,6/5,4/3,3/2,8/5,7/4]); // same scale transposed a 3/2

// test it out
\root, 0, // the pitch class of the scale's root
\octave, 5, // the octave of the root with a scale degree of 0
\scale, Pstep([a,b,c],2,inf), // play each scale/tuning every 2 seconds
\degree, Pseq((0..a.size),inf), // walk up the scale
\dur, 0.125 // each note is a 1/16th

Here’s what’s going on and why.

Scale first asks for an array of scale degrees based on the total number of degrees. For something like a major scale in 12TET this would be [0,2,4,5,7,9,11]. Since I want to deal with arbitrary scales sizes and the step sizes will be handled by the Tuning later, I just use (0..ratios.size-1) to make an array from 0 to one less than the number of ratios I supplied. If I give it 5 ratios, this gives [0,1,2,3,4].

Next Scale asks for the number of steps per octave. Since we want each ratio to be its own step, we just use ratios.size here. This effectively maps each ratio in the Tuning to each scale degree. At this point, Scale is just a wrapper around the Tuning, which is the real point of interest.

My way of dealing with the Tuning here is slightly more complicated than it absolutely needs to be, but I chose this approach because it offers the most flexibility.

All you really need is Tuning(ratios.ratiomidi), which would make a Tuning by taking our ratio array and converting it into the “midi number” version. This would be more than enough if we always ensure that our ratios are between 1/1 and 2/1. However, I decided I wanted to be able to be lazy and do things like transpose my ratios like so: (5/4) * [1,9/8,6/5,4/3,3/2,8/5,7/4]. This needed a little more stuff going on under the hood.

With ratios.ratiomidi, we get the the “midi number” array. Then we % 12 to force everything between 0 and 12. Finally we sort the result. This means that even if we supply ratios that are beyond one octave, this will automatically correct them and put put them in the right order for a scale.

Hopefully this is somewhat helpful. Once we have our Scale, we can do all the cool Patterny things exactly the same way as with any other standard scale. I also like to think of Scale in this case as also being usable as a chord. For instance, if you supply a three note tuning representing a chord, you could have your pattern play degrees [0,1,2] which would be the chord. Then if you change the Scale to be a different chord, the notes will change even if the degrees do not. Since the function we made will adjust octaves of out of range ratios, this can automatically handle inversions for us and thus give smooth voice leading basically for free (if that’s something you want). It’s fun to play around with at any rate.

Post to Twitter Post to Facebook Post to Google Buzz Send Gmail

Live Coding Drones #3

October 15, 2013 in Electronic, Music

More tweaks to my live coding setup in vim. Trying out the motus color scheme. Using delimitMate for automatic enclosures, SuperTab for autocomplete, snipmate for snippet expansion. Also decided to try using keyCastr to display all my keystrokes.

Started out with a basic master effects synth and bussing setup. I have a routine spawning a one synth that I constantly tweak. Later I add in a simple band passed noise synth for a little variation while I keep messing with the other one. Pitches are all derived from the overtones of two ratios which I alter from time to time.

Post to Twitter Post to Facebook Post to Google Buzz Send Gmail

Live Coding Drones #2

October 11, 2013 in Electronic, Music

Practicing jumping around Vim to quickly edit parts of existing code. All code was pre-written with the intent that certain parts would be edited as things progressed.

Post to Twitter Post to Facebook Post to Google Buzz Send Gmail

Live Coding Drones #1

October 9, 2013 in Electronic, Music

This is the first of possibly a series of recordings of my live coded drone music practice. For this session, I decided:

-start with one background synth that I coded beforehand and code the rest on the fly
-the primary synth would be made primarily from a SinOsc
-do a generic arch form

Post to Twitter Post to Facebook Post to Google Buzz Send Gmail