Skip to main content

Module scala

Module scala 

Source
Expand description

Runtime parsing of Scala .scl scale files. Runtime parsing of Scala .scl scale files.

Scala files are the de facto interchange format for microtonal scales, and music21 ships an archive of several thousand of them. Unlike the fixed TuningSystem tables, a scale loaded here is owned data decided at runtime, and its degrees may be either exact integer ratios or cents.

use music21_rs::ScalaScale;

let scale: ScalaScale = "! example.scl\n\
                         !\n\
                         A perfect fifth and an octave\n\
                         2\n\
                         !\n\
                         3/2\n\
                         2/1\n".parse()?;

assert_eq!(scale.description(), "A perfect fifth and an octave");
assert_eq!(scale.len(), 2);
assert_eq!(scale.ratio_at(1), 1.5);
// Degree 2 is the first degree of the next period.
assert_eq!(scale.ratio_at(2), 2.0);

Structs§

ScalaArchive
A searchable collection of Scala scales, keyed by file name.
ScalaScale
A scale parsed from a Scala .scl file.

Enums§

ScalaDegree
A single degree of a ScalaScale.