diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-03 00:06:42 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-11-03 00:06:42 +0000 |
commit | a188e69aae053ba78ccef58b1c34c9279c83a0b3 (patch) | |
tree | 32a3dcd67fb2ee3c91f50b8784d35a9b9d35cf33 | |
parent | fb048ebc30760fe11caef050dfb3da1817e57509 (diff) |
make VLQ save+restore functions publically accessible, for use with meta-events
git-svn-id: svn://localhost/ardour2/branches/3.0@7952 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r-- | libs/evoral/src/libsmf/smf.h | 6 | ||||
-rw-r--r-- | libs/evoral/src/libsmf/smf_load.c | 10 | ||||
-rw-r--r-- | libs/evoral/src/libsmf/smf_save.c | 8 |
3 files changed, 15 insertions, 9 deletions
diff --git a/libs/evoral/src/libsmf/smf.h b/libs/evoral/src/libsmf/smf.h index 5e3e2d1859..7f4aa402c0 100644 --- a/libs/evoral/src/libsmf/smf.h +++ b/libs/evoral/src/libsmf/smf.h @@ -386,6 +386,12 @@ int smf_event_is_textual(const smf_event_t *event) WARN_UNUSED_RESULT; char *smf_event_decode(const smf_event_t *event) WARN_UNUSED_RESULT; char *smf_event_extract_text(const smf_event_t *event) WARN_UNUSED_RESULT; +/* Routines for dealing with Variable Length Quantities (VLQ's). + Slightly odd names reflect original static names within libsmf + */ +int smf_format_vlq (unsigned char *buf, int length, unsigned long value); +int smf_extract_vlq(const unsigned char *buf, const size_t buffer_length, uint32_t *value, uint32_t *len); + /* Routines for loading SMF files. */ smf_t *smf_load(FILE *) WARN_UNUSED_RESULT; smf_t *smf_load_from_memory(const void *buffer, const size_t buffer_length) WARN_UNUSED_RESULT; diff --git a/libs/evoral/src/libsmf/smf_load.c b/libs/evoral/src/libsmf/smf_load.c index cebca73b82..060dc5849e 100644 --- a/libs/evoral/src/libsmf/smf_load.c +++ b/libs/evoral/src/libsmf/smf_load.c @@ -206,8 +206,8 @@ parse_mthd_chunk(smf_t *smf) * 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. */ -static int -extract_vlq(const unsigned char *buf, const size_t buffer_length, uint32_t *value, uint32_t *len) +int +smf_extract_vlq(const unsigned char *buf, const size_t buffer_length, uint32_t *value, uint32_t *len) { uint32_t val = 0; const unsigned char *c = buf; @@ -284,7 +284,7 @@ expected_sysex_length(const unsigned char status, const unsigned char *second_by return (-1); } - extract_vlq(second_byte, buffer_length, &sysex_length, &len); + smf_extract_vlq(second_byte, buffer_length, &sysex_length, &len); if (consumed_bytes != NULL) *consumed_bytes = len; @@ -558,7 +558,7 @@ parse_next_event(smf_track_t *track) assert(buffer_length > 0); /* First, extract time offset from previous event. */ - if (extract_vlq(c, buffer_length, &time, &len)) + if (smf_extract_vlq(c, buffer_length, &time, &len)) goto error; c += len; @@ -655,7 +655,7 @@ smf_event_extract_text(const smf_event_t *event) return (NULL); } - extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); + smf_extract_vlq((void *)&(event->midi_buffer[2]), event->midi_buffer_length - 2, &string_length, &length_length); if (string_length <= 0) { g_critical("smf_event_extract_text: truncated MIDI message."); diff --git a/libs/evoral/src/libsmf/smf_save.c b/libs/evoral/src/libsmf/smf_save.c index b03bf90044..b99af75461 100644 --- a/libs/evoral/src/libsmf/smf_save.c +++ b/libs/evoral/src/libsmf/smf_save.c @@ -156,8 +156,8 @@ track_append(smf_track_t *track, const void *buffer, const int buffer_length) return (0); } -static int -format_vlq(unsigned char *buf, int length, unsigned long value) +int +smf_format_vlq(unsigned char *buf, int length, unsigned long value) { int i; unsigned long buffer; @@ -212,7 +212,7 @@ smf_event_new_textual(int type, const char *text) event->midi_buffer[0] = 0xFF; event->midi_buffer[1] = type; - vlq_length = format_vlq(event->midi_buffer + 2, MAX_VLQ_LENGTH - 2, text_length); + vlq_length = smf_format_vlq(event->midi_buffer + 2, MAX_VLQ_LENGTH - 2, text_length); copied_length = snprintf((char *)event->midi_buffer + vlq_length + 2, event->midi_buffer_length - vlq_length - 2, "%s", text); assert(copied_length == text_length); @@ -231,7 +231,7 @@ write_vlq(smf_event_t *event, unsigned long value) unsigned char buf[MAX_VLQ_LENGTH]; int vlq_length; - vlq_length = format_vlq(buf, MAX_VLQ_LENGTH, value); + vlq_length = smf_format_vlq(buf, MAX_VLQ_LENGTH, value); return (track_append(event->track, buf, vlq_length)); } |