FluidSynth / fluidsynth

Software synthesizer based on the SoundFont 2 specifications
https://www.fluidsynth.org
GNU Lesser General Public License v2.1
1.89k stars 259 forks source link

Fluidsynth's pan modulator amount is not correct #1395

Closed spessasus closed 1 month ago

spessasus commented 1 month ago

FluidSynth version

Execute fluidsynth --version and provide the output. 2.3.6

Describe the bug

Provide a clear and concise description of the current situation, e.g. how the bug manifests. Sfspec24.pdf section 8.4.6:

8.4.6 MIDI Continuous Controller 10 to Pan Position Source Enumeration = 0x028A (type=0, P=1, D=0, CC=1, index = 10) Destination Enumeration = Initial Attenuation Amount = 1000 tenths of a percent Amount Source Enumeration = 0x0 (No controller) Transform Enumeration = 0 (Linear)

Yet https://github.com/FluidSynth/fluidsynth/blob/66adce6ad9772dd7285370d3f78b6824b907c0e8/src/synth/fluid_synth.c#L396-L409

Spec says 1000, so why is it set to 500?

Amount of 1000 does not mean that the full range of the modulator is 1000, with 0 being -500, 64=0 and 127=500. The range is twice that because of bipolar transform: 0=-1000 64=0 127=1000, like with the pitch modulator.

With the current behavior, you can clearly notice this:

This is because, amount of 1000 always forces the sample to be on the desired channel. That is:

Where with amount being 500 like fluid sets:

I think this is why creative chose 1000 and not 500.

Expected behavior

Provide a clear and concise description of what you expected to happen. It should be 1000 and both of the attached soundfont's presets should pan in the same way.

Steps to reproduce

Please explain the steps required to duplicate the issue, esp. if you are able to provide a sample application. E.g. how to start fluidsynth, what shell commands to enter, what midi events to send, etc.

  1. boot up fluid
  2. run it with the attached soundfont
  3. select stereo square
  4. set CC10 to 0 or 127
  5. play a few notes
  6. repeat 3-5 with mono square
  7. hear the difference

Additional context

If you are able to illustrate the bug with an example, please provide simple source code below or as attached file. List any other information that is relevant to your issue, e.g. stack traces, related issues, build logs, suggestions on how to fix, links to related discussions at fluid-dev, etc. None

derselbst commented 1 month ago

@mawe42 I think this is the problem you observed 6 years ago which led to the creation of the custom balance modulator: https://lists.nongnu.org/archive/html/fluid-dev/2018-01/msg00006.html

Opinions?

mawe42 commented 1 month ago

@mawe42 I think this is the problem you observed 6 years ago which led to the creation of the custom balance modulator: https://lists.nongnu.org/archive/html/fluid-dev/2018-01/msg00006.html

Opinions?

Hm... interesting. I will have time to look at this in more detail over the weekend.

spessasus commented 1 month ago

Nevermind, the pan amount is correct. That is, using 1000 leads to the pan being too extreme: see this for detailed info by Christian. Closing this!