[−][src]Struct libatm::midi_event::MIDIChannelVoiceMessage
MIDI channel voice message
MIDI supports two main types of messages: Channel and System.
Channel messages are tied to a specific MIDI channel, whereas
System messages are not (and thus don't contain a channel number).
This library only supports channel messages, and more specifically
the NoteOn
and NoteOff
channel voice messages,
which actually produce sounds. For a detailed explanation of
MIDI messages, see appendix 1.1 of the document here:
https://www.cs.cmu.edu/~music/cmsip/readings/Standard-MIDI-file-format-updated.pdf.
Fields
delta_time: u8
status: u8
note: u8
velocity: u8
Implementations
impl MIDIChannelVoiceMessage
[src]
pub fn new(
delta_time: u8,
note: &MIDINote,
velocity: u8,
status: MIDIStatus,
channel: u8
) -> MIDIChannelVoiceMessage
[src]
delta_time: u8,
note: &MIDINote,
velocity: u8,
status: MIDIStatus,
channel: u8
) -> MIDIChannelVoiceMessage
Create new MIDIChannelVoiceMessage
Arguments
delta_time
: time delta since last MIDI channel messagenote
: MIDINote to playvelocity
: velocity with which to play the notestatus
: MIDIStatus bits of the messagechannel
: channel on which to play the message
Examples
// Create Middle C note and two MIDI events, one to "press" the key and // one to "release" they key after 5 ticks. let note = libatm::MIDINote::new(libatm::MIDINoteType::C, 4); let note_on_event = libatm::MIDIChannelVoiceMessage::new(0, ¬e, 0x64, libatm::MIDIStatus::NoteOn, 0); let note_off_event = libatm::MIDIChannelVoiceMessage::new(5, ¬e, 0, libatm::MIDIStatus::RunningStatus, 0);
Notes
- The meaning of
delta_time
is determined by thedivision
value present in the MIDIHeader. - A
NoteOn
event with a velocity of 0 is equivalent to aNoteOff
event. This library heavily exploits this feature, as well as running status, to produce the smallest possible MIDI files. - If the note type is MIDINoteType::Rest
then the velocity will automatically be set to 0 (equivalent to a
NoteOff
event).
pub fn write_buffer<T>(&self, target: &mut T) -> Result<()> where
T: WriteBytesExt,
[src]
T: WriteBytesExt,
Write MIDI channel message to buffer
Arguments
target
: buffer to write to
Examples
use byteorder::WriteBytesExt; // Target buffer let mut buffer = std::io::BufWriter::new(Vec::new()); // Middle C let note = libatm::MIDINote::new(libatm::MIDINoteType::C, 4); // Play for 5 ticks let note_on_event = libatm::MIDIChannelVoiceMessage::new(0, ¬e, 0x64, libatm::MIDIStatus::NoteOn, 0); let note_off_event = libatm::MIDIChannelVoiceMessage::new(5, ¬e, 0, libatm::MIDIStatus::RunningStatus, 0); // Write notes to buffer note_on_event.write_buffer(&mut buffer).unwrap(); note_off_event.write_buffer(&mut buffer).unwrap();
Trait Implementations
impl Clone for MIDIChannelVoiceMessage
[src]
fn clone(&self) -> MIDIChannelVoiceMessage
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for MIDIChannelVoiceMessage
[src]
impl Debug for MIDIChannelVoiceMessage
[src]
impl PartialEq<MIDIChannelVoiceMessage> for MIDIChannelVoiceMessage
[src]
fn eq(&self, other: &MIDIChannelVoiceMessage) -> bool
[src]
fn ne(&self, other: &MIDIChannelVoiceMessage) -> bool
[src]
impl StructuralPartialEq for MIDIChannelVoiceMessage
[src]
Auto Trait Implementations
impl RefUnwindSafe for MIDIChannelVoiceMessage
impl Send for MIDIChannelVoiceMessage
impl Sync for MIDIChannelVoiceMessage
impl Unpin for MIDIChannelVoiceMessage
impl UnwindSafe for MIDIChannelVoiceMessage
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,
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> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
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.
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>,