Scales and tunings without Scale or Tuning

I’ve always found the Scale and Tuning classes weird as hell and I just roll my own scale logic for every piece. Here’s how to do it.

Here’s a simple EDO:

var edo, degreeToFreq;

degreeToFreq = { |n|
    reference * (2 ** (n / edo))
};

Here, reference is the frequency in Hz of the note that you get when n is 0. Really this isn’t a “degree” but rather a pitch index analogous to MIDI note numbers.

Here’s a scale:

var scale, edo, degreeToFreq;

scale = [0, 2, 4, 5, 7, 9, 11];

degreeToFreq = { |n|
    reference * (2 ** ((scale.wrapAt(n) / edo) + floor(n / scale.size)))
};

If you want an equal tuning that’s not at the octave, replace 2 with whatever the period is. Dunno why anyone thinks Bohlen-Pierce sounds good, but it’s not my place to judge.

Not using equal temperaments? Here’s a scale with JI ratios:

var scale, degreeToFreq;

scale = [1, 9 / 8, 5 / 4, 4 / 3, 3 / 2, 13 / 8, 9 / 4];

degreeToFreq = { |n|
    432 * scale.wrapAt(n) * (2 ** floor(n / scale.size))
};

Chakras aligned, baby! Behold the power of binaural Ayurvedic quantum mindfulness!

If you use Scale or Tuning and you’re making great music, then you do you! If you use Scale or Tuning and you will ardently defend all their design decisions in the replies, then please leave me alone!

6 Likes

Nice!

…the library of scales and tunings is a cool convenience though, I write "1 3 5 7".df(\c) to get a C-major7 chord and "1 3 5 7".df(\c,\mixolydian) to get a C-dominant 7th. I know I could just write “1 3 5 6.5” but being a music-theory type it can be nice to just read the usual scales and modes. (my .df method uses Scale and Tuning under the hood)

…and Scale and Tuning are explicitly used by the default Event type. So new users bump into them…

It would be cool if these classes were not so wonky. (and/or had note-names and 1-indexed options so that trad music can look like trad music) - or if we built in some simple convenience methods for Array and Simple Number to help newbs out.

and as @prko suggests maybe SinOsc.ar('c3'.cps, 0, 0.1) ought to work? or even SinOsc.ar('c3') or SinOsc.ar('c3'.tune(\just))

1 Like

Great points.

One simple idea might be to support Scala scales and tuning (in which case we are not responsible for the library)

( and totally agree re: inclusion + defaulting to et12 irritates me esthetically. )

1 Like

interesting thoughts to include Scale scales… you have a link to them, possibly?

https://www.huygens-fokker.org/microtonality/scales.html

1 Like

for later reference, I found this document that explains the file format: Scala scale file (.scl) format

1 Like

Here’s a “parser” I just built:

https://sccode.org/1-5hj

I hope it is useful to someone :slight_smile:

Just to understand the Scale class (finally, after about a decade of ignorance from my side):
An idea on how to turn these into proper Scale objects would be much appreciated.

1 Like

You can load the scala files using TuningLib as well, FYI

1 Like

thanks for the heads up, @madskjeldgaard, and thanks for the great introduction to Scales/Tuning, Celeste Hutchins!

(also, this thread seems to be related to what we’re discussing here: Scale documentation incomplete? - #10 by jordan)

@Yann_Ics just looping you into this thread in case you don’t see it