AudioDataLib
A C++ library of classes supporting a variety of audio-data tasks.
Loading...
Searching...
No Matches
AudioDataLib::MidiData::Event Class Referenceabstract

#include <MidiData.h>

Inheritance diagram for AudioDataLib::MidiData::Event:
AudioDataLib::MidiData::ChannelEvent AudioDataLib::MidiData::MetaEvent AudioDataLib::MidiData::SystemExclusiveEvent

Public Member Functions

 Event ()
 
virtual ~Event ()
 
virtual bool Decode (ByteStream &inputStream, Error &error)=0
 
virtual bool Encode (ByteStream &outputStream, Error &error) const =0
 
virtual std::string LogMessage () const =0
 

Public Attributes

uint64_t deltaTimeTicks
 

Detailed Description

Instances of the Event class are MIDI messages. There are three different types of such messages, and so there are three derivatives of this class; namely, MetaEvent, ChannelEvent and SystemExclusiveEvent. A common base ensures here that each derivative impliments an encoder and a decoder for data typically seen going to, or coming from, a MIDI port.

Encoding/decoding of events seems like it's something that should only be part of the MidiFileFormat class, but in other contexts we need to be able to encode an event (e.g., before we send it down to a MIDI device on a MIDI port for synthesis); and similarly, we also need to be able to decode a MIDI message (e.g., that we receive from a MIDI port for storage.)

Constructor & Destructor Documentation

◆ Event()

MidiData::Event::Event ( )

◆ ~Event()

MidiData::Event::~Event ( )
virtual

Member Function Documentation

◆ Decode()

virtual bool AudioDataLib::MidiData::Event::Decode ( ByteStream & inputStream,
Error & error )
pure virtual

Try to read and interpret bytes from the given stream as a MIDI message of the derived class type.

Parameters
[in,out]inputStreamThe byte stream from which to read bytes.
[out]errorAn error object containing reasons for failure if false is returned.
Returns
True is returned on success; false on failure.

Implemented in AudioDataLib::MidiData::SystemExclusiveEvent, AudioDataLib::MidiData::MetaEvent, and AudioDataLib::MidiData::ChannelEvent.

◆ Encode()

virtual bool AudioDataLib::MidiData::Event::Encode ( ByteStream & outputStream,
Error & error ) const
pure virtual

Try to write this MIDI message (of the derived class type) as a sequence of bytes to the given stream. This is how the message should be stored in a MIDI file or how it should appear when handed to, or received from, a MIDI device.

Parameters
[in,out]outputStreamThe byte stream to which bytes are to be written.
[out]errorAn error object containing reasons for failure if false is returned.
Returns
True is returned on success; false on failure.

Implemented in AudioDataLib::MidiData::SystemExclusiveEvent, AudioDataLib::MidiData::MetaEvent, and AudioDataLib::MidiData::ChannelEvent.

◆ LogMessage()

virtual std::string AudioDataLib::MidiData::Event::LogMessage ( ) const
pure virtual

Return a one-line, human-readable message for logging purposes.

Implemented in AudioDataLib::MidiData::SystemExclusiveEvent, AudioDataLib::MidiData::MetaEvent, and AudioDataLib::MidiData::ChannelEvent.

Member Data Documentation

◆ deltaTimeTicks

uint64_t AudioDataLib::MidiData::Event::deltaTimeTicks

The documentation for this class was generated from the following files: