mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2025-01-31 13:40:35 +00:00
do not pad invalid loops
This commit is contained in:
parent
f2eb657905
commit
cbd3efc7c5
1 changed files with 17 additions and 21 deletions
|
@ -3168,9 +3168,9 @@ fixup_sample (SFData * sf)
|
||||||
{
|
{
|
||||||
sam = (SFSample *) (p->data);
|
sam = (SFSample *) (p->data);
|
||||||
|
|
||||||
// The SoundFont 2.4 spec defines the loop start index as the first sample point of the loop
|
/* The SoundFont 2.4 spec defines the loop start index as the first sample point of the loop */
|
||||||
inv_start = (sam->loopstart < sam->start) || (sam->loopstart >= sam->loopend);
|
inv_start = (sam->loopstart < sam->start) || (sam->loopstart >= sam->loopend);
|
||||||
// while loop end is the first point AFTER the last sample of the loop.
|
/* while loop end is the first point AFTER the last sample of the loop */
|
||||||
inv_end = (sam->loopend > sam->end+1) || (sam->loopstart >= sam->loopend);
|
inv_end = (sam->loopend > sam->end+1) || (sam->loopstart >= sam->loopend);
|
||||||
|
|
||||||
/* if sample is not a ROM sample and end is over the sample data chunk
|
/* if sample is not a ROM sample and end is over the sample data chunk
|
||||||
|
@ -3187,26 +3187,22 @@ fixup_sample (SFData * sf)
|
||||||
return (OK);
|
return (OK);
|
||||||
}
|
}
|
||||||
else if (inv_start || inv_end)
|
else if (inv_start || inv_end)
|
||||||
{ /* loop is fowled?? (cluck cluck :) */
|
{
|
||||||
FLUID_LOG (FLUID_DBG, _("Sample '%s' has invalid loop,"
|
/* loop is fowled?? (cluck cluck :) */
|
||||||
" extending loop to full sample"), sam->name);
|
|
||||||
invalid_loops |= TRUE;
|
invalid_loops |= TRUE;
|
||||||
|
|
||||||
/* can pad loop by 8 samples and ensure at least 4 for loop (2*8+4) */
|
/* force incorrect loop points into the sample range, ignore padding */
|
||||||
if ((sam->end - sam->start) >= 20)
|
if(inv_start)
|
||||||
{
|
{
|
||||||
if(inv_start)
|
FLUID_LOG (FLUID_DBG, _("Sample '%s' has invalid loop start '%d',"
|
||||||
sam->loopstart = sam->start + 8;
|
" setting to sample start at '%d'+1"), sam->name, sam->loopstart, sam->start);
|
||||||
|
|
||||||
if(inv_end)
|
|
||||||
sam->loopend = sam->end - 8;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ /* loop is fowled, sample is tiny (can't pad 8 samples) */
|
|
||||||
if(inv_start)
|
|
||||||
sam->loopstart = sam->start + 1;
|
sam->loopstart = sam->start + 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(inv_end)
|
if(inv_end)
|
||||||
|
{
|
||||||
|
FLUID_LOG (FLUID_DBG, _("Sample '%s' has invalid loop stop '%d',"
|
||||||
|
" setting to sample stop at '%d'-1"), sam->name, sam->loopend, sam->end);
|
||||||
sam->loopend = sam->end - 1;
|
sam->loopend = sam->end - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue