readmidi.c (libtimidity-0.2.6) | : | readmidi.c (libtimidity-0.2.7) | ||
---|---|---|---|---|
skipping to change at line 312 | skipping to change at line 312 | |||
} | } | |||
#undef MIDIEVENT | #undef MIDIEVENT | |||
/* Read a midi track into the linked list, either merging with any previous | /* Read a midi track into the linked list, either merging with any previous | |||
tracks or appending to them. */ | tracks or appending to them. */ | |||
static int read_track(MidIStream *stream, MidSong *song, int append) | static int read_track(MidIStream *stream, MidSong *song, int append) | |||
{ | { | |||
MidEventList *meep; | MidEventList *meep; | |||
MidEventList *next, *newlist; | MidEventList *next, *newlist; | |||
sint32 len, next_pos, pos; | sint32 len; | |||
long next_pos, pos; | ||||
char tmp[4]; | char tmp[4]; | |||
meep = song->evlist; | meep = song->evlist; | |||
if (append && meep) | if (append && meep) | |||
{ | { | |||
/* find the last event in the list */ | /* find the last event in the list */ | |||
for (; meep->next; meep=meep->next) | for (; meep->next; meep=meep->next) | |||
; | ; | |||
song->at = meep->event.time; | song->at = meep->event.time; | |||
} | } | |||
skipping to change at line 409 | skipping to change at line 410 | |||
for (i=0; i<16; i++) | for (i=0; i<16; i++) | |||
{ | { | |||
current_bank[i]=0; | current_bank[i]=0; | |||
current_set[i]=0; | current_set[i]=0; | |||
current_program[i]=song->default_program; | current_program[i]=song->default_program; | |||
} | } | |||
tempo=500000; | tempo=500000; | |||
compute_sample_increment(song, tempo, divisions); | compute_sample_increment(song, tempo, divisions); | |||
our_event_count=0; | ||||
st=at=sample_cum=0; | ||||
counting_time=2; /* We strip any silence before the first NOTE ON. */ | ||||
/* This may allocate a bit more than we need */ | /* This may allocate a bit more than we need */ | |||
groomed_list=lp=(MidEvent *) timi_calloc(sizeof(MidEvent) * (song->event_count +1)); | groomed_list=lp=(MidEvent *) timi_calloc(sizeof(MidEvent) * (song->event_count +1)); | |||
if (!groomed_list) { | if (!groomed_list) { | |||
song->oom=1; | song->oom=1; | |||
free_midi_list(song); | free_midi_list(song); | |||
return NULL; | return NULL; | |||
} | } | |||
meep=song->evlist; | meep=song->evlist; | |||
our_event_count=0; | ||||
st=at=sample_cum=0; | ||||
counting_time=2; /* We strip any silence before the first NOTE ON. */ | ||||
for (i = 0; i < song->event_count; i++) | for (i = 0; i < song->event_count; i++) | |||
{ | { | |||
skip_this_event=0; | skip_this_event=0; | |||
if (meep->event.type==ME_TEMPO) | if (meep->event.type==ME_TEMPO) | |||
{ | { | |||
skip_this_event=1; | skip_this_event=1; | |||
} | } | |||
else switch (meep->event.type) | else switch (meep->event.type) | |||
{ | { | |||
skipping to change at line 592 | skipping to change at line 593 | |||
return NULL; | return NULL; | |||
} | } | |||
} | } | |||
len=SWAPBE32(len); | len=SWAPBE32(len); | |||
if (memcmp(tmp, "MThd", 4) || len < 6) | if (memcmp(tmp, "MThd", 4) || len < 6) | |||
{ | { | |||
DEBUG_MSG("Not a MIDI file!\n"); | DEBUG_MSG("Not a MIDI file!\n"); | |||
return NULL; | return NULL; | |||
} | } | |||
format=tracks=divisions_tmp = -1; | ||||
mid_istream_read(stream, &format, 2, 1); | mid_istream_read(stream, &format, 2, 1); | |||
mid_istream_read(stream, &tracks, 2, 1); | mid_istream_read(stream, &tracks, 2, 1); | |||
mid_istream_read(stream, &divisions_tmp, 2, 1); | mid_istream_read(stream, &divisions_tmp, 2, 1); | |||
format=SWAPBE16(format); | format=SWAPBE16(format); | |||
tracks=SWAPBE16(tracks); | tracks=SWAPBE16(tracks); | |||
divisions_tmp=SWAPBE16(divisions_tmp); | divisions_tmp=SWAPBE16(divisions_tmp); | |||
if (divisions_tmp<0) | if (divisions_tmp<0) | |||
{ | { | |||
/* SMPTE time -- totally untested. Got a MIDI file that uses this? */ | /* SMPTE time -- totally untested. Got a MIDI file that uses this? */ | |||
End of changes. 4 change blocks. | ||||
5 lines changed or deleted | 7 lines changed or added |