ardour
|
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <errno.h>
#include <ctype.h>
#include <arpa/inet.h>
#include "smf.h"
#include "smf_private.h"
Go to the source code of this file.
Functions | |
static struct chunk_header_struct * | next_chunk (smf_t *smf) |
static int | chunk_signature_matches (const struct chunk_header_struct *chunk, const char *signature) |
static int | parse_mthd_header (smf_t *smf) |
static int | parse_mthd_chunk (smf_t *smf) |
int | smf_extract_vlq (const unsigned char *buf, const size_t buffer_length, uint32_t *value, uint32_t *len) |
int | is_status_byte (const unsigned char status) |
static int | is_sysex_byte (const unsigned char status) |
static int | is_escape_byte (const unsigned char status) |
static int32_t | expected_sysex_length (const unsigned char status, const unsigned char *second_byte, const size_t buffer_length, int32_t *consumed_bytes) |
static int32_t | expected_escaped_length (const unsigned char status, const unsigned char *second_byte, const size_t buffer_length, int32_t *consumed_bytes) |
static int32_t | expected_message_length (unsigned char status, const unsigned char *second_byte, const size_t buffer_length) |
static int | extract_sysex_event (const unsigned char *buf, const size_t buffer_length, smf_event_t *event, uint32_t *len, int last_status) |
static int | extract_escaped_event (const unsigned char *buf, const size_t buffer_length, smf_event_t *event, uint32_t *len, int last_status) |
static int | extract_midi_event (const unsigned char *buf, const size_t buffer_length, smf_event_t *event, uint32_t *len, int last_status) |
static smf_event_t * | parse_next_event (smf_track_t *track) |
static char * | make_string (const unsigned char *buf, const size_t buffer_length, uint32_t len) |
int | smf_event_is_textual (const smf_event_t *event) |
char * | smf_event_extract_text (const smf_event_t *event) |
static int | parse_mtrk_header (smf_track_t *track) |
static int | event_is_end_of_track (const smf_event_t *event) |
int | smf_event_length_is_valid (const smf_event_t *event) |
int | smf_event_is_valid (const smf_event_t *event) |
static int | parse_mtrk_chunk (smf_track_t *track) |
static int | load_file_into_buffer (void **file_buffer, size_t *file_buffer_length, FILE *stream) |
smf_t * | smf_load_from_memory (const void *buffer, const size_t buffer_length) |
smf_t * | smf_load (FILE *file) |
Standard MIDI File format loader.
Definition in file smf_load.c.
|
static |
Returns 1, iff signature of the "chunk" is the same as string passed as "signature".
Definition at line 95 of file smf_load.c.
|
static |
Return 1 if event is end-of-the-track, 0 otherwise.
Definition at line 727 of file smf_load.c.
|
static |
Definition at line 305 of file smf_load.c.
|
static |
Returns expected length of the midi message (including the status byte), in bytes, for the given status byte. The "second_byte" points to the expected second byte of the MIDI message. "buffer_length" is the buffer length limit, counting from "second_byte". Returns value < 0 iff there was an error.
Definition at line 317 of file smf_load.c.
|
static |
Just like expected_message_length(), but only for System Exclusive messages. Note that value returned by this thing here is the length of SysEx "on the wire", not the number of bytes that this sysex takes in the file - in SMF format sysex contains VLQ telling how many bytes it takes, "on the wire" format does not have this.
Definition at line 279 of file smf_load.c.
|
static |
Definition at line 433 of file smf_load.c.
|
static |
Puts MIDI data extracted from from "buf" into "event" and number of consumed bytes into "len". In case valid status is not found, it uses "last_status" (so called "running status"). Returns 0 iff everything went OK, value < 0 in case of error.
Definition at line 493 of file smf_load.c.
|
static |
Definition at line 388 of file smf_load.c.
|
static |
Definition at line 263 of file smf_load.c.
int is_status_byte | ( | const unsigned char | status | ) |
Returns 1 if the given byte is a valid status byte, 0 otherwise.
Definition at line 248 of file smf_load.c.
|
static |
Definition at line 254 of file smf_load.c.
|
static |
Allocate buffer of proper size and read file contents into it.
Definition at line 824 of file smf_load.c.
|
static |
Takes "len" characters starting in "buf", making sure it does not access past the length of the buffer, and makes ordinary, zero-terminated string from it. May return NULL if there was any problem.
Definition at line 617 of file smf_load.c.
|
static |
Returns pointer to the next SMF chunk in smf->buffer, based on length of the previous one. Returns NULL in case of error.
Definition at line 56 of file smf_load.c.
|
static |
Parses MThd chunk, filling "smf" structure with values extracted from it. Returns 0 iff everything went OK.
Definition at line 154 of file smf_load.c.
|
static |
Verifies if MThd header looks OK. Returns 0 iff it does.
Definition at line 107 of file smf_load.c.
|
static |
Parse events and put it on the track.
Definition at line 792 of file smf_load.c.
|
static |
Verify if the next chunk really is MTrk chunk, and if so, initialize some track variables and return 0. Return different value otherwise.
Definition at line 696 of file smf_load.c.
|
static |
Locates, basing on track->next_event_offset, the next event data in track->buffer, interprets it, allocates smf_event_t and fills it properly. Returns smf_event_t or NULL, if there was an error. Allocating event means adding it to the track; see smf_event_new().
Definition at line 555 of file smf_load.c.
char* smf_event_extract_text | ( | const smf_event_t * | event | ) |
Extracts text from "textual metaevents", such as Text or Lyric.
Definition at line 668 of file smf_load.c.
int smf_event_is_textual | ( | const smf_event_t * | event | ) |
Definition at line 648 of file smf_load.c.
int smf_event_is_valid | ( | const smf_event_t * | event | ) |
Definition at line 770 of file smf_load.c.
int smf_event_length_is_valid | ( | const smf_event_t * | event | ) |
Definition at line 740 of file smf_load.c.
int smf_extract_vlq | ( | const unsigned char * | buf, |
const size_t | buffer_length, | ||
uint32_t * | value, | ||
uint32_t * | len | ||
) |
Interprets Variable Length Quantity pointed at by "buf" and puts its value into "value" and number of bytes consumed into "len", making sure it does not read past "buf" + "buffer_length". Explanation of Variable Length Quantities is here: http://www.borg.com/~jglatt/tech/midifile/vari.htm Returns 0 iff everything went OK, different value in case of error.
Definition at line 213 of file smf_load.c.
smf_t* smf_load | ( | FILE * | file | ) |
Loads SMF file.
file | Open file. |
Definition at line 930 of file smf_load.c.
smf_t* smf_load_from_memory | ( | const void * | buffer, |
const size_t | buffer_length | ||
) |
Creates new SMF and fills it with data loaded from the given buffer.
Definition at line 876 of file smf_load.c.