surge-synthesizer / surge

Synthesizer plug-in (previously released as Vember Audio Surge)
https://surge-synthesizer.github.io/
GNU General Public License v3.0
3.09k stars 395 forks source link

FM3 Oscillators | Subharmonic and Harmonic Ratio Input #2363

Closed ghost closed 3 years ago

ghost commented 4 years ago

Documenting from Slack discussions, proposed enhancements to the Surge FM2 and FM3 oscillators to permit input a range of both subharmonic and harmonic values.

FM2 Oscillator Currently the M1 and M2 Ratio sliders of the FM2 oscillator permit specifying harmonics in the range of 1 to 32.

Proposed enhancements: Have the M1 and M2 Ratio sliders centered in their ranges, with the 1/1 in the center, and allow input of a range of sub/harmonics from -32 to 32.

Optionally, once the sliders are moved, and snapped to a particular ratio selection, offer the ability to typein floating point offset values in the right-click context menu with two decimal places of resolution, for specifying inharmonic ratios, such as 1.99, 3.01, 5.98, etc.

FM3 Oscillator Currently, the M1 and M2 Ratio slider controls permit input of ratios with two decimal places of floating point resolution in the range of 1 to 32, while the M3 Frequency slider operates exclusively in an absolute-frequency mode within the range of 13.75 to 25,087.71 Hz.

Proposed enhancements: Add a right-click context menu option that would enable independently switching each of the M1, M2 and M3 sliders between either Ratio or Absolute Frequency.

When any FM3 oscillator M1, M2 and M3 slider is in Ratio mode... Have the M1, M2 and M3 sliders centered in their ranges with the 1/1 in the center, and permit input of values in the range of -32.00 to 32.00, both using the slider controls, as well as typeins.

When any FM3 oscillator M1, M2 and M3 slider is in Absolute frequency mode... Basically mirror the current functionality of M3 to both M1 and M2, enabling input of values within the range of 13.75 to 25,087.71 Hz, using either the sliders or right-click typeins.

An additional consideration about switching the FM3 oscillator M1, M2 and M3 slider controls between Ratio and Absolute modes, is that the labels should contextually change as well to reflect their states, such that when any are in Ratio, the label will indicate M1, M2, M3 Ratio, and when in Absolute mode, the slider labels would indicate M1, M2, M2 Frequency.

baconpaul commented 4 years ago

Agree with all points and can implement them, with one exception. The 2 decimals on FM2. The primary difference between FM2 and FM3 is that FM2 constrains the ratios to integers, so we can't easily use floats there. The rest of these things (except maybe the label switches but probably even those too) can make it into 1.7.1

ghost commented 4 years ago

It also occurs that it might be prudent to make the FM2 and FM3 oscillators 'Nyquist aware', such that if during performance any harmonic specified in the M settings exceeds Nyquist, it would be silenced.

Conversely, for subharmonics that might drop below 0 Hz during performance, also disable them during operation.

Another option might be to use modulus calculations to fold intervals that will exceed allowed ranges back into ones that are permitted.

Obviously, there is little that can be done for out-of-range generated FM sidebands, but where the above options might be available, it would offer some method for either disabling (if out of range), or otherwise logically folding their values back into allowed ranges during operation, for less aliasing artifacts.

ghost commented 4 years ago

Understood on FM2 floats, and intuiting that, I was careful to use "Optionally" in the suggestions above on that detail.

mkruselj commented 4 years ago

But... FM oscillators don't work as an additive synthesizer, so you cannot disable harmonics just like that.

ghost commented 4 years ago

This was the way the old XA FM synths worked actually: any M that would exceed Nyquist, was silenced.

mkruselj commented 4 years ago

Ha but then you get a non-functional modulator operator. Dunno. Aliasing is sort of ingrained to FM (unless done in analog realm - which is super hard to do with precision!), it's what gives it its character, I'd say.

ghost commented 4 years ago

True, one must embrace the inherent realities of aliasing in FM synthesis, so, in agreement, where it occurs, it's just a natural artifact of the synthesis method; entirely expected and normal operation. Just mentioning the above, as food-for-DSP-thought.

baconpaul commented 4 years ago

We run all the oscillators at 2x sample rate, also.

As to turnoff above nyquist: Seems like it could run you off a cliff when modulating accidentally also (remember inside the osc, surge can't tell the difference between a modulated value and a entered value).

j5v commented 4 years ago

True, one must embrace the inherent realities of aliasing in FM synthesis, so, in agreement, where it occurs, it's just a natural artifact of the synthesis method; entirely expected and normal operation. Just mentioning the above, as food-for-DSP-thought.

Yes, the characteristic of the resulting noise will depend on the synth sampling rate. Interpolations, multisampling, etc., will help by a small factor, but never really get around the way that sampling a wavetable at high frequency can skip its slopes. Making them Nyquist-aware will be tricky, as you would need to know the context of the whole FM chain to understand how FM3 ends up affecting the power spectrum output by FM1 [1]. I think it comes down to patch designers being aware of the high-frequency content, and throwing a LP filter on it as required, preferably before they say, "Ouch!".

[1] It's most likely to happen with 'true FM', with FM chains, or with simple FM pairs where the modulator ratio*amount is high and the Waves involved are less smooth.

j5v commented 4 years ago

allow input of a range of sub/harmonics from -32 to 32.

I think there's a decision to be made here, about display and input notation for subharmonics.

  1. Do we want:

    • -1 to -32 for exact subharmonics, and 0.01 to 0.99 (to whatever precision) for irrationals,
    • 1/r notation for exact subharmonics, ...
  2. Would we need some UI state to indicate whether the intent was a subharmonic or irrational?

  3. FM ratios are remarkably sensitive to being slightly off-ratio, and some users might want to exploit this by detuning by less than 0.01x. As a stretch goal, should we allow greater precision, or (at the risk of cluttering the interface) have a detune slider for each operator? Is the use case strong enough to warrant this (Yamaha thought so, with a Detune on each operator, units: 0.01 cents)?

baconpaul commented 4 years ago

Right now FM3 goes from 0 -> 32; where x in [epsilon,1) is the same as 1/x. My plan was to adjust the slider so it adjusts the float non-uniformly and let the typein let you say 1/16 or 1/16.002.

Much more to say here but that is one of the key things we can do without changing the synth at all.

FM2 is trickier.

mkruselj commented 4 years ago

FM ratios are remarkably sensitive to being slightly off-ratio, and some users might want to exploit this by detuning by less than 0.01x. As a stretch goal, should we allow greater precision, or (at the risk of cluttering the interface) have a detune slider for each operator? Is the use case strong enough to warrant this (Yamaha thought so, with a Detune on each operator, units: 0.01 cents)?

This is already handled in Surge by having High-precision value readouts enabled in Menu->User settings.

mkruselj commented 4 years ago

@Jacky-Ligon This issue seems to be a sort of a duplicate of #2051, so I suppose just add Sine in title and we can close the older one?

ghost commented 4 years ago

@baconpaul

Just checking out FM3 in Surge-NIGHTLY-2020-09-12-aab5b49 | Windows 10 x64, VST3i

On first test here, ratios and float typeins seem to be working as intended for M1 and M2, and amazing new sounds are coming from FM3.

Forgive if I missed it in discussions, but M3 doesn't seem to yet have the extended functionality applied to this build.

And do seem to recall that absolute for all modulators will follow at some point.

But this is a really spectacular start. Thanks much for it all, and very excited for this new enhancement.

baconpaul commented 4 years ago

Yes just one step of many. But wanted to be sure step 1 was the right path!

baconpaul commented 3 years ago

Talking with Jacky: We decided to just apply these to FM3. Still work to do, but basically now ratio is extendable we just need to make each of the M sliders absolute/ratio swappable and preserve streaming.

mkruselj commented 3 years ago

Does it not make sense to have it on FM2 as well?

baconpaul commented 3 years ago

FM2 is harder for a couple of reasons, including those sliders all being ints.