[−][src]Struct tonal::Chord
Represents a pitch or group of pitches with shared volume and length.
The reason both chords and single notes are represented by the same strcut is because I don't know of a better way of doing it without duplicating code.
Implementations
impl Chord
[src]
pub fn new(pitches: Vec<Pitch>, length: Length, volume: f64) -> Self
[src]
Creates a new chord.
pub fn new_major(root: Pitch, length: Length, volume: f64) -> Self
[src]
Creates a new major chord based off of the root.
This will construct a major chord by including the root, the pitch a major third above it, and the pitch a perfect fifth above it.
Examples
use tonal::*; let c4 = Pitch::new(Name::C, 4); let c_maj = Chord::new_major(c4, Length::Whole, 0.5); let correct = [c4, Pitch::new(Name::E, 4), Pitch::new(Name::G, 4)]; assert_eq!(c_maj.pitches(), &correct);
pub fn pitches(&self) -> &[Pitch]
[src]
Allows access to the pitches in this chord.
pub fn pitches_mut(&mut self) -> &mut Vec<Pitch>
[src]
Allows mutable access to the pitches in this chord.
pub fn samples(&self, bpm: f64, rate: u32) -> Samples
[src]
Returns an iterator of PCM samples representing this chord.
This is mostly useful for music playback.
Trait Implementations
impl Clone for Chord
[src]
impl Debug for Chord
[src]
impl PartialEq<Chord> for Chord
[src]
impl StructuralPartialEq for Chord
[src]
Auto Trait Implementations
impl RefUnwindSafe for Chord
impl Send for Chord
impl Sync for Chord
impl Unpin for Chord
impl UnwindSafe for Chord
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,