From 0a664e0797b0963555778fad795718ed79ebb770 Mon Sep 17 00:00:00 2001 From: Marcus Weseloh Date: Wed, 4 Apr 2018 11:03:47 +0200 Subject: [PATCH] Remove unnecessary conversion of sample pointers to offsets SFSample should provide the sample pointers as specified in the Soundfont file. If any mangling of the pointers is required, it should happen in the defsfont loader. --- src/sfloader/fluid_defsfont.c | 6 +++--- src/sfloader/fluid_sffile.c | 13 ++++--------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/sfloader/fluid_defsfont.c b/src/sfloader/fluid_defsfont.c index 1ed13c77..2e1f698f 100644 --- a/src/sfloader/fluid_defsfont.c +++ b/src/sfloader/fluid_defsfont.c @@ -1848,9 +1848,9 @@ fluid_sample_import_sfont(fluid_sample_t* sample, SFSample* sfsample, fluid_defs sample->data = sfont->sampledata; sample->data24 = sfont->sample24data; sample->start = sfsample->start; - sample->end = sfsample->start + sfsample->end; - sample->loopstart = sfsample->start + sfsample->loopstart; - sample->loopend = sfsample->start + sfsample->loopend; + sample->end = (sfsample->end > 0) ? sfsample->end - 1 : 0; /* marks last sample, contrary to SF spec. */ + sample->loopstart = sfsample->loopstart; + sample->loopend = sfsample->loopend; sample->samplerate = sfsample->samplerate; sample->origpitch = sfsample->origpitch; sample->pitchadj = sfsample->pitchadj; diff --git a/src/sfloader/fluid_sffile.c b/src/sfloader/fluid_sffile.c index 37a040a1..cf86026c 100644 --- a/src/sfloader/fluid_sffile.c +++ b/src/sfloader/fluid_sffile.c @@ -1595,9 +1595,9 @@ static int load_shdr(SFData *sf, unsigned int size) sf->sample = fluid_list_append(sf->sample, p); READSTR(sf, &p->name); READD(sf, p->start); - READD(sf, p->end); /* - end, loopstart and loopend */ - READD(sf, p->loopstart); /* - will be checked and turned into */ - READD(sf, p->loopend); /* - offsets in fixup_sample() */ + READD(sf, p->end); + READD(sf, p->loopstart); + READD(sf, p->loopend); READD(sf, p->samplerate); READB(sf, p->origpitch); READB(sf, p->pitchadj); @@ -1679,7 +1679,7 @@ static int fixup_igen(SFData *sf) return TRUE; } -/* convert sample end, loopstart and loopend to offsets and check if valid */ +/* Make sure sample start/end and loopstart/loopend pointers are valid */ static int fixup_sample(SFData *sf) { fluid_list_t *p; @@ -1780,11 +1780,6 @@ static int fixup_sample(SFData *sf) } } - /* convert sample end, loopstart, loopend to offsets from sam->start */ - sam->end -= sam->start + 1; /* marks last sample, contrary to SF spec. */ - sam->loopstart -= sam->start; - sam->loopend -= sam->start; - next_sample: p = fluid_list_next(p); }