tmhglnd / mercury

A minimal and human-readable language and environment for the live coding of algorithmic electronic music.
http://www.timohoogland.com/mercury-livecoding
GNU General Public License v3.0
304 stars 13 forks source link

Addition of Scala files #39

Open GuillemGongora opened 4 years ago

GuillemGongora commented 4 years ago

An addition for scale could include the use of the Scala format due to the immense library of already existing scales in .scl format.

The music concepts of scale, mode and tuning are somewhat similar to each other depending on the source. There should be a clear distinction for naming the different functions within Mercury. I.e.: scale for all the pitches within a division of the octave (12-TET), mode for the intervalic choice of said pitches (Major), leaving tuning unused, meaning the correction of the intonation in a specific note.

tmhglnd commented 4 years ago

Interesting! Had not heard about this .scl format before. So at the moment all numbers are always thought of as a semitone in 12-TET. If setting a scale to a (for example) 19-TET, what would the values in note() mean? Would certainly be nice to find a way that fits most scenarios! I see a few options:

  1. The first argument in note(x x) is the nth-position in the scale (which means that in a pentatonic scale 6 is one octave higher), this method would make the scale-mapping method redundant.
  2. The first argument in note(x x) is the nth-position in the tone-system, which means that in all 12-TET scales 13 is an octave higher, similar to note(0 1). But in a 19-TET 20 would be an octave higher, similar to note(0 1).

I guess this would largly also depend on how these .scl files are formatted and imported, I would have to dive into that. Also setting the root based on a frequency would be an interesting addition, and maybe I should convert all notes early-on to frequencies to have this working easier.

GuillemGongora commented 4 years ago

I would see the first argument of note() to be the pitch class, and the second argument, the octave choice. Of course, the octave choice would be dependant on the size of the pitch class, that would have to be calculated depending on the .scl file loaded. The only problem I see is the similarity of the concepts scale, mode, tuning, temperament... All the files in .scl format reference a scale, which is a unique temperament and tuning system. But what happens when you want the pitches to adjust to a minor scale like set scale minor c? Would that call for set scale minor.scl c? Or for set scale(12-tet.scl) mode(minor) root(c)? I've been looking at the archive of .scl files and I cannot find the more common scales based on 12-TET (which wouldn't be a problem to create). But that's why I'm more drawn towards the second approach, where mode() could re-define the pitches chosen for a loaded .scl file, and it could apply to other non-12-TET scales as well.