Musical Soft Clipping Circuits - Tri-to-Sine Waveshapers & the Differential Pair

Started by bowanderror, September 27, 2021, 05:42:38 PM

Previous topic - Next topic

Vivek

Quote from: ElectricDruid on September 29, 2021, 05:00:16 PM
Quote from: Vivek on September 29, 2021, 12:11:18 PM
Quote from: Steben on September 29, 2021, 11:59:11 AM
The tanhx function has an ultimate hard clipping that goes beyond diodes but has a softer knee than single diodes.

How can we mathematically measure and compare "softness" of knees ?

I thought RGs "take a differential" suggestion was a good idea for looking at the slope of the curves, rather than the curves themselves.
For the softness of the knees, you'd need a second differential, so you could see how fast the slope changes from one thing to another.


Please check if this line of thinking is OK





Suppose we have a linear part of a transfer curve represented by line B

and it meets the saturated part represented by line A

and we assume that A and B are linked with arcs that are tangent to A and B

and there are many such possible arcs, of different radii that could join A and B, representing many levels of smoothness.

Hence, if we were to invent a measure of smoothness of clip, we have to find some standard way to measure the radius of that arc (Bigger radius = smoother transition)

(Now real life is never so simple, and possibly the interconnect between A and B is a squished arc or crazy spline instead of a pure arc, hence some standards of how to measure effective radius will have to be established)


PS: there seem to be very few ways to influence the radius of the interconnect. For rail to rail saturated opamps, maybe Rob's diagram of clipping diodes referenced to Vcc can add a new Knee. I dont know how to influence radius of interconnect for differential pair. Piecewise diode functions might be useful for some situations and I want to try that for LG1

Steben

Feedback gets you "sharper" but think swiping the linear line to the right with less gain.
  • SUPPORTER
Rules apply only for those who are not allowed to break them

niektb

In my faust simulation I used 1/arctan(a)*arctan(ax), sounds very smooth but the output isn't fully bounded. (with a being a distortion constant and x input signal)

Vivek

Quote from: niektb on September 30, 2021, 04:19:21 AM
In my faust simulation I used 1/arctan(a)*arctan(ax), sounds very smooth but the output isn't fully bounded. (with a being a distortion constant and x input signal)

I entered your function into https://www.desmos.com/calculator/ to have a look

I really wonder what is the sonic difference between all these different transfer functions. They all seem so similar ie some linear part close to zero crossing, some curved part, some saturated part (or ever expanding non-bounded) and optionally some degree of asymmetry

Teemu, RG, Craig etc have in the past said that the EQ before and after the distortion makes more difference than the actual method of distortion.

Steben

Quote from: Vivek on September 30, 2021, 04:59:23 AM
Quote from: niektb on September 30, 2021, 04:19:21 AM
In my faust simulation I used 1/arctan(a)*arctan(ax), sounds very smooth but the output isn't fully bounded. (with a being a distortion constant and x input signal)

I entered your function into https://www.desmos.com/calculator/ to have a look

I really wonder what is the sonic difference between all these different transfer functions. They all seem so similar ie some linear part close to zero crossing, some curved part, some saturated part (or ever expanding non-bounded) and optionally some degree of asymmetry

Teemu, RG, Craig etc have in the past said that the EQ before and after the distortion makes more difference than the actual method of distortion.

More yes. Only no.
Fact is as mentioned earlier many power amps are rather hard clipping. The AC30 or 1974 for example are not.
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Rob Strand

QuoteFact is as mentioned earlier many power amps are rather hard clipping. The AC30 or 1974 for example are not.

http://www.tonestack.net/articles/guitar-amps/tube-vs-solid-state.html

Marshall_JMP1987_power_amp_distortion


Using the current limit idea I got this circuit which is half-baked in terms of circuit design.   The crossover distortion is too much.  Yeah, I could probably increase the input resistor.    The rounded clipping isn't too hard to sharpen up based on the stuff in my previous post.


Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

teemuk

QuoteMore yes. Only no.

This.

In my experience, even difference of clipping with "hard" edges versus clipping with very "soft" edges is a subtle one. In practice there is a slight difference in timbre and the softer clipping has more gradual morph into distortion but, IME, distortion at "soft" knee region is still very audible distortion. Maybe not as "bright" and "aggressive" as hard brickwall clipping but audible clipping nonetheless. If even this difference is subtle then it only makes sense that more subtle differences in knee are even more subtle to perceive.

And this especially because we sense transients very poorly. A distorted transient can be nearly inaudible, and by the time we have so much distortion in average to become perceptible we have also so much distortion that subtleties of the knee area have become almost negligible. The softer clipping just has a little bit less of "bite".

But hey, you can always audition the effect yourself and make your own conclusions. You don't have to trust our, or my, word for it.

IME, common critique about very soft clipping circuits, such as MOSFET inverters for example, is about their blurry tone and lack of headroom. If you look at the graphs it would make sense to hear more about transparent and warm distortion at intermediate gain levels but no; too fuzzy and blurry, and too early. And you seldom see these very soft clippers employed in practice, even though their design is trivial. Even most of the praised tube power amps are not the type of designs that could and would clip very softly. Generally I believe all this soft clipping stuff enjoys way too much credit. It's in the same category as speculation of even versus odd harmonics.

And yes, I firmly believe you achieve much more with EQ. You can audition soft versus hard clipping circuit but I'm pretty sure you hear much more prominent differences when you audition a HPF vs. no HPF prior to that circuit, or LPF and no LPF post that circuit.

Steben

Quote from: teemuk on September 30, 2021, 06:17:18 AM
QuoteMore yes. Only no.

This.

In my experience, even difference of clipping with "hard" edges versus clipping with very "soft" edges is a subtle one. In practice there is a slight difference in timbre and the softer clipping has more gradual morph into distortion but, IME, distortion at "soft" knee region is still very audible distortion. Maybe not as "bright" and "aggressive" as hard brickwall clipping but audible clipping nonetheless. If even this difference is subtle then it only makes sense that more subtle differences in knee are even more subtle to perceive.

And this especially because we sense transients very poorly. A distorted transient can be nearly inaudible, and by the time we have so much distortion in average to become perceptible we have also so much distortion that subtleties of the knee area have become almost negligible. The softer clipping just has a little bit less of "bite".

But hey, you can always audition the effect yourself and make your own conclusions. You don't have to trust our, or my, word for it.

IME, common critique about very soft clipping circuits, such as MOSFET inverters for example, is about their blurry tone and lack of headroom. If you look at the graphs it would make sense to hear more about transparent and warm distortion at intermediate gain levels but no; too fuzzy and blurry, and too early. And you seldom see these very soft clippers employed in practice, even though their design is trivial. Even most of the praised tube power amps are not the type of designs that could and would clip very softly. Generally I believe all this soft clipping stuff enjoys way too much credit. It's in the same category as speculation of even versus odd harmonics.

And yes, I firmly believe you achieve much more with EQ. You can audition soft versus hard clipping circuit but I'm pretty sure you hear much more prominent differences when you audition a HPF vs. no HPF prior to that circuit, or LPF and no LPF post that circuit.

Although the - way too often mentioned by me, but the same theme is coming back - AC30 is rumoured for its glassy chimey character which is partially connected to the softer onset of clipping giving earlier harmonic content. But.... it is only as "soft" as you want to see it. The curve is not a part of a circle some MOSFET inverter seem to have. It is rather a slight bend going to rounded corner.
And as I mentioned earlier too, some want harder clipping and headroom. The "ideal curve" might be the one curve no one is really really really satisfied with.
I see parallels with the fact people (like me) prefer silicon Fuzz Faces or clipping rather than germanium. Germanium has mojo, but has the same "blurry" character IMHO. Silicon can be designed to come close to germanium anyway. Stepping on toes.
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Steben

  • SUPPORTER
Rules apply only for those who are not allowed to break them

teemuk

QuoteBut.... it is only as "soft" as you want to see it. The curve is not a part of a circle some MOSFET inverter seem to have. It is rather a slight bend going to rounded corner.

Yes. I guess we bump into subjectivity of defining "soft".

Scenario #1. Soft vs. Hard. Overall curvature from linear to flat top limiting is about same but there is difference in the knee area. Non-linear region is not very broad in either.

We can clip about the same percentage off waveform peaks, with either hard or softer edges (and every variation between) before an eventual "brickwall limit" and, IME, the magnitude and amount of distortion we perceive is almost completely defined by how big percentage we chop off. The soft clipping isn't sounding any "cleaner", just duller, because difference of hard versus soft in this scenario falls down to hard clipping merely sounding brighter because of higher amount of high order harmonics generated.

Scenario #2. Instantaneous gain compression. Very non-linear, gradually sloping curve. Non-linear area very broad (e.g. 1/4th or 1/3rd of the characteristic curve).

Percentage of waveform chopped off no longer qualifies as a measure of distortion's magnitude as morph to brickwall limit is subtler, yet gain compressed parts of the waveform are still distorted. The signal should theoretically sound clean-ish at fair bit of overdrive, but in practice even the distortion of gain compressed portions is audible and although it is not full bore "high gain" it's still perfectly audible blurryness and "muddy" sound without additional filtering and other similar tricks.

---

IME, soft clipping of scenario #2 sounds good on paper but in practice the reality is different. it is something not exploited often in distortion effects.

And I wouldn't be too hasty to explain the "AC30 chime" just with its soft clipping. It's after all something that can be, to a good degree, approximated with plain diode clipping circuits, which as is do not have the AC30 chime at all. AC30 is, BTW, at least on some parts a rather bright-voiced circuit. There's also that "Cut" control that helps to reduce some of the nastiest higher frequency IMD. Very much like rolling down tone control from your guitar before you overdrive the signal: Distortion recreates the attenuated high order harmonic content so it doesn't sound "dull", yet there's less IMD messing up the high end. Come to think of it, it's a voicing trick commonly employed in distortion effects, though a user adjustment is rarely provided for it.

R.G.

Of course, music is not sine waves. That being the case, you never get just harmonic distortion. You also get intermodulation distortion with any non-linear process if there is more than one frequency involved. I'll have to go look up the source, but I remember from somewhere that the more softly rounded the clipping, the lower the order and amount of IMD compared to THD.

Some people like a bit of IMD, some like a lot, but most people think lots of IMD isn't "musical".

It could well be that the ratio of IMD to THD for a clipper is what is behind the perception, and that my baby-steps ratio of knee range to linear range is a crude rule of thumb for that. I'll have to go see if Mr. Sim can make an all-knee clipper.  :)
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

teemuk

QuoteI'll have to go look up the source, but I remember from somewhere that the more softly rounded the clipping, the lower the order and amount of IMD compared to THD.

Should be (I can't remember the source either). But how to judge it? With harder knees and smaller non-linear area there's more IMD during distortion, sure, but also less IMD without distortion. And we almost never ever distort 100% of the signal but the peaks. With larger non-linear area there's less IMD during distortion but also much larger percent of the signal is distorted in comparison to previous setup, and more IMD then.

It would be interesting to audition this for a group and see what people actually perceive.

QuoteSome people like a bit of IMD, some like a lot, but most people think lots of IMD isn't "musical".

We simply can't distort audio signals by any conventional manner without adding IMD to equation. ..and at the extreme "lots of IMD" is practically just noise consisting of all frequencies (by definition). There's probably a subjective point where "musicality" vanishes between a clean signal and incomprehensible noise. 

bowanderror

Quote from: Vivek on September 29, 2021, 07:49:22 AM
Quote from: bowanderror on September 27, 2021, 06:07:40 PM
If anyone wants to play around with that Thomas Henry circuit in LTSpice, I've posted the .asc file

Thanks

Do you have any other Spice files of differential stages

or pedals that use this stage ?

I have played with a few Diff Amps in LTSpice:


I have that Transistor Ladder Filter on the breadboard at the moment and the overdrive sound is so cool! Maybe someone else can better explain why, but it's unlike any overdrive or distortion I've played with before.

Here is an audio demo, ranging from clean to overdriven filter (no envelope).

bowanderror

Quote from: Vivek on September 30, 2021, 04:59:23 AM
Quote from: niektb on September 30, 2021, 04:19:21 AM
In my faust simulation I used 1/arctan(a)*arctan(ax), sounds very smooth but the output isn't fully bounded. (with a being a distortion constant and x input signal)

I entered your function into https://www.desmos.com/calculator/ to have a look

I really wonder what is the sonic difference between all these different transfer functions. They all seem so similar ie some linear part close to zero crossing, some curved part, some saturated part (or ever expanding non-bounded) and optionally some degree of asymmetry

Teemu, RG, Craig etc have in the past said that the EQ before and after the distortion makes more difference than the actual method of distortion.

Here is a link to a plot of that function, with a slider for Distortion. Quite interesting to see the behavior as it moves away from the zero-crossing.

Also Vivek, I would agree that the gain staging & EQ of a circuit is going to make a much more obvious & immediate difference in the sound of a circuit. This is dealing with a much more subtle difference with what seems like a narrow operating window.

I should make it clear that I don't personally believe that this is the most "musical" clipping, as I don't believe that exists or can be quantified. I happened to like the sounds I was hearing from clipping things like diff amps, VCAs, & OTAs on the breadboard, and the tanh(x) function kept coming up while reading about them.

My intuition is that this style of smooth super-soft clipping is not going to create some mind-blowing effect. It's a simple, useful, & under-utilized (at least in pedals) building block that I was hoping other people could help optimize for guitar. Once beaten into submission & documented, it's another tool in the community toolbox & hopefully it might inspire other people's designs.

Personally, I would like to build a version that goes after my looper for a touch of overdrive & a bit of compression.

Vivek

It's possible to simultaneously plot multiple functions on desmos.com



Great to see the differences between the two functions posted here

The Tanhx saturates, the arctan one does not


In DSP, it would be quite easy to make a meld function pot that lets you go smoothly from one function to the other, in case compliance/ softness needed to be controlled.


Yes I agree that just because Tanh shows up with differential pairs does not necessary mean that it is the "most musical" curve.

or that there is audible sonic difference between that and other similar functions.

I dont believe that one function is very much "smoother" than the other since I believe its just a matter of proportion and gain. To a large extent, what appears to be a hard clip function can be seen as a soft clip function if gain is reduced, and a soft clipper can look hard if gain is increased. Yes of course the unbound functions that forever increase will be "softer" at the knee since knee angle if less.


SPICE can process WAV and I am tempted to pass a 20 second clip through different transfer curves to see if the output sounds different. It will be very easy to stuff a function into a BV and record its output.


PS : If we are talking about golden transfer functions, I'm surprised that Fibonacci did not feature till now.


Steben

Quote from: Vivek on September 30, 2021, 11:59:19 AM
PS : If we are talking about golden transfer functions, I'm surprised that Fibonacci did not feature till now.

Diode ladders my friend diode ladders  :icon_mrgreen:

On topic: one of the biggest difference next to EQ is the saturation or not. Non inverting feedback style = no saturation. The arctan is in between saturation and non saturation in theory. Yet it does have a limit to saturation. Try the arctan function above with a on 10.


And try for example x/2 + log x and x/4 + log x for example.... Diode time!
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Rob Strand

QuoteThe Tanhx saturates, the arctan one does not


In DSP, it would be quite easy to make a meld function pot that lets you go smoothly from one function to the other, in case compliance/ softness needed to be controlled.
Another way to look at it is atan(x) is like tanh(x) with the clean signal added to it (ie. a clean blend).  The presence of the clean signal prevents it reaching a limit.

Check out (I've used 2x so it passes near +/-1 when x= is +/- 1, slope at x=0 is 2.0)
- tanh(2x)
- atan(2x)
- A*tanh(Bx) + Cx
    For same small signal slope C = 2 - A*B.
    then choose A = 0.77342, B = 2.12291
    which gives C = 0.3581

   That matches atan(2x) to within 0.0025 over x = -1 to 1

There's many other "limiting" functions, for example (1/2)*asinh(4*x) which is softer than atan(2x).

I used to do a lot of curve fitting and the small differences can help the fit.


With this same thinking and from the Don Tillman approximation for sine, the sine curve approximation is tanh(x) but instead of adding the clean signal we subtract it - that would make the harmonics louder in relative terms.

So we use tanh(x) as the primary clipper then add or subtract the clean signal.

The flaw in the equivalence is it is an approximation.   The slopes of true functions and the approximations are not equal so that means the approximation might not really maintain the character of the true function.   What I'm getting at here is if we just change the characteristic by changing the amount of clean we aren't really changing the character of the clipper at is remains as tanh(x) and has a constant harmonic footprint.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

ashcat_lt

Quote from: Vivek on September 30, 2021, 04:59:23 AM
I really wonder what is the sonic difference between all these different transfer functions.
There is at least one JS plugin for Reaper (I'll try to dig around and find it if anybody's interested) which allows you to try a number of different common functions in real time.  It's very much the same thing we've said over and over again about the difference between different diodes, or diode vs transistor or opamp or whatever.  Pre and post filtering, the signal-to-clipping-threshold relationship, and the symmetry/asymmetry will have a much bigger impact on both sound and feel than any subtleties in the curve itself.

niektb

Well let's put our ears to the test, shall we?  ;)

I've written a simulation in Faust, comparing both clipper types and putting them through a Marshall-type tonestack and a simple cab sim. I used anti-aliased approximations so you should be able to crank the gain without getting all kinds of nasty harmonics  8)
You can open this link and copy-paste the code below: https://faustide.grame.fr/
And then you can use any DI guitar track you like. I used the one from this forum thread (which is used to test Kemper Profiles): https://www.kemper-amps.com/forum/index.php?thread/26817-a-dry-guitar-track-for-our-tests/

I noticed that the gain knob responds radically different: https://www.desmos.com/calculator/czdixdgki0?lang=nl
So that's why one clipper starts at 5 and the other at 3.65. I level-matched them as well as I could and also added VU meters to aid with this.


import("stdfaust.lib");

amp_clipper1 = aa.tanh1(amp_k*_)*amp_vol
with {
    amp_k = vslider("[01]Gain", 3.65, 0.1, 10, 0.1);
    amp_vol = vslider("[02]Volume", 1, 0.001, 10, 0.001) / 5;
};

amp_clipper2 = (aa.arctan(amp_k*_)/aa.arctan(amp_k))*amp_vol
with {
    amp_k = vslider("[01]Gain", 5, 0.1, 10, 0.1);
    amp_vol = vslider("[02]Volume", 1, 0.001, 10, 0.001) / 5;
};

vumeter = vmeter(0)
with {
    vmeter(i, x) = attach(x, envelop(x) : vbargraph("VU[2][unit:dB]", -70, +5));
    hmeter(i, x) = attach(x, envelop(x) : hbargraph("VU[2][unit:dB]", -70, +5));
    envelop = abs : max ~ -(1.0/ma.SR) : max(ba.db2linear(-70)) : ba.linear2db;
};

amp_tonestack = component("tonestacks.lib").jcm800(t,m,l), component("tonestacks.lib").jcm800(t,m,l)
with {
    t = vslider("[05]Treble", 6, 0, 10, 0.01) / 10;
    m = vslider("[04]Middle", 4.5, 0, 10, 0.01) / 10;
    l = vslider("[03]Bass", 5, 0, 10, 0.01) / 10;
};

amp_cabsim = sp.stereoize(ef.speakerbp(80,5000));

bpc = checkbox("[04]Arctan Select");
boost = vslider("Boost", 5, 0.1, 10, 0.1);
amp_sim = hgroup("[00]Boost", boost*_) <: hgroup("[02]Tanh", amp_clipper1 : vumeter), hgroup("[01]Arctan", amp_clipper2 : vumeter) : select2(bpc) <: hgroup("[03]Tonestack", amp_tonestack) : amp_cabsim;

process = hgroup("British Amp", amp_sim);

Vivek

Wow, this group is so much fun !

I too use same dry guitar file as one of my test files. I also have reference dry files of each note of the fretboard, I'll try and remember where I got that from.

Here is a test tone. This can help see resultant output waveshape : https://virtualzeroaudio.com/pages/1khz-sine-wave


Last week, I too looked at the 2 free waveshapers in Reaper and ran these test files through them. I was not happy with the built in waveshapers and am going to search for other better ones. The idea was to design a new pedal in reaper and then implement in hardware.


I want to learn Faust, especially it it can program fxcore efficiently. What should I read up first ?



This project is interesting for it's ability to check effect of different transfer functions, tone control settings, gain in real time


https://mainline.i3s.unice.fr/AmpSim5/index.html