fn write<W: Write>(&self, running_status: &mut Option<u8>, out: &mut W) -> WriteResult<W> {
        //Running Status rules:
        // - MIDI Messages (0x80 ..= 0xEF) alter and use running status
        // - System Exclusive (0xF0) cancels and cannot use running status
        // - Escape (0xF7) cancels and cannot use running status
        // - Meta Messages (0xFF) cancel and cannot use running status
        match self {
            TrackEventKind::Midi { channel, message } => {
                let status = message.status_nibble() << 4 | channel.as_int();
                if Some(status) != *running_status {
                    //Explicitly write status
                    out.write(&[status])?;
                    *running_status = Some(status);
                }
                message.write(out)?;
            }
            TrackEventKind::SysEx(data) => {
                *running_status = None;
                out.write(&[0xF0])?;
                write_varlen_slice(data, out)?;
            }
            TrackEventKind::Escape(data) => {
                *running_status = None;
                out.write(&[0xF7])?;
                write_varlen_slice(data, out)?;
            }
            TrackEventKind::Meta(meta) => {
                *running_status = None;
                out.write(&[0xFF])?;
                meta.write(out)?;
            }
        }
        Ok(())
    }
/// Writes a single event to the given output writer.
///
/// `running_status` keeps track of the last MIDI status, in order to make proper use of
/// running status. It should be shared between consecutive calls, and should initially be set
/// to `None`.
Writes a single event to the given output writer.
`running_status` keeps track of the last MIDI status, in order to make proper use of
running status. It should be shared between consecutive calls, and should initially be set
to `None`.
Writes a single event to the given output writer . ` running_status ` keeps track of the last MIDI status in order to make proper use of running status . It should be shared between consecutive calls and should initially be set to ` None ` .
fn write<W: Write>(&self, running_status: &mut Option<u8>, out: &mut W) -> WriteResult<W> {
        //Running Status rules:
        // - MIDI Messages (0x80 ..= 0xEF) alter and use running status
        // - System Exclusive (0xF0) cancels and cannot use running status
        // - Escape (0xF7) cancels and cannot use running status
        // - Meta Messages (0xFF) cancel and cannot use running status
        match self {
            TrackEventKind::Midi { channel, message } => {
                let status = message.status_nibble() << 4 | channel.as_int();
                if Some(status) != *running_status {
                    //Explicitly write status
                    out.write(&[status])?;
                    *running_status = Some(status);
                }
                message.write(out)?;
            }
            TrackEventKind::SysEx(data) => {
                *running_status = None;
                out.write(&[0xF0])?;
                write_varlen_slice(data, out)?;
            }
            TrackEventKind::Escape(data) => {
                *running_status = None;
                out.write(&[0xF7])?;
                write_varlen_slice(data, out)?;
            }
            TrackEventKind::Meta(meta) => {
                *running_status = None;
                out.write(&[0xFF])?;
                meta.write(out)?;
            }
        }
        Ok(())
    }
fn write < W : Write > ( & self , running_status : & mut Option < u8 > , out : & mut W ) -> WriteResult < W > { //Running Status rules: // - MIDI Messages (0x80 ..= 0xEF) alter and use running status // - System Exclusive (0xF0) cancels and cannot use running status // - Escape (0xF7) cancels and cannot use running status // - Meta Messages (0xFF) cancel and cannot use running status match self { TrackEventKind :: Midi { channel , message } => { let status = message . status_nibble ( ) << 4 | channel . as_int ( ) ; if Some ( status ) != * running_status { //Explicitly write status out . write ( & [ status ] ) ? ; * running_status = Some ( status ) ; } message . write ( out ) ? ; } TrackEventKind :: SysEx ( data ) => { * running_status = None ; out . write ( & [ 0xF0 ] ) ? ; write_varlen_slice ( data , out ) ? ; } TrackEventKind :: Escape ( data ) => { * running_status = None ; out . write ( & [ 0xF7 ] ) ? ; write_varlen_slice ( data , out ) ? ; } TrackEventKind :: Meta ( meta ) => { * running_status = None ; out . write ( & [ 0xFF ] ) ? ; meta . write ( out ) ? ; } } Ok ( ( ) ) }
Writes a single event to the given output writer.
Writes a single event to the given output writer .
&self
running_status
&mut Option<u8>
out
&mut W
&self
running_status
&mut Option<u8>
out
&mut W