[−][src]Struct simple_tones::Player
The Player
is a struct used to play an Iterator
of types implementing Play
.
Example
use simple_tones::{Note, NoteDuration, Player}; let song = vec![ Note::new("C4".parse().unwrap(), NoteDuration::Quarter), Note::new("C4".parse().unwrap(), NoteDuration::Quarter), Note::new("D4".parse().unwrap(), NoteDuration::Eighth), Note::new("Eb4".parse().unwrap(), NoteDuration::Eighth), // | Note::new("D4".parse().unwrap(), NoteDuration::HalfDotted), // | Note::new("C4".parse().unwrap(), NoteDuration::Eighth), Note::new("G3".parse().unwrap(), NoteDuration::Eighth), Note::new("Ab4".parse().unwrap(), NoteDuration::Quarter), Note::new("G3".parse().unwrap(), NoteDuration::Eighth), Note::new("F3".parse().unwrap(), NoteDuration::Eighth), // | Note::new("G3".parse().unwrap(), NoteDuration::HalfDotted), // | Note::new("C4".parse().unwrap(), NoteDuration::Quarter), Note::new("C4".parse().unwrap(), NoteDuration::Quarter), Note::new("D4".parse().unwrap(), NoteDuration::Eighth), Note::new("Eb4".parse().unwrap(), NoteDuration::Eighth), // | Note::new("F4".parse().unwrap(), NoteDuration::HalfDotted), // | Note::new("G4".parse().unwrap(), NoteDuration::Eighth), Note::new("Eb4".parse().unwrap(), NoteDuration::Eighth), Note::new("D4".parse().unwrap(), NoteDuration::Eighth), Note::new("C4".parse().unwrap(), NoteDuration::Eighth), Note::new("Bb4".parse().unwrap(), NoteDuration::Quarter), // | Note::new("C4".parse().unwrap(), NoteDuration::HalfDotted), // | Note::new("F3".parse().unwrap(), NoteDuration::Half), ]; let np = Player::from_bpm(55); np.play(song.iter());
Implementations
impl Player
[src]
pub fn new(bar_duration: Duration) -> Self
[src]
Constructs a new Player
from the given bar duration, which describes how much time one whole note takes to play.
Example
use simple_tones::Player; let np = Player::new(std::time::Duration::from_secs_f64(0.5));
pub fn from_bpm(bpm: u32) -> Self
[src]
Constructs a new Player
from the given beats per minute. One beat is considered a quarter note.
Therefore, the formula to determine the duration of one bar d is:
d = 60 / bpm * 4
Example
use simple_tones::Player; let np = Player::from_bpm(120);
pub fn play<P: Play, N: Iterator<Item = P>>(&self, notes: N)
[src]
Plays an Iterator
of types implementing Play
on the standard audio device.
Auto Trait Implementations
impl !RefUnwindSafe for Player
[src]
impl !Send for Player
[src]
impl !Sync for Player
[src]
impl Unpin for Player
[src]
impl !UnwindSafe for Player
[src]
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,
pub 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, 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.
pub 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>,