Drop MIDI files patch applied by upstream
Dennis Braun
11 months ago
0 | From c0e2ef4243b83f29620b2078fc0f1198bafd7d90 Mon Sep 17 00:00:00 2001 | |
1 | From: derselbst <tom.mbrt@googlemail.com> | |
2 | Date: Sun, 2 Apr 2023 17:31:24 +0200 | |
3 | Subject: [PATCH 46/49] Fix seamless looping between MIDI files | |
4 | ||
5 | Fixes #1227 | |
6 | --- | |
7 | src/midi/fluid_midi.c | 45 +++++++++++++++++++++++-------------------- | |
8 | 1 file changed, 24 insertions(+), 21 deletions(-) | |
9 | ||
10 | diff --git a/src/midi/fluid_midi.c b/src/midi/fluid_midi.c | |
11 | index 0676c452..b72c3914 100644 | |
12 | --- a/src/midi/fluid_midi.c | |
13 | +++ b/src/midi/fluid_midi.c | |
14 | @@ -2178,34 +2178,37 @@ fluid_player_callback(void *data, unsigned int msec) | |
15 | player->start_msec = msec; /* should be the (synth)-time of the last tempo change */ | |
16 | fluid_atomic_int_set(&player->seek_ticks, -1); /* clear seek_ticks */ | |
17 | } | |
18 | - | |
19 | - /* Once we've run out of MIDI events, keep playing until no voices are active */ | |
20 | - if(status == FLUID_PLAYER_DONE && fluid_synth_get_active_voice_count(player->synth) > 0) | |
21 | + | |
22 | + if(fluid_list_next(player->currentfile) == NULL && player->loop == 0) | |
23 | { | |
24 | - /* The first time we notice we've run out of MIDI events but there are still active voices, disable all hold pedals */ | |
25 | - if(!player->end_pedals_disabled) | |
26 | + /* Once we've run out of MIDI events, keep playing until no voices are active */ | |
27 | + if(status == FLUID_PLAYER_DONE && fluid_synth_get_active_voice_count(player->synth) > 0) | |
28 | { | |
29 | - for(i = 0; i < synth->midi_channels; i++) | |
30 | + /* The first time we notice we've run out of MIDI events but there are still active voices, disable all hold pedals */ | |
31 | + if(!player->end_pedals_disabled) | |
32 | { | |
33 | - fluid_synth_cc(player->synth, i, SUSTAIN_SWITCH, 0); | |
34 | - fluid_synth_cc(player->synth, i, SOSTENUTO_SWITCH, 0); | |
35 | + for(i = 0; i < synth->midi_channels; i++) | |
36 | + { | |
37 | + fluid_synth_cc(player->synth, i, SUSTAIN_SWITCH, 0); | |
38 | + fluid_synth_cc(player->synth, i, SOSTENUTO_SWITCH, 0); | |
39 | + } | |
40 | + | |
41 | + player->end_pedals_disabled = 1; | |
42 | } | |
43 | ||
44 | - player->end_pedals_disabled = 1; | |
45 | + status = FLUID_PLAYER_PLAYING; | |
46 | } | |
47 | ||
48 | - status = FLUID_PLAYER_PLAYING; | |
49 | - } | |
50 | - | |
51 | - /* Once no voices are active, if end_msec hasn't been scheduled, schedule it so we wait for reverb, etc to finish */ | |
52 | - if(status == FLUID_PLAYER_DONE && player->end_msec < 0) | |
53 | - { | |
54 | - player->end_msec = msec + FLUID_PLAYER_STOP_GRACE_MS; | |
55 | - } | |
56 | - /* If end_msec has been scheduled and is in the future, keep playing */ | |
57 | - if (player->end_msec >= 0 && msec < (unsigned int) player->end_msec) | |
58 | - { | |
59 | - status = FLUID_PLAYER_PLAYING; | |
60 | + /* Once no voices are active, if end_msec hasn't been scheduled, schedule it so we wait for reverb, etc to finish */ | |
61 | + if(status == FLUID_PLAYER_DONE && player->end_msec < 0) | |
62 | + { | |
63 | + player->end_msec = msec + FLUID_PLAYER_STOP_GRACE_MS; | |
64 | + } | |
65 | + /* If end_msec has been scheduled and is in the future, keep playing */ | |
66 | + if (player->end_msec >= 0 && msec < (unsigned int) player->end_msec) | |
67 | + { | |
68 | + status = FLUID_PLAYER_PLAYING; | |
69 | + } | |
70 | } | |
71 | ||
72 | /* Once there's no reason to keep playing, we're actually done */ | |
73 | -- | |
74 | 2.39.2 | |
75 |