From 3762a217413043e3bbdb38e371a053884dc336cc Mon Sep 17 00:00:00 2001 From: Jonathan Gilbert Date: Fri, 6 Sep 2024 11:59:24 -0500 Subject: [PATCH] Split fluid_synth_set_reverb and fluid_synth_set_chorus calls into separate per-parameter calls in music_fluidsynth_mididevice.cpp. Changed calls to fluid_synth_set_reverb_on and fluid_synth_set_chorus_on to use fluid_synth_reverb_on and fluid_synth_chorus_on. Suppressed warnings about unused fread return values in music_timidity_mididevice.cpp, music_timiditypp_mididevice.cpp and instrum_dls.cpp. Corrected indentation in itread.c, readmod.c and readxm.c. Inlined the functionality of fluid_player_update_tempo inside fluid_player_set_bpm, as the former is deprecated and could be removed in a future version. Corrected Ym2612_Nuked_Emu::reset in Ym2612_Nuked.cpp to only call OPN2_Reset on chip_r when chip_r is _not_ NULL, instead of only when it is. Marked case ATTACK and case DECAY in envelope generation in OPL3.cpp as fallthrough to case DECAY and case SUSTAIN respectively. --- .../music_fluidsynth_mididevice.cpp | 29 ++++++++++++++----- .../mididevices/music_timidity_mididevice.cpp | 3 +- .../music_timiditypp_mididevice.cpp | 3 +- thirdparty/dumb/src/it/itread.c | 4 +-- thirdparty/dumb/src/it/readmod.c | 14 ++++----- thirdparty/dumb/src/it/readxm.c | 18 ++++++------ thirdparty/fluidsynth/src/midi/fluid_midi.c | 5 +++- .../game-music-emu/gme/Ym2612_Nuked.cpp | 2 +- thirdparty/oplsynth/OPL3.cpp | 2 ++ thirdparty/timidity/instrum_dls.cpp | 6 ++-- 10 files changed, 54 insertions(+), 32 deletions(-) diff --git a/source/mididevices/music_fluidsynth_mididevice.cpp b/source/mididevices/music_fluidsynth_mididevice.cpp index 1a33d3c..2e78c8f 100644 --- a/source/mididevices/music_fluidsynth_mididevice.cpp +++ b/source/mididevices/music_fluidsynth_mididevice.cpp @@ -130,10 +130,16 @@ FluidSynthMIDIDevice::FluidSynthMIDIDevice(int samplerate, std::vectordata; delta = 0; diff --git a/thirdparty/dumb/src/it/readmod.c b/thirdparty/dumb/src/it/readmod.c index f738027..2448dcc 100644 --- a/thirdparty/dumb/src/it/readmod.c +++ b/thirdparty/dumb/src/it/readmod.c @@ -281,15 +281,15 @@ static DUMB_IT_SIGDATA *it_mod_load_sigdata(DUMBFILE *f, int restrict_) int i; uint32 fft; - if ( dumbfile_seek(f, MOD_FFT_OFFSET, DFS_SEEK_SET) ) - return NULL; + if ( dumbfile_seek(f, MOD_FFT_OFFSET, DFS_SEEK_SET) ) + return NULL; - fft = dumbfile_mgetl(f); - if (dumbfile_error(f)) - return NULL; + fft = dumbfile_mgetl(f); + if (dumbfile_error(f)) + return NULL; - if ( dumbfile_seek(f, 0, DFS_SEEK_SET) ) - return NULL; + if ( dumbfile_seek(f, 0, DFS_SEEK_SET) ) + return NULL; sigdata = malloc(sizeof(*sigdata)); if (!sigdata) { diff --git a/thirdparty/dumb/src/it/readxm.c b/thirdparty/dumb/src/it/readxm.c index e3c082e..b239c1f 100644 --- a/thirdparty/dumb/src/it/readxm.c +++ b/thirdparty/dumb/src/it/readxm.c @@ -999,15 +999,15 @@ static DUMB_IT_SIGDATA *it_xm_load_sigdata(DUMBFILE *f, int * version) if (sigdata->speed == 0) sigdata->speed = 6; // Should we? What about tempo? sigdata->tempo = dumbfile_igetw(f); - // FT2 always clips restart position against the song length - if (sigdata->restart_position > sigdata->n_orders) - sigdata->restart_position = sigdata->n_orders; - // And FT2 starts playback on order 0, regardless of length, - // and only checks if the next order is greater than or equal - // to this, not the current pattern. Work around this with - // DUMB's playback core by overriding a zero length with one. - if (sigdata->n_orders == 0) - sigdata->n_orders = 1; + // FT2 always clips restart position against the song length + if (sigdata->restart_position > sigdata->n_orders) + sigdata->restart_position = sigdata->n_orders; + // And FT2 starts playback on order 0, regardless of length, + // and only checks if the next order is greater than or equal + // to this, not the current pattern. Work around this with + // DUMB's playback core by overriding a zero length with one. + if (sigdata->n_orders == 0) + sigdata->n_orders = 1; /* sanity checks */ // XXX diff --git a/thirdparty/fluidsynth/src/midi/fluid_midi.c b/thirdparty/fluidsynth/src/midi/fluid_midi.c index fa72327..5a44468 100644 --- a/thirdparty/fluidsynth/src/midi/fluid_midi.c +++ b/thirdparty/fluidsynth/src/midi/fluid_midi.c @@ -2489,7 +2489,10 @@ int fluid_player_set_bpm(fluid_player_t *player, int bpm) return FLUID_FAILED; /* to avoid a division by 0 */ } - return fluid_player_set_midi_tempo(player, 60000000L / bpm); + player->miditempo = 60000000L / bpm; + + fluid_player_update_tempo(player); + return FLUID_OK; } /** diff --git a/thirdparty/game-music-emu/gme/Ym2612_Nuked.cpp b/thirdparty/game-music-emu/gme/Ym2612_Nuked.cpp index fc49ac6..74cb3d1 100644 --- a/thirdparty/game-music-emu/gme/Ym2612_Nuked.cpp +++ b/thirdparty/game-music-emu/gme/Ym2612_Nuked.cpp @@ -1839,7 +1839,7 @@ const char *Ym2612_Nuked_Emu::set_rate(double sample_rate, double clock_rate) void Ym2612_Nuked_Emu::reset() { Ym2612_NukedImpl::ym3438_t *chip_r = reinterpret_cast(impl); - if ( !chip_r ) Ym2612_NukedImpl::OPN2_Reset( chip_r, static_cast(prev_sample_rate), static_cast(prev_clock_rate) ); + if ( chip_r ) Ym2612_NukedImpl::OPN2_Reset( chip_r, static_cast(prev_sample_rate), static_cast(prev_clock_rate) ); } void Ym2612_Nuked_Emu::mute_voices(int mask) diff --git a/thirdparty/oplsynth/OPL3.cpp b/thirdparty/oplsynth/OPL3.cpp index be1c717..21ccccd 100644 --- a/thirdparty/oplsynth/OPL3.cpp +++ b/thirdparty/oplsynth/OPL3.cpp @@ -1469,6 +1469,7 @@ double EnvelopeGenerator::getEnvelope(OPL3 *OPL3, int egt, int am) { envelope = 0; stage = DECAY; } + [[fallthrough]]; case DECAY: // The decay and release are linear. if(envelope>envelopeSustainLevel) { @@ -1477,6 +1478,7 @@ double EnvelopeGenerator::getEnvelope(OPL3 *OPL3, int egt, int am) { } else stage = SUSTAIN; + [[fallthrough]]; case SUSTAIN: // The Sustain stage is mantained all the time of the Key ON, // even if we are in non-sustaining mode. diff --git a/thirdparty/timidity/instrum_dls.cpp b/thirdparty/timidity/instrum_dls.cpp index 24c4c2e..8294ab7 100644 --- a/thirdparty/timidity/instrum_dls.cpp +++ b/thirdparty/timidity/instrum_dls.cpp @@ -144,8 +144,10 @@ RIFF_Chunk *LoadRIFF(FILE *src) chunk = new RIFF_Chunk; /* Make sure the file is in RIFF format */ - fread(&chunk->magic, 4, 1, src); - fread(&chunk->length, 4, 1, src); + if (!fread(&chunk->magic, 4, 1, src)) + ; + if (!fread(&chunk->length, 4, 1, src)) + ; chunk->length = LittleLong(chunk->length); if ( chunk->magic != RIFF ) { __Sound_SetError("Not a RIFF file");