ardour
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Evoral::SMF< Time > Class Template Reference

#include <OldSMF.hpp>

Inheritance diagram for Evoral::SMF< Time >:
ARDOUR::SMFSource TestSMF

Classes

class  FileError
 

Public Member Functions

 SMF ()
 
virtual ~SMF ()
 
void seek_to_start () const
 
uint16_t ppqn () const
 
bool is_empty () const
 
bool eof () const
 
Time last_event_time () const
 
void begin_write ()
 
void append_event_delta (uint32_t delta_t, const Event< Time > &ev)
 
void end_write () THROW_FILE_ERROR
 
void flush ()
 
int flush_header ()
 
int flush_footer ()
 
 SMF ()
 
virtual ~SMF ()
 
int open (const std::string &path, int track=1) THROW_FILE_ERROR
 
int create (const std::string &path, int track=1, uint16_t ppqn=19200) THROW_FILE_ERROR
 
void close () THROW_FILE_ERROR
 
void seek_to_start () const
 
int seek_to_track (int track)
 
int read_event (uint32_t *delta_t, uint32_t *size, uint8_t **buf, event_id_t *note_id) const
 
uint16_t num_tracks () const
 
uint16_t ppqn () const
 
bool is_empty () const
 
void begin_write ()
 
void append_event_delta (uint32_t delta_t, uint32_t size, const uint8_t *buf, event_id_t note_id)
 
void end_write (std::string const &) THROW_FILE_ERROR
 
void flush ()
 
double round_to_file_precision (double val) const
 

Static Public Member Functions

static bool test (const std::string &path)
 

Protected Member Functions

int open (const std::string &path) THROW_FILE_ERROR
 
void close () THROW_FILE_ERROR
 
int read_event (uint32_t *delta_t, uint32_t *size, uint8_t **buf) const
 

Private Member Functions

void seek_to_footer_position ()
 
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)
 
uint32_t read_var_len () const
 

Private Attributes

FILE * _fd
 
Time _last_ev_time
 last frame time written, relative to source start More...
 
uint32_t _track_size
 
uint32_t _header_size
 size of SMF header, including MTrk chunk header More...
 
bool _empty
 true iff file contains(non-empty) events More...
 
smf_t_smf
 
smf_track_t_smf_track
 
Glib::Threads::Mutex _smf_lock
 

Static Private Attributes

static const uint16_t _ppqn = 19200
 

Detailed Description

template<typename Time>
class Evoral::SMF< Time >

Standard Midi File (Type 0)

Standard Midi File. Currently only tempo-based time of a given PPQN is supported.

Definition at line 31 of file OldSMF.hpp.

Constructor & Destructor Documentation

template<typename Time >
Evoral::SMF< Time >::SMF ( )

Definition at line 36 of file OldSMF.cpp.

template<typename Time >
Evoral::SMF< Time >::~SMF ( )
virtual

Definition at line 46 of file OldSMF.cpp.

template<typename Time >
Evoral::SMF< Time >::SMF ( )
inline

Definition at line 52 of file SMF.hpp.

template<typename Time >
virtual Evoral::SMF< Time >::~SMF ( )
virtual

Member Function Documentation

template<typename Time >
void Evoral::SMF< Time >::append_event_delta ( uint32_t  delta_t,
const Event< Time > &  ev 
)

Definition at line 284 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::append_event_delta ( uint32_t  delta_t,
uint32_t  size,
const uint8_t *  buf,
event_id_t  note_id 
)

Definition at line 310 of file SMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::begin_write ( )

Definition at line 307 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::begin_write ( )
template<typename Time >
void Evoral::SMF< Time >::close ( )
protected

Definition at line 96 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::close ( )
template<typename Time >
int Evoral::SMF< Time >::create ( const std::string &  path,
int  track = 1,
uint16_t  ppqn = 19200 
)

Attempt to create a new SMF file for reading and/or writing.

Returns
0 on success -1 if the file can not be created -2 if the track can not be created

Definition at line 143 of file SMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::end_write ( )

Definition at line 315 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::end_write ( std::string const &  )
template<typename Time >
bool Evoral::SMF< Time >::eof ( ) const
inline

Definition at line 40 of file OldSMF.hpp.

template<typename Time >
void Evoral::SMF< Time >::flush ( )

Definition at line 138 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::flush ( )
inline

Definition at line 74 of file SMF.hpp.

template<typename Time >
int Evoral::SMF< Time >::flush_footer ( )

Definition at line 175 of file OldSMF.cpp.

template<typename Time >
int Evoral::SMF< Time >::flush_header ( )

Definition at line 145 of file OldSMF.cpp.

template<typename Time >
bool Evoral::SMF< Time >::is_empty ( ) const
inline

Definition at line 39 of file OldSMF.hpp.

template<typename Time >
bool Evoral::SMF< Time >::is_empty ( ) const
inline

Definition at line 68 of file SMF.hpp.

template<typename Time >
Time Evoral::SMF< Time >::last_event_time ( ) const
inline

Definition at line 42 of file OldSMF.hpp.

template<typename Time >
uint16_t Evoral::SMF< Time >::num_tracks ( ) const

Definition at line 44 of file SMF.cpp.

template<typename Time >
int Evoral::SMF< Time >::open ( const std::string &  path)
protected

Attempt to open the SMF file for reading and writing.

Currently SMF is always read/write.

Returns
0 on success -1 if the file can not be opened for reading, -2 if the file can not be opened for writing

Definition at line 60 of file OldSMF.cpp.

template<typename Time >
int Evoral::SMF< Time >::open ( const std::string &  path,
int  track = 1 
)

Attempt to open the SMF file for reading and/or writing.

Returns
0 on success -1 if the file can not be opened or created -2 if the file exists but specified track does not exist

Definition at line 102 of file SMF.cpp.

template<typename Time >
uint16_t Evoral::SMF< Time >::ppqn ( ) const
inline

Definition at line 38 of file OldSMF.hpp.

template<typename Time >
uint16_t Evoral::SMF< Time >::ppqn ( ) const
template<typename Time >
int Evoral::SMF< Time >::read_event ( uint32_t *  delta_t,
uint32_t *  size,
uint8_t **  buf 
) const
protected

Read an event from the current position in file.

File position MUST be at the beginning of a delta time, or this will die very messily. ev.buffer must be of size ev.size, and large enough for the event. The returned event will have it's time field set to it's delta time, in SMF tempo-based ticks, using the rate given by ppqn() (it is the caller's responsibility to calculate a real time).

size should be the capacity of buf. If it is not large enough, buf will be freed and a new buffer allocated in its place, the size of which will be placed in size.

Returns event length (including status byte) on success, 0 if event was skipped (eg a meta event), or -1 on EOF (or end of track).

Definition at line 212 of file OldSMF.cpp.

template<typename Time >
int Evoral::SMF< Time >::read_event ( uint32_t *  delta_t,
uint32_t *  size,
uint8_t **  buf,
event_id_t note_id 
) const

Read an event from the current position in file.

File position MUST be at the beginning of a delta time, or this will die very messily. ev.buffer must be of size ev.size, and large enough for the event. The returned event will have it's time field set to it's delta time, in SMF tempo-based ticks, using the rate given by ppqn() (it is the caller's responsibility to calculate a real time).

buf must be a pointer to a buffer allocated with malloc, or a pointer to NULL. size must be the capacity of buf. If it is not large enough, buf will be reallocated and *size will be set to the new size of buf.

if the event is a meta-event and is an Evoral Note ID, then note_id will be set to the value of the NoteID; otherwise, meta-events will set note_id to -1.

Returns
event length (including status byte) on success, 0 if event was a meta event, or -1 on EOF (or end of track).

Definition at line 237 of file SMF.cpp.

template<typename Time >
uint32_t Evoral::SMF< Time >::read_var_len ( ) const
private
template<typename Time >
double Evoral::SMF< Time >::round_to_file_precision ( double  val) const

Definition at line 422 of file SMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::seek_to_footer_position ( )
private

Used by flush_footer() to find the position to write the footer

Definition at line 115 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::seek_to_start ( ) const

Definition at line 108 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::seek_to_start ( ) const
template<typename Time >
int Evoral::SMF< Time >::seek_to_track ( int  track)

Seek to the specified track (1-based indexing)

Returns
0 on success

Definition at line 61 of file SMF.cpp.

template<typename Time >
bool Evoral::SMF< Time >::test ( const std::string &  path)
static

Attempt to open the SMF file just to see if it is valid.

Returns
true on success false on failure

Definition at line 79 of file SMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::write_chunk ( const char  id[4],
uint32_t  length,
void *  data 
)
private

Definition at line 333 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::write_chunk_header ( const char  id[4],
uint32_t  length 
)
private

Definition at line 323 of file OldSMF.cpp.

template<typename Time >
void Evoral::SMF< Time >::write_footer ( )
private

Write the track footer at the current seek position

Definition at line 187 of file OldSMF.cpp.

template<typename Time >
size_t Evoral::SMF< Time >::write_var_len ( uint32_t  value)
private

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

Definition at line 343 of file OldSMF.cpp.

Member Data Documentation

template<typename Time >
bool Evoral::SMF< Time >::_empty
private

true iff file contains(non-empty) events

Definition at line 76 of file OldSMF.hpp.

template<typename Time >
FILE* Evoral::SMF< Time >::_fd
private

Definition at line 72 of file OldSMF.hpp.

template<typename Time >
uint32_t Evoral::SMF< Time >::_header_size
private

size of SMF header, including MTrk chunk header

Definition at line 75 of file OldSMF.hpp.

template<typename Time >
Time Evoral::SMF< Time >::_last_ev_time
private

last frame time written, relative to source start

Definition at line 73 of file OldSMF.hpp.

template<typename Time >
const uint16_t Evoral::SMF< Time >::_ppqn = 19200
staticprivate

Definition at line 70 of file OldSMF.hpp.

template<typename Time >
smf_t* Evoral::SMF< Time >::_smf
private

Definition at line 79 of file SMF.hpp.

template<typename Time >
Glib::Threads::Mutex Evoral::SMF< Time >::_smf_lock
mutableprivate

Definition at line 82 of file SMF.hpp.

template<typename Time >
smf_track_t* Evoral::SMF< Time >::_smf_track
private

Definition at line 80 of file SMF.hpp.

template<typename Time >
uint32_t Evoral::SMF< Time >::_track_size
private

Definition at line 74 of file OldSMF.hpp.


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