pub struct Tone {
pub value: ToneValue,
pub string_rep: String,
pub lineno: Option<usize>,
}
Expand description
A Tone is a single entry in a SCL file. It is expressed either in cents or in a ratio, as described in the SCL documentation.
In most normal use, you will not use this struct, and it will be internal to a Scale
.
Fields§
§value: ToneValue
Value of the tone.
string_rep: String
String representation of the tone. Is set if parsed from string.
lineno: Option<usize>
Number of line on which the tone was specified. Is set if parsed from file.
Implementations§
Source§impl Tone
impl Tone
Sourcepub fn float_value(&self) -> f64
pub fn float_value(&self) -> f64
Returns float value of a tone. Equal to cents() / 1200 + 1
.
Sourcepub fn from_string(
line: &str,
lineno: Option<usize>,
) -> Result<Self, TuningError>
pub fn from_string( line: &str, lineno: Option<usize>, ) -> Result<Self, TuningError>
Constructs a tone from a string.
Returns a TuningError::ParseError
if line
is not a valid tone representation.
Returns a TuningError::InvalidTone
if line
is a ratio with either denominator or
numerator equal to 0.
Returns an Ok
variant for valid tones.
Trait Implementations§
Source§impl Ord for Tone
impl Ord for Tone
Source§impl PartialOrd for Tone
impl PartialOrd for Tone
impl Eq for Tone
impl StructuralPartialEq for Tone
Auto Trait Implementations§
impl Freeze for Tone
impl RefUnwindSafe for Tone
impl Send for Tone
impl Sync for Tone
impl Unpin for Tone
impl UnwindSafe for Tone
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more