Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modulation envelope attack is linear instead of convex #153

Closed
derselbst opened this issue Feb 28, 2016 · 15 comments
Closed

Modulation envelope attack is linear instead of convex #153

derselbst opened this issue Feb 28, 2016 · 15 comments

Comments

@derselbst
Copy link
Member

According to the 2.01/2.04 spec, both the volume and modulation envelopes should have a convex attack phase. FluidSynth correctly uses a convex attack for the volume envelope, but uses a linear attack for the modulation envelope.

You can hear the difference by comparing the two "modulation envelope test" OGG recordings (inside attached archive) between the Audigy 2 ZS and FluidSynth. In the recording, you will hear a single note playing through all stages of a modulation envelope that is mapped to the note's pitch. Hear the difference in the speed/curve of the initial rise in the note's pitch. The similarly-named .mid and .sf2 files can be used to test this yourself.

Reported by: mrbumpy409

Original Ticket: fluidsynth/tickets/155

@derselbst
Copy link
Member Author

Hi,

The recording is a very good demonstration. We can hear easly the fluidsynth attack for the modulation enveloppe that sounds 'linear'.

For fluidsynth modulation enveloppe:
After looking the code it works like you have experimented.
(i.e linear attack instead of convex).
In fact alls segments (attack,decay,release) are linear.

For fluidsynth amplitude enveloppe
After looking the code

  • Attack is linear insteed of convex as you assume. Please tell me if you hear that it sounds convex anywhere ?
  • Decay and release are exponentiel (i.e it decrease very fast versus
    linear decrease. The result is a kind of concave curve.

Conclusion: Attack for both enveloppes (modulation and amplitude)are not correct versus spec 2.01.

regards

Original comment by: jjceresa

@derselbst
Copy link
Member Author

Actually, the amplitude envelope is correct, because the curves are being calculated in decibels.

If you view the output of the amplitude envelope in a wave editor, it will appear to have a linear attack and a concave decay and release:
amp-envelope-normal

But if you view it on a decibel scale, you will see it is correct, with a convex attack and a linear decay and release:
amp-envelope-dB

This output is correct to the spec, and matches the output of my Audigy 2 ZS as well.

Original comment by: mrbumpy409

@derselbst
Copy link
Member Author

Hi,
Now i understand want you mean. In fact the shape of the volume envelope described by the specs. is the shape of what we hear (i.e the logarithmic response of our ear). Effectively during attack this response is convex.

Now, for modulation envelope attack to get convex shape, do you think that the same kind of function (i.e logaritmic) is suitable ?

Original comment by: jjceresa

@derselbst
Copy link
Member Author

I'm not sure, since I'm not a coder. Perhaps somebody else can answer this?

Original comment by: mrbumpy409

@derselbst
Copy link
Member Author

Now that I have had time to experiment with this, I am finding that I prefer FluidSynth's current mod envelope attack (linear) vs. the spec (convex). A linear attack actually makes more sense for a modulation envelope. For example, if you set the mod envelope to a 1 sec. attack and 1 sec. decay to cause a note's pitch to rise and then fall, you would expect the rise and fall to be along a similar slope. Using a convex attack curve results in a very quick initial rise that slows down as it reaches the top, which sounds weird, in my opinion.

So our options are:

  1. Keep the mod envelope attack linear, which makes more sense musically, but results in inaccurate rendering of some presets designed on SB hardware or other SoundFont synths.
  2. Go for maximum compatibility with the spec, even if the result isn't as musically strong. This will increase compatibility with older SoundFonts.

Opinions?

Original comment by: mrbumpy409

@derselbst
Copy link
Member Author

Hi,
From your experiment, it seems that both options are useful. In this case, theses options could be added (via API, shell commands).
Unfortunately i don't have SB hardware to compare the sound difference. I was wondering if you have the possibility to produce a short audio demo (Fluidsynth vs SB) ?.

Original comment by: jjceresa

@derselbst
Copy link
Member Author

Here are some audio examples so you can hear the difference between the convex mod envelope attack (Audigy, SF spec) and the linear mod envelope attack (FluidSynth).

  1. Mod envelope to pitch: Both attack and decay are set to 2 seconds in length.
    Audigy: You can hear how the Audigy sweeps the pitch up very quickly at first, slowing as it reaches the high point.
    FluidSynth: In FluidSynth, the slope of the attack and decay are identical (linear).

  2. Mod envelope to filter cutoff: Both attack and decay are set to 2 seconds in length.
    Audigy: The filter opens very quickly and then hangs out at an open level for a while before the decay kicks in.
    FluidSynth: Unlike the Audigy, Fluidsynth has a very even sweep up and down.

  3. GeneralUser GS "Sweep Pad"
    Here is an example of a real-world preset that is greatly affected by the shape of the modulation envelope attack curve. The original version of this preset was programmed for the Sound Blaster hardware synths, on which it sounds like this (Audigy). However, the same preset loaded into FluidSynth sounds like this instead. The attack sounds way too slow on FluidSynth. Both the Audigy and FluidSynth are playing a roughly 6.5 second attack phase, but the convex curve on the Audigy causes the filter sweep to happen much more quickly at the beginning of the attack phase. The downside to the convex curve here is that the full 6.5 seconds must elapse before the decay phase can begin, which can seem like forever if you want to create a sweep up and down effect.

For the most recent versions of GeneralUser GS, I have re-programmed "Sweep Pad" to sound correct with FluidSynth, using an attack time of roughly 1.75 seconds instead of 6.5. Here is what the new version sounds like using FluidSynth, and here is what it sounds like on the Audigy. Now FluidSynth sounds correct and the Audigy's filter opens too quickly.

So, you can see the problem, but the question remains: what is the ideal solution? To review the options:

  1. Keep the mod envelope attack linear, which makes more sense musically, but results in inaccurate rendering of some presets designed on SB hardware or other SoundFont synths.
  2. Go for maximum compatibility with the spec, even if the result isn't as musically strong. This will increase compatibility with older SoundFonts.

Original comment by: mrbumpy409

@derselbst
Copy link
Member Author

Thanks for the time to produce this good demonstration.
All audios examples are manifest and anyone can hear the problem clearly.

My opinion is that any musical need should not be limited by any technology or specification. It is obvious that the SoundFonts format which is a great idea should be updated with new functionalities.
For example the shape of the attack/decay/release segment could be chosen with new 'Generator shape property' (ie.concave,linear,convex).

But for now he question remains: what is the ideal solution?
Actally,I don't see an ideal solution, but

First: The least worst solution could be going for the maximum compatibilty (option 2 above). Increasing compatibily with older soundfonts is very important. Consequently that means that fluidsynth should be updated to have a default convex shape for Modulation Attack segment.

Second, the actual linear shape for Mod Attack, seems to be musically useful. So keeping this option inside Fluidsynth would be interesting (option 1 above). Whith the help of a setting, command, or API the synthesizer could be set in this option (linear or convex).

Of course that means that at Soundfont design time, we always need to think and maintain two set of Soundfonts; the one working only with the default convex shape and the other working only with the linear shape.

jean-jacques ceresa.

Original comment by: jjceresa

@derselbst
Copy link
Member Author

Yeah, I would also vote for going with the spec. I have had to maintain separate Audigy vs. FluidSynth versions of GeneralUser GS mainly due to this very issue. Providing a curve option is not a bad idea, although I tend to think that if you want to be able to customize envelope curves and filter types, etc., that is what a sampler format such as SFZ is for.

Original comment by: mrbumpy409

@mrbumpy409
Copy link

mrbumpy409 commented Jul 31, 2017

modulation envelope test.tar.gz

Here are the test files from my original bug report on the SourceForge bug tracker.

@jjceresa
Copy link
Collaborator

Here are the test files from my original bug report on the SourceForge bug tracker.

Hello, (since more than one year now !).Thanks a lot for this important missing archive.

although I tend to think that if you want to be able to customize envelope curves and filter types, etc., that is what a sampler format such as SFZ is for.

Not yet familiar with this format, after a quick look there are SFZ 1.0 and SFZ 2.0 and both are official but only SFZ 1.0 is documented. Did you know if SFZ 2.0 documentation is accessible elsewhere ? or may be could you advice about preference between both ?

@derselbst derselbst modified the milestones: 2.0, 2.0-post Dec 29, 2017
@mrbumpy409
Copy link

mrbumpy409 commented Jan 2, 2018 via email

@jjceresa
Copy link
Collaborator

jjceresa commented Jan 2, 2018

Many thanks for the hints!
jjc

@derselbst derselbst modified the milestones: 2.0-post, 2.1 Jun 24, 2018
@derselbst
Copy link
Member Author

Second, the actual linear shape for Mod Attack, seems to be musically useful. So keeping this option inside Fluidsynth would be interesting. [...] Of course that means that at Soundfont design time, we always need to think and maintain two set of Soundfonts;

The fact that fluidsynth uses a linear modenv attack is a bug. The spec is absolutely clear to use a convex shape (whether we like it or not). And because to avoid having to think about two versions of soundfonts out there, I dont want to introduce any setting for this.

@derselbst
Copy link
Member Author

Implemented by #406.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants