Expand description
Temporal arrangement of events
Fields
events: Vec<Event>
Implementations
sourceimpl Stream
impl Stream
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new empty Stream
with no events.
Examples
Basic usage:
use mumuse::music::stream::Stream;
let s = Stream::new();
sourcepub fn add_event(&mut self, event: Event)
pub fn add_event(&mut self, event: Event)
Adds event to stream
Examples
Basic usage:
use mumuse::music::{time::Time, note::Note, stream::{Stream, Event}};
use mumuse::messages::Status;
let mut stream: Stream = Stream::new();
let time: Time = Time::new(1, 16, 1);
let note: Note = Note::try_from("A3").unwrap();
stream.add_event(Event::new(time, Status::NoteOn, note));
sourcepub fn add_note(&mut self, note: Note, time: Time, duration: Duration)
pub fn add_note(&mut self, note: Note, time: Time, duration: Duration)
Adds note to stream
Examples
Basic usage:
use mumuse::music::{time::Time, note::Note, stream::Stream, duration::Duration};
let mut stream: Stream = Stream::new();
let note: Note = Note::try_from("A3").unwrap();
let time: Time = Time::new(1, 16, 1);
let duration: Duration = Duration::new(16, 1);
stream.add_note(note, time, duration);
sourcepub fn to_seconds(&self, bpm: f64, bpb: u32) -> Vec<(f64, Status, Note)>
pub fn to_seconds(&self, bpm: f64, bpb: u32) -> Vec<(f64, Status, Note)>
Converts Events to seconds timeline
In order to convert the stream with Time
events, one need to declare a bpm
(beats per minutes) and a bpb
(beats per bar).
Examples
Basic usage:
use mumuse::music::{time::Time, note::Note, stream::Stream, duration::Duration};
let mut stream: Stream = Stream::new();
let note: Note = Note::try_from("A3").unwrap();
let time: Time = Time::new(1, 16, 1);
let duration: Duration = Duration::new(16, 1);
stream.add_note(note, time, duration);
let stream_seconds = stream.to_seconds(120.0, 4);
sourcepub fn play(&self, conn_out: &mut MidiOutputConnection, bpm: f64, bpb: u32)
pub fn play(&self, conn_out: &mut MidiOutputConnection, bpm: f64, bpb: u32)
Plays stream of events in real time
Use ticking for playing the stream of events at regular intervals.
For each tick, the events with Time to seconds lying in the tick window are
sent as MIDI.
The bpm
(beats per minutes) and bpb
(beats per bar) are needed for the conversion
to seconds.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Stream
impl Send for Stream
impl Sync for Stream
impl Unpin for Stream
impl UnwindSafe for Stream
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more