Scala

Generate scala scl and kbm files.

Scala files are widely used to load microtonal tunings into synths. For more information see here.

class ScalaScale(frequencies, description='Generated by jird')[source]

Scala scale data.

Contains frequencies of the notes in a scale. For more information see here.

description

Text describing the scale.

Type:

str

number_of_notes

Number of notes in the scale

Type:

int

frequencies

Frequencies in the scale. Fractions are interpreted as frequency ratios, floats as cent values.

Type:

list of Fraction or float

class ScalaKeyboardMap(size, first_midi_note, last_midi_note, middle_note, reference_note, reference_frequency, formal_octave, mapping)[source]

Scala keyboard map data.

Contains mapping from midi note number to scale degree. For more information see here. Attribute descriptions below copied from example.kbm in scala repo.

size

Size of map (greater than or equal to the number of notes in the scale to be mapped). The pattern repeats every so many keys.

Type:

int

first_midi_note

First MIDI note number to retune.

Type:

int

last_midi_note

Last MIDI note number to retune.

Type:

int

middle_note

Middle note where the first entry of the mapping is mapped to.

Type:

int

reference_note

Reference note for which frequency is given.

Type:

int

reference_frequency

Frequency to tune the above note to (floating point e.g. 440.0).

Type:

float

formal_octave

Scale degree to consider as formal octave (determines difference in pitch between adjacent mapping patterns) and 0 means last scale degree.

Type:

int

mapping

The numbers represent scale degrees mapped to keys. The first entry is for the given middle note, the next for subsequent higher keys. For an unmapped key, put in an “x”. At the end, unmapped keys may be left out.

Type:

list of int

write_scala_files_for_midi(music, f0, base_filename)[source]

Write scl and kbm files for retuning midi.

The scl file contains each frequency in music sorted low to high. The lowest frequency is taken as 1/1 in the scala file. The kbm file contains a mapping from each frequency in the music to a unique midi note, along with the frequency in Hz of the lowest note in music to use as the frequency of the scala 1/1.

Parameters:
  • music (Music) – Music to build tuning for.

  • f0 (float) – Base frequency in Hz.

  • base_filename (str or Path) – Filename to build output scl and kbm filenames from by changing the file extension.

Returns:

Scala data to be used with the midi file for music.

Return type:

ScalaData

write_scale(music, filename)[source]

Write scala scl file for scale in music.

The scale is all the notes in music transposed into the same octave.

Parameters:
  • music (Music) – Music to build scale from.

  • filename (str or Path) – Output file name.