fluid-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [fluid-dev] Possible bugs in mod and release envelope math


From: David Henningsson
Subject: Re: [fluid-dev] Possible bugs in mod and release envelope math
Date: Mon, 11 Jul 2011 10:11:29 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110516 Thunderbird/3.1.10

On 2011-07-10 02:07, Andrew Suffield wrote:
I've been working through the source, and while I don't pretend to
fully understand what's going on here, I've spotted a couple of things
that seem wrong:


fluid_mod_get_value sets range1 and range2 to 127, which are used as
the divisor for linear and bipolar modulators. That means, for a
bipolar mod, an input of 0 maps to -1 and an input of 127 maps to 1,
and there is no input which maps to 0. I looked at SF2.01 and it says
the range should be from -1 to 127/128 (ie, range1 and range2 should
be 128).

This has the unfortunate consequence that the default pan setting of
64 does not generate identical output on both channels (which is how I
spotted this), and the optimisation in fluid_rvoice_buffers_mix is
defeated because there will never be a centered stereo sample
(although since it's clearly never worked, the merit of that
optimisation is questionable).

Thanks for the observation. But just changing the divisor to 128 seems
to me like that would make us lose the right endpoint (as 127/128 < 1)
instead, i e there would be no way to pan hard right. While diverging
from the standard is a bad idea in general, I wonder if there is a point
in trying to do that in this case?

An formula Y = (X-1)/126 would give both 0 and 1 as hard left, 64 as
center and 127 as hard right. Does that make sense to everybody?



fluid_voice_update_param contains these:

   case GEN_VOLENVRELEASE:             /* SF2.01 section 8.1.3 # 38 */
     x = _GEN(voice, GEN_VOLENVRELEASE);
     fluid_clip(x, FLUID_MIN_VOLENVRELEASE, 8000.0f);
     count = 1 + NUM_BUFFERS_RELEASE(x);
     fluid_voice_update_volenv(voice, FLUID_VOICE_ENVRELEASE,
                             count, 1.0f, count ? -1.0f / count : 0.0f, 0.0f, 
1.0f);
     break;

   case GEN_MODENVRELEASE:                                  /* SF 2.01 section 
8.1.3 # 30 */
     x = _GEN(voice, GEN_MODENVRELEASE);
     fluid_clip(x, -12000.0f, 8000.0f);
     count = 1 + NUM_BUFFERS_RELEASE(x);
     fluid_voice_update_modenv(voice, FLUID_VOICE_ENVRELEASE,
                             count, 1.0f, count ? -1.0f / count : 0.0f, 0.0f, 
2.0f);

     break;

Pay particular attention to the 'max' parameter on the release
section. It's set to 1 for volenv and 2 for modenv. Both volenv and
modenv have a max of 2 for the decay and sustain sections, so there's
no apparent reason for this variation. I'm not really sure what's
going on here but it feels strange.

I agree that it feels strange, but question is if it matters? For
release volumes, things should always ramp down anyway so any value >= 1 should be okay.

// David



reply via email to

[Prev in Thread] Current Thread [Next in Thread]