[][src]Struct tonal::Chord

pub struct Chord { /* fields omitted */ }

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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.