libsmf
smf_load.c File Reference

Standard MIDI File format loader. More...

Go to the source code of this file.

Functions

int is_status_byte (const unsigned char status)
 Returns 1 if the given byte is a valid status byte, 0 otherwise. More...
 
int smf_event_is_textual (const smf_event_t *event)
 
char * smf_event_extract_text (const smf_event_t *event)
 Extracts text from "textual metaevents", such as Text or Lyric. More...
 
int smf_event_length_is_valid (const smf_event_t *event)
 
int smf_event_is_valid (const smf_event_t *event)
 
smf_tsmf_load_from_memory (const void *buffer, const int buffer_length)
 Creates new SMF and fills it with data loaded from the given buffer. More...
 
smf_tsmf_load (const char *file_name)
 Loads SMF file. More...
 

Detailed Description

Standard MIDI File format loader.

Definition in file smf_load.c.

Function Documentation

◆ is_status_byte()

int is_status_byte ( const unsigned char  status)

Returns 1 if the given byte is a valid status byte, 0 otherwise.

Definition at line 251 of file smf_load.c.

Referenced by smf_event_is_valid(), and smf_event_new_from_bytes().

◆ smf_event_extract_text()

char * smf_event_extract_text ( const smf_event_t event)

Extracts text from "textual metaevents", such as Text or Lyric.

Returns
Zero-terminated string extracted from "text events" or NULL, if there was any problem.

Definition at line 647 of file smf_load.c.

References smf_event_struct::midi_buffer_length, and smf_event_is_textual().

◆ smf_event_is_textual()

int smf_event_is_textual ( const smf_event_t event)
Returns
1, if passed a metaevent containing text, that is, Text, Copyright, Sequence/Track Name, Instrument, Lyric, Marker, Cue Point, Program Name, or Device Name; 0 otherwise.

Definition at line 627 of file smf_load.c.

References smf_event_struct::midi_buffer, smf_event_struct::midi_buffer_length, and smf_event_is_metadata().

Referenced by smf_event_extract_text().

◆ smf_event_is_valid()

int smf_event_is_valid ( const smf_event_t event)
Returns
Nonzero, if MIDI data in the event is valid, 0 otherwise. For example, it checks if event length is correct.

Definition at line 745 of file smf_load.c.

References is_status_byte(), smf_event_struct::midi_buffer, smf_event_struct::midi_buffer_length, and smf_event_length_is_valid().

◆ smf_event_length_is_valid()

int smf_event_length_is_valid ( const smf_event_t event)
Returns
Nonzero, if event is as long as it should be, from the MIDI specification point of view. Does not work for SysExes - it doesn't recognize internal structure of SysEx.

Definition at line 718 of file smf_load.c.

References smf_event_struct::midi_buffer, smf_event_struct::midi_buffer_length, and smf_event_is_sysex().

Referenced by smf_event_is_valid().

◆ smf_load()

smf_t * smf_load ( const char *  file_name)

Loads SMF file.

Parameters
file_namePath to the file.
Returns
SMF or NULL, if loading failed.

Definition at line 912 of file smf_load.c.

References smf.

◆ smf_load_from_memory()

smf_t * smf_load_from_memory ( const void *  buffer,
const int  buffer_length 
)

Creates new SMF and fills it with data loaded from the given buffer.

Returns
SMF or NULL, if loading failed.

Definition at line 860 of file smf_load.c.

References smf_struct::file_buffer, smf_struct::file_buffer_length, smf_struct::next_chunk_offset, smf, and smf_new().