Struct MidiFile
#[non_exhaustive]pub struct MidiFile {
pub(crate) messages: Vec<MidiMessage>,
pub(crate) times: Vec<f64>,
}Expand description
Represents a standard MIDI file.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.messages: Vec<MidiMessage>§times: Vec<f64>Implementations§
§impl MidiFile
impl MidiFile
pub fn new_with_loop_type<R>(
reader: &mut R,
loop_type: MidiFileLoopType,
) -> Result<MidiFile, MidiFileError>where
R: Read,
pub fn new_with_loop_type<R>(
reader: &mut R,
loop_type: MidiFileLoopType,
) -> Result<MidiFile, MidiFileError>where
R: Read,
Loads a MIDI file from the stream with a specified loop type.
§Arguments
reader- The data stream used to load the MIDI file.loop_type- The type of the loop extension to be used.
§Remarks
MidiFileLoopType has the following variants:
LoopPoint(usize)- Specifies the loop start point by a tick value.RpgMaker- The RPG Maker style loop. CC #111 will be the loop start point.IncredibleMachine- The Incredible Machine style loop. CC #110 and #111 will be the start and end points of the loop.FinalFantasy- The Final Fantasy style loop. CC #116 and #117 will be the start and end points of the loop.
pub fn get_length(&self) -> f64
pub fn get_length(&self) -> f64
Get the length of the MIDI file in seconds.
pub fn get_messages(&self) -> &[MidiMessage]
pub fn get_messages(&self) -> &[MidiMessage]
Get the merged message list of the MIDI file.
Parallel to get_times: message i occurs at
get_times()[i]. Tempo changes are already folded into the times.
pub fn get_times(&self) -> &[f64]
pub fn get_times(&self) -> &[f64]
Get the time of every message in absolute seconds.
Parallel to get_messages.
pub fn new_with_events<I>(events: I) -> Result<MidiFile, MidiFileError>
pub fn new_with_events<I>(events: I) -> Result<MidiFile, MidiFileError>
Creates a MIDI file from an event list without parsing.
Times must be in non-decreasing order (same-time events allowed);
returns [MidiFileError::InvalidEventList] otherwise. Accepts any
iterator of (time, message) pairs.
pub fn extend_events<I>(&mut self, events: I) -> Result<(), MidiFileError>
pub fn extend_events<I>(&mut self, events: I) -> Result<(), MidiFileError>
Appends events to the end of the MIDI file.
Appended times must be non-decreasing and not earlier than the last
existing time; otherwise returns [MidiFileError::InvalidEventList]
and leaves the file unchanged. To replace all events, call
clear first.
pub fn clear(&mut self)
pub fn clear(&mut self)
Removes all events from the MIDI file.
Trait Implementations§
Auto Trait Implementations§
impl Forget for MidiFile
impl Freeze for MidiFile
impl RefUnwindSafe for MidiFile
impl Send for MidiFile
impl Sync for MidiFile
impl Unpin for MidiFile
impl UnsafeUnpin for MidiFile
impl UnwindSafe for MidiFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> Component for Twhere
T: 'static,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
impl<T> MaybeSync for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
impl<F, T, S> SimdInto<T, S> for Fwhere
T: SimdFrom<F, S>,
S: Simd,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.