pub struct Scale {
pub name: String,
pub description: String,
pub raw_text: String,
pub tones: Vec<Tone>,
/* private fields */
}
Expand description
The Scale is the representation of the SCL file.
It contain several key features. Most importantly it has a Scale::count()
and a vector of
Tones.
In most normal use, you will simply pass around instances of this struct to a Tuning
, but in
some cases you may want to create or inspect this struct yourself. Especially if you are
displaying this struct to your end users, you may want to use the Scale::raw_text
or
Scale::count()
methods.
Fields§
§name: String
The name in the SCL file. Informational only.
description: String
The description in the SCL file. Informational only.
raw_text: String
The raw text of the SCL file used to create this Scale.
tones: Vec<Tone>
The tones.
Implementations§
Source§impl Scale
impl Scale
Sourcepub fn read_scl_file<P>(fname: P) -> Result<Self, TuningError>
pub fn read_scl_file<P>(fname: P) -> Result<Self, TuningError>
Returns a Scale or an error from the SCL file contents in fname
.
Sourcepub fn parse_scl_data(scl_contents: &str) -> Result<Self, TuningError>
pub fn parse_scl_data(scl_contents: &str) -> Result<Self, TuningError>
Returns a Scale or an error from the SCL file contents in memory.
Sourcepub fn even_temperament_12_note_scale() -> Self
pub fn even_temperament_12_note_scale() -> Self
Provides a utility scale which is the “standard tuning” scale.
Sourcepub fn even_division_of_span_by_m(
span: u32,
m: u32,
) -> Result<Self, TuningError>
pub fn even_division_of_span_by_m( span: u32, m: u32, ) -> Result<Self, TuningError>
Provides a scale refered to as “ED2-17” or “ED3-24” by dividing the span
into m
points.
Scale::even_division_of_span_by_m(2, 12)
should be the
Scale::even_temperament_12_note_scale()
.
let s1 = Scale::even_division_of_span_by_m(2, 12).unwrap(); // equal to `even_temperament_12_note_scale()`
let s2 = Scale::even_division_of_span_by_m(2, 17).unwrap(); // ED2-17
let s3 = Scale::even_division_of_span_by_m(3, 24).unwrap(); // ED3-24
Sourcepub fn even_division_of_cents_by_m(
cents: f64,
m: u32,
last_label: &str,
) -> Result<Self, TuningError>
pub fn even_division_of_cents_by_m( cents: f64, m: u32, last_label: &str, ) -> Result<Self, TuningError>
Provides a scale which divides cents
into m
steps. It is less frequently used than
Scale::even_division_of_span_by_m()
for obvious reasons. If you want the last cents
label labeled differently than the cents argument, pass in the associated label.