[][src]Struct simple_tones::Note

pub struct Note { /* fields omitted */ }

Represents a musical note.

Implementations

impl Note[src]

pub fn new<D: Into<f64>>(pitch: NotePitch, duration: D) -> Self[src]

Constructs a new Note with a given NotePitch and a duration which represents the value of the note as a fraction. NoteDuration can be used as a helper enum.

Example

use simple_tones::{Note, NoteDuration};

let note = Note::new("A4".parse().unwrap(), NoteDuration::Whole);

Trait Implementations

impl Debug for Note[src]

impl Play for Note[src]

pub fn play(&self, stream_handle: &OutputStreamHandle, bar_duration: Duration)[src]

Plays this note on the given stream_handle for duration time. The sound is generated by a sine wave.

Example

use std::time;
use simple_tones::{Note, NoteType, NotePitch, Play};

let (_stream, stream_handle) = rodio::OutputStream::try_default().unwrap();
let note = Note::new(NotePitch::new(NoteType::A, 4), 1);
note.play(&stream_handle, time::Duration::from_secs(2));

Auto Trait Implementations

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, 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.