From af0522461de3dc474e64cda2d12234a7a65c43bc Mon Sep 17 00:00:00 2001 From: Element Green Date: Sat, 28 Jun 2003 21:09:44 +0000 Subject: [PATCH] Fixed a crash bug from attempt to optimize ROM samples. --- fluidsynth/ChangeLog | 10 ++++++++++ fluidsynth/src/fluid_defsfont.c | 4 ++-- fluidsynth/src/fluid_voice.c | 5 ++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/fluidsynth/ChangeLog b/fluidsynth/ChangeLog index 51d1b839..f2b547c1 100644 --- a/fluidsynth/ChangeLog +++ b/fluidsynth/ChangeLog @@ -1,3 +1,13 @@ +2003-06-28 Josh Green + + * src/fluid_defsfont.c: Moved call to fluid_voice_optimize_sample + from fluid_inst_zone_import_sfont to fluid_defsfont_load. Also + reduced minimum sample size before rejection from 48 to 8 (could + be lower?). + * src/fluid_voice.c (fluid_voice_optimize_sample): Added a check + for sample->valid to ignore ROM samples which was causing a crash + with Vintage Dreams and other SoundFont files with ROM samples. + 2003-06-17 Josh Green Release version 1.0.2 diff --git a/fluidsynth/src/fluid_defsfont.c b/fluidsynth/src/fluid_defsfont.c index 71654004..728d8b8d 100644 --- a/fluidsynth/src/fluid_defsfont.c +++ b/fluidsynth/src/fluid_defsfont.c @@ -313,6 +313,7 @@ int fluid_defsfont_load(fluid_defsfont_t* sfont, const char* file) return FLUID_FAILED; } fluid_defsfont_add_sample(sfont, sample); + fluid_voice_optimize_sample(sample); p = fluid_list_next(p); } @@ -1384,7 +1385,6 @@ fluid_inst_zone_import_sfont(fluid_inst_zone_t* zone, SFZone *sfzone, fluid_defs FLUID_LOG(FLUID_ERR, "Couldn't find sample name"); return FLUID_FAILED; } - fluid_voice_optimize_sample(zone->sample); } /* Import the modulators (only SF2.1 and higher) */ @@ -1606,7 +1606,7 @@ fluid_sample_import_sfont(fluid_sample_t* sample, SFSample* sfsample, fluid_defs sample->valid = 0; FLUID_LOG(FLUID_WARN, "Ignoring sample %s: can't use ROM samples", sample->name); } - if (sample->end - sample->start < 48) { + if (sample->end - sample->start < 8) { sample->valid = 0; FLUID_LOG(FLUID_WARN, "Ignoring sample %s: too few sample data points", sample->name); } else { diff --git a/fluidsynth/src/fluid_voice.c b/fluidsynth/src/fluid_voice.c index 93ecfb63..a1fa957a 100644 --- a/fluidsynth/src/fluid_voice.c +++ b/fluidsynth/src/fluid_voice.c @@ -1978,7 +1978,10 @@ int fluid_voice_optimize_sample(fluid_sample_t* s) signed short peak; double result; int i; - + + /* ignore ROM and other(?) invalid samples */ + if (!s->valid) return (FLUID_OK); + if (!s->amplitude_that_reaches_noise_floor_is_valid){ /* Only once */ /* Scan the loop */ for (i = (int)s->loopstart; i < (int) s->loopend; i ++){