Struct Scale

Source
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

Source

pub fn new() -> Self

Constructs an empty scale.

Source

pub fn count(&self) -> usize

Number of tones in the scale.

Source

pub fn read_scl_file<P>(fname: P) -> Result<Self, TuningError>
where P: AsRef<Path>,

Returns a Scale or an error from the SCL file contents in fname.

Source

pub fn parse_scl_data(scl_contents: &str) -> Result<Self, TuningError>

Returns a Scale or an error from the SCL file contents in memory.

Source

pub fn even_temperament_12_note_scale() -> Self

Provides a utility scale which is the “standard tuning” scale.

Source

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
Source

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.

Trait Implementations§

Source§

impl Clone for Scale

Source§

fn clone(&self) -> Scale

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Scale

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Scale

Source§

fn default() -> Scale

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Scale

§

impl RefUnwindSafe for Scale

§

impl Send for Scale

§

impl Sync for Scale

§

impl Unpin for Scale

§

impl UnwindSafe for Scale

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.