mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-02-22 03:41:16 +00:00
Handle MIDI End of track events (Credit: Matt Giuca). Fixes ticket #101.
This commit is contained in:
parent
8791c115c9
commit
15e6508ffd
2 changed files with 19 additions and 6 deletions
|
@ -1455,11 +1455,11 @@ FluidSynth can be also play MIDI files directly from a buffer in memory. If you
|
|||
const char MIDIFILE[] = {
|
||||
0x4d, 0x54, 0x68, 0x64, 0x00, 0x00, 0x00, 0x06,
|
||||
0x00, 0x01, 0x00, 0x01, 0x01, 0xe0, 0x4d, 0x54,
|
||||
0x72, 0x6b, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x90,
|
||||
0x72, 0x6b, 0x00, 0x00, 0x00, 0x20, 0x00, 0x90,
|
||||
0x3c, 0x64, 0x87, 0x40, 0x80, 0x3c, 0x7f, 0x00,
|
||||
0x90, 0x43, 0x64, 0x87, 0x40, 0x80, 0x43, 0x7f,
|
||||
0x00, 0x90, 0x48, 0x64, 0x87, 0x40, 0x80, 0x48,
|
||||
0x7f, 0x00, 0xff, 0x2f, 0x00,
|
||||
0x7f, 0x83, 0x60, 0xff, 0x2f, 0x00
|
||||
};
|
||||
|
||||
int main(int argc, char** argv)
|
||||
|
|
|
@ -585,6 +585,16 @@ fluid_midi_file_read_event(fluid_midi_file *mf, fluid_track_t *track)
|
|||
break;
|
||||
}
|
||||
mf->eot = 1;
|
||||
evt = new_fluid_midi_event();
|
||||
if (evt == NULL) {
|
||||
FLUID_LOG(FLUID_ERR, "Out of memory");
|
||||
result = FLUID_FAILED;
|
||||
break;
|
||||
}
|
||||
evt->dtime = mf->dtime;
|
||||
evt->type = MIDI_EOT;
|
||||
fluid_track_add_event(track, evt);
|
||||
mf->dtime = 0;
|
||||
break;
|
||||
|
||||
case MIDI_SET_TEMPO:
|
||||
|
@ -1204,12 +1214,15 @@ fluid_track_send_events(fluid_track_t *track,
|
|||
|
||||
track->ticks += event->dtime;
|
||||
|
||||
if (event->type != MIDI_SET_TEMPO) {
|
||||
if (!player || event->type == MIDI_EOT) {
|
||||
}
|
||||
else if (event->type == MIDI_SET_TEMPO) {
|
||||
fluid_player_set_midi_tempo(player, event->param1);
|
||||
}
|
||||
else {
|
||||
if (player->playback_callback)
|
||||
player->playback_callback(player->playback_userdata, event);
|
||||
}
|
||||
else if (player)
|
||||
fluid_player_set_midi_tempo(player, event->param1);
|
||||
}
|
||||
|
||||
fluid_track_next_event(track);
|
||||
|
||||
|
|
Loading…
Reference in a new issue