Struct sorceress::pattern::Event[][src]

pub struct Event<M> {
    pub delta: f64,
    pub event: EventOrRest<M>,
}

An occurrence with timing information.

Events are used in Patterns to describe things that occur at a specific time. Events are most commonly used to describe musical events such as a note playing or a pitch changing, but can be used to describe any occurrence. The only information that is required by all events is a delta which determines the time delay until the next event in a sequence.

Examples

use sorceress::pattern::{Event, EventOrRest};

let event = Event::new(1.0, "hello");
let rest = Event::rest(2.0);

assert_eq!(
    event,
    Event {
        delta: 1.0,
        event: EventOrRest::Event("hello".to_owned()),
    }
);
assert_eq!(
    rest,
    Event::<String> {
        delta: 2.0,
        event: EventOrRest::Rest,
    }
);

Fields

delta: f64

The “logical time” delay until the next event. Instead of being specified as a Duration, delta is a floating point number. This lets whatever schedules the event determine how the delta value should be intepreted. For example: a tempo-aware scheduler can intepret the delta as a number of beats.

event: EventOrRest<M>

The event data or a musical rest.

Implementations

impl<M> Event<M>[src]

pub fn new(delta: f64, event: impl Into<M>) -> Event<M>[src]

Create a new event.

pub fn rest(delta: f64) -> Event<M>[src]

Create a rest event.

Trait Implementations

impl<M: Clone> Clone for Event<M>[src]

impl<M: Debug> Debug for Event<M>[src]

impl<M: PartialEq> PartialEq<Event<M>> for Event<M>[src]

impl<M: PartialOrd> PartialOrd<Event<M>> for Event<M>[src]

impl<M> StructuralPartialEq for Event<M>[src]

Auto Trait Implementations

impl<M> RefUnwindSafe for Event<M> where
    M: RefUnwindSafe

impl<M> Send for Event<M> where
    M: Send

impl<M> Sync for Event<M> where
    M: Sync

impl<M> Unpin for Event<M> where
    M: Unpin

impl<M> UnwindSafe for Event<M> where
    M: UnwindSafe

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.