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.
This commit is contained in:
Jonathan Gilbert 2024-09-06 11:59:24 -05:00
parent 50ad730c38
commit 3762a21741
10 changed files with 54 additions and 32 deletions

View file

@ -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.
@ -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);
}
}
@ -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))
{

View file

@ -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)

View file

@ -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)

View file

@ -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;

View file

@ -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) {

View file

@ -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

View file

@ -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;
}
/**

View file

@ -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)

View file

@ -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.

View file

@ -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");