Struct persichetti::primitives::Interval [−][src]
pub struct Interval { /* fields omitted */ }
An Interval is a combination of an IntervalSize
and an IntervalQuality
. It represents the relationship
between two Note
s.
Implementations
impl Interval
[src]
impl Interval
[src]pub fn new(
size: IntervalSize,
quality: IntervalQuality
) -> Result<Interval, IntervalError>
[src]
pub fn new(
size: IntervalSize,
quality: IntervalQuality
) -> Result<Interval, IntervalError>
[src]Instantiate a new Interval
. If an invalid combination is entered, such as a major fourth or a perfect third,
the function will return an error.
pub fn from_str(input: &str) -> Result<Interval, IntervalError>
[src]
pub fn from_str(input: &str) -> Result<Interval, IntervalError>
[src]Instantiate an Interval
using the shorthand documented in crate::primitives
. If the token cannot be
parsed or the desired interval is invalid, an error will be returned.
pub fn size(&self) -> &IntervalSize
[src]
pub fn quality(&self) -> &IntervalQuality
[src]
pub fn chromatic_size(&self) -> isize
[src]
pub fn chromatic_size(&self) -> isize
[src]The number of half steps between the top and bottom note in the interval. In the case of a diminished unison, the output could be negative
assert_eq!(7, Interval::new(Fifth, Perfect)?.chromatic_size()); assert_eq!(-1, Interval::new(Unison, Diminished(0))?.chromatic_size()); assert_eq!(-3, Interval::new(Second, Diminished(3))?.chromatic_size());
pub fn from_notes(lower: &Note, higher: &Note) -> Interval
[src]
pub fn from_notes(lower: &Note, higher: &Note) -> Interval
[src]Given two Note
s, calculate the interval that describes their relationship. While there is discourse around
the existence of a diminished unison, this library acknowledges
its existence since there is no concept of an octave.
assert_eq!(ivl!("A6")?, Interval::from_notes(¬e!("Bb")?, ¬e!("G#")?)); assert_eq!(ivl!("dU")?, Interval::from_notes(¬e!("F#")?, ¬e!("F")?));
Trait Implementations
impl Eq for Interval
[src]
impl StructuralEq for Interval
[src]
impl StructuralPartialEq for Interval
[src]
Auto Trait Implementations
impl RefUnwindSafe for Interval
impl Send for Interval
impl Sync for Interval
impl Unpin for Interval
impl UnwindSafe for Interval
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more