Skip to content

Commit

Permalink
Split fluid_synth_set_reverb and fluid_synth_set_chorus calls into se…
Browse files Browse the repository at this point in the history
…parate 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.
  • Loading branch information
logiclrd committed Sep 6, 2024
1 parent 50ad730 commit 3762a21
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 32 deletions.
29 changes: 21 additions & 8 deletions source/mididevices/music_fluidsynth_mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,16 @@ FluidSynthMIDIDevice::FluidSynthMIDIDevice(int samplerate, std::vector<std::stri
throw std::runtime_error("Failed to create FluidSynth.\n");
}
fluid_synth_set_interp_method(FluidSynth, -1, fluidConfig.fluid_interp);
fluid_synth_set_reverb(FluidSynth, fluidConfig.fluid_reverb_roomsize, fluidConfig.fluid_reverb_damping,
fluidConfig.fluid_reverb_width, fluidConfig.fluid_reverb_level);
fluid_synth_set_chorus(FluidSynth, fluidConfig.fluid_chorus_voices, fluidConfig.fluid_chorus_level,
fluidConfig.fluid_chorus_speed, fluidConfig.fluid_chorus_depth, fluidConfig.fluid_chorus_type);
fluid_synth_set_reverb_group_roomsize(FluidSynth, -1, fluidConfig.fluid_reverb_roomsize);
fluid_synth_set_reverb_group_damp(FluidSynth, -1, fluidConfig.fluid_reverb_damping);
fluid_synth_set_reverb_group_width(FluidSynth, -1, fluidConfig.fluid_reverb_width);
fluid_synth_set_reverb_group_level(FluidSynth, -1, fluidConfig.fluid_reverb_level);
fluid_synth_set_chorus_group_nr(FluidSynth, -1, fluidConfig.fluid_chorus_voices);
fluid_synth_set_chorus_group_level(FluidSynth, -1, fluidConfig.fluid_chorus_level);
fluid_synth_set_chorus_group_speed(FluidSynth, -1, fluidConfig.fluid_chorus_speed);
fluid_synth_set_chorus_group_depth(FluidSynth, -1, fluidConfig.fluid_chorus_depth);
fluid_synth_set_chorus_group_type(FluidSynth, -1, fluidConfig.fluid_chorus_type);


// try loading a patch set that got specified with $mididevice.

Expand Down Expand Up @@ -320,11 +326,11 @@ void FluidSynthMIDIDevice::ChangeSettingInt(const char *setting, int value)
// fluid_settings_setint succeeded; update these settings in the running synth, too
else if (strcmp(setting, "synth.reverb.active") == 0)
{
fluid_synth_set_reverb_on(FluidSynth, value);
fluid_synth_reverb_on(FluidSynth, -1, value);
}
else if (strcmp(setting, "synth.chorus.active") == 0)
{
fluid_synth_set_chorus_on(FluidSynth, value);
fluid_synth_chorus_on(FluidSynth, -1, value);
}
}

Expand All @@ -346,11 +352,18 @@ void FluidSynthMIDIDevice::ChangeSettingNum(const char *setting, double value)

if (strcmp(setting, "z.reverb") == 0)
{
fluid_synth_set_reverb(FluidSynth, fluidConfig.fluid_reverb_roomsize, fluidConfig.fluid_reverb_damping, fluidConfig.fluid_reverb_width, fluidConfig.fluid_reverb_level);
fluid_synth_set_reverb_group_roomsize(FluidSynth, -1, fluidConfig.fluid_reverb_roomsize);
fluid_synth_set_reverb_group_damp(FluidSynth, -1, fluidConfig.fluid_reverb_damping);
fluid_synth_set_reverb_group_width(FluidSynth, -1, fluidConfig.fluid_reverb_width);
fluid_synth_set_reverb_group_level(FluidSynth, -1, fluidConfig.fluid_reverb_level);
}
else if (strcmp(setting, "z.chorus") == 0)
{
fluid_synth_set_chorus(FluidSynth, fluidConfig.fluid_chorus_voices, fluidConfig.fluid_chorus_level, fluidConfig.fluid_chorus_speed, fluidConfig.fluid_chorus_depth, fluidConfig.fluid_chorus_type);
fluid_synth_set_chorus_group_nr(FluidSynth, -1, fluidConfig.fluid_chorus_voices);
fluid_synth_set_chorus_group_level(FluidSynth, -1, fluidConfig.fluid_chorus_level);
fluid_synth_set_chorus_group_speed(FluidSynth, -1, fluidConfig.fluid_chorus_speed);
fluid_synth_set_chorus_group_depth(FluidSynth, -1, fluidConfig.fluid_chorus_depth);
fluid_synth_set_chorus_group_type(FluidSynth, -1, fluidConfig.fluid_chorus_type);
}
else if (FluidSettingsResultFailed == fluid_settings_setnum(FluidSettings, setting, value))
{
Expand Down
3 changes: 2 additions & 1 deletion source/mididevices/music_timidity_mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,8 @@ bool GUS_SetupConfig(const char* args)
if (f)
{
char test[12] = {};
fread(test, 1, 12, f);
if (!fread(test, 1, 12, f))
;
fclose(f);
// If the passed file is an SF2 sound font we need to use the special reader that fakes a config for it.
if (memcmp(test, "RIFF", 4) == 0 && memcmp(test + 8, "sfbk", 4) == 0)
Expand Down
3 changes: 2 additions & 1 deletion source/mididevices/music_timiditypp_mididevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ bool Timidity_SetupConfig(const char* args)
if (f)
{
char test[12] = {};
fread(test, 1, 12, f);
if (!fread(test, 1, 12, f))
;
fclose(f);
// If the passed file is an SF2 sound font we need to use the special reader that fakes a config for it.
if (memcmp(test, "RIFF", 4) == 0 && memcmp(test + 8, "sfbk", 4) == 0)
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/dumb/src/it/itread.c
Original file line number Diff line number Diff line change
Expand Up @@ -621,8 +621,8 @@ int32 _dumb_it_read_sample_data_adpcm4(IT_SAMPLE *sample, DUMBFILE *f)
int32 n, len, delta;
signed char * ptr, * end;
signed char compression_table[16];
if (dumbfile_getnc((char *)compression_table, 16, f) != 16)
return -1;
if (dumbfile_getnc((char *)compression_table, 16, f) != 16)
return -1;
ptr = (signed char *) sample->data;
delta = 0;

Expand Down
14 changes: 7 additions & 7 deletions thirdparty/dumb/src/it/readmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
18 changes: 9 additions & 9 deletions thirdparty/dumb/src/it/readxm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion thirdparty/fluidsynth/src/midi/fluid_midi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/game-music-emu/gme/Ym2612_Nuked.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ym2612_NukedImpl::ym3438_t*>(impl);
if ( !chip_r ) Ym2612_NukedImpl::OPN2_Reset( chip_r, static_cast<Bit32u>(prev_sample_rate), static_cast<Bit32u>(prev_clock_rate) );
if ( chip_r ) Ym2612_NukedImpl::OPN2_Reset( chip_r, static_cast<Bit32u>(prev_sample_rate), static_cast<Bit32u>(prev_clock_rate) );
}

void Ym2612_Nuked_Emu::mute_voices(int mask)
Expand Down
2 changes: 2 additions & 0 deletions thirdparty/oplsynth/OPL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions thirdparty/timidity/instrum_dls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3762a21

Please sign in to comment.