Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes

Raul::SMFWriter Class Reference
[Realtime Audio Utility Library]

Standard Midi File (Type 0) Writer. More...

#include <SMFWriter.hpp>

Inherits Raul::MIDISink.

Collaboration diagram for Raul::SMFWriter:
Collaboration graph

List of all members.

Public Member Functions

 SMFWriter (TimeUnit unit)
 Create a new SMF writer.
bool start (const std::string &filename, TimeStamp start_time) throw (std::logic_error)
 Start a write to an SMF file.
TimeUnit unit () const
void write_event (TimeStamp time, size_t ev_size, const unsigned char *ev) throw (std::logic_error)
 Write an event at the end of the file.
void flush ()
void finish () throw (std::logic_error)

Protected Member Functions

void write_header ()
void write_footer ()
void write_chunk_header (const char id[4], uint32_t length)
void write_chunk (const char id[4], uint32_t length, void *data)
size_t write_var_len (uint32_t val)
 Write an SMF variable length value.

Protected Attributes

std::string _filename
FILE * _fd
TimeUnit _unit
Raul::TimeStamp _start_time
Raul::TimeStamp _last_ev_time
 Time last event was written relative to _start_time.
uint32_t _track_size
uint32_t _header_size
 size of SMF header, including MTrk chunk header

Static Protected Attributes

static const uint32_t VAR_LEN_MAX = 0x0FFFFFFF

Detailed Description

Standard Midi File (Type 0) Writer.


Constructor & Destructor Documentation

Raul::SMFWriter::SMFWriter ( TimeUnit  unit  )  [explicit]

Create a new SMF writer.

unit must match the time stamp of ALL events passed to write, or terrible things will happen.

*** NOTE: Only beat time is implemented currently.


Member Function Documentation

bool Raul::SMFWriter::start ( const std::string &  filename,
Raul::TimeStamp  start_time 
) throw (std::logic_error)

Start a write to an SMF file.

filename Filename to write to. start_time Beat time corresponding to t=0 in the file (timestamps passed to write_event will have this value subtracted before writing).

void Raul::SMFWriter::write_event ( Raul::TimeStamp  time,
size_t  ev_size,
const unsigned char *  ev 
) throw (std::logic_error)

Write an event at the end of the file.

time is the absolute time of the event, relative to the start of the file (the start_time parameter to start). Must be monotonically increasing on successive calls to this method.

size_t Raul::SMFWriter::write_var_len ( uint32_t  value  )  [protected]

Write an SMF variable length value.

Returns:
size (in bytes) of the value written.

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