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

Steben

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

Vivek


Vivek

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 ?

Vivek

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 here.

You'll need a TL072 spice model & the standard potentiometer model from the LTSpice groups.io Library (used to be Yahoo Groups). If you're not a member, I've re-hosted it here.


Here are some outputs from my infamous AC TRANSFER FUNCTION routine in LTSPICE

Basically, I inject sine waves of various amplitudes to the circuit. Between -2 and 0V peak of input, I plot the Vtrough of output,

and from 0 till +2Vpeak of input,  I plot the Vpeak of the output signal

This is straight from the ASC posted above, with no tweaks, trimmer at 17K just like in the original file



And here is a zoom in, from -800mv to +800 mv




and more zoom in



Observations :

1. Gain at zero crossing is around 78

2. This transfer function looks very similar in shape to a Muamp, especially if we attenuate input or reduce gain

Or many other methods of softer distortion like multiple knee feedback diodes.
Ref: https://www.diystompboxes.com/smfforum/index.php?topic=127101.0




Ie any distortion circuit with gain adjusted so that saturation knee is not so sharp.


The only thing this is not similar to is high gain rail to rail Opamps

Hence, special Tanhx magic not discovered yet !!!


R.G.

Proportion matters.
Any clipper makes a square wave out of a big enough signal. Any clipper is (nearly) no effect at all to signals below its "knee". 
If you allow DC offsets along the clipper characteristic and go to quite small signals, the signal is merely attenuated by the slope of the characteristic at the DC offset. This is how diode modulators work. The Thomas Organ Vox amps used a four-diode modulator to produce very distortion-free tremolo. It worked because the signal size at the modulator was down in the 25mV range.

Bipolar diffamps have quite low distortion below about +/- 25mV of signal. More than that, the peaks get into the knee. 

It occurs to me that plotting the derivative of the slope of the clipper characteristic and come up with some useful information on clipping. The "derivative" - rate of change of the slope at any given point - probably needs to be qualified by the width of the region you take the derivative over.
Hmmm...
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.

Steben

Quote from: R.G. on September 29, 2021, 11:30:40 AM
Proportion matters.
Any clipper makes a square wave out of a big enough signal. Any clipper is (nearly) no effect at all to signals below its "knee". 

gonna repost from another thread :D




Albeit with one slight addition: no diode clipper ever gets "to the rail" because of the internal resistance although it can be inaudible if the impedance of the signal is high enough.
This is seen when the series resistor of diode clippers to ground is changed.

Personally I always have found diode clippers at high only convincing as an "amp tone" if the opamp in front is clipping as well. It must be this reason no?
And any feedback tube power amp clips harder than a diode clipper, but many have the power sag added.
It is one of the paradoxes of guitar tone: there is no supremacy of soft nor hard clipping. We love both. The tanhx function has an ultimate hard clipping that goes beyond diodes but has a softer knee than single diodes.
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Vivek

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 ?

Steben

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 ?

It's all relative. A very "round" curve is for example a MOSFET inverter but it will sound "harder" once it hits the rails over a wide interval than a germanium clipper..
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Vivek

Quote from: R.G. on September 29, 2021, 11:30:40 AM
Proportion matters.
Any clipper makes a square wave out of a big enough signal. Any clipper is (nearly) no effect at all to signals below its "knee". 


I totally agree !!

All depends upon the positioning of the knee vis-a-vis the guitar signal strength.

After analysing a few Pedals and Amp-in-a-box, if feel, in general

"Tube like" transfer curve similar to Line6 patent 5,789,689:


That red dot is positioned around 2mvP of guitar signal for very high gain sounds and maybe 150mvp for gentle crunch

So the same transfer function can provide clean or crunch or rock or metal based on the "Proportion" or gain or signal level at which you are driving it.

Which means that there is nothing terribly spectacular in the Tanh curve. Infact, I feel it would be better if it didn't go all flat and horizontal for high signals, and instead allowed room for output to grow a bit even in severe clipping zone.


Quote
Bipolar diffamps have quite low distortion below about +/- 25mV of signal. More than that, the peaks get into the knee. 

I know nothing about diffamps, so please permit me to humbly remark that I think the +/- 25mV of signal could be related to gain of that stage and power supply to that stage. I submit it might be possible to design diffamps that start to clip at 2mv or 20mv or 200mv or 2V by playing around with gain and power supply.

Quote
It occurs to me that plotting the derivative of the slope of the clipper characteristic and come up with some useful information on clipping. The "derivative" - rate of change of the slope at any given point - probably needs to be qualified by the width of the region you take the derivative over.
Hmmm...

Let me try that as a challenge in mathematics / Spice and see what I can come up with. Normally to get a good AC TRANSFER FUNCTION graph with a high gain amp, I plot data every 1mvp of guitar input, but for low gain amps, sometimes 10mv jumps also are fairly representative.

Steben

Quote from: Vivek on September 29, 2021, 01:14:44 PM
Which means that there is nothing terribly spectacular in the Tanh curve.


No, AC30's are around for a very long time.  :icon_mrgreen:

Quote
Infact, I feel it would be better if it didn't go all flat and horizontal for high signals, and instead allowed room for output to grow a bit even in severe clipping zone.

Not sure. The flat line sound when completely driven is reminiscent to the marshall sound.
And that thick hairy rock sound of Led Zep II is impossible without some flat railed out.
And what good is to com from growing level of you want sag?

Quote
I know nothing about diffamps, so please permit me to humbly remark that I think the +/- 25mV of signal could be related to gain of that stage and power supply to that stage. I submit it might be possible to design diffamps that start to clip at 2mv or 20mv or 200mv or 2V by playing around with gain and power supply.

Quote
It occurs to me that plotting the derivative of the slope of the clipper characteristic and come up with some useful information on clipping. The "derivative" - rate of change of the slope at any given point - probably needs to be qualified by the width of the region you take the derivative over.
Hmmm...

Let me try that as a challenge in mathematics / Spice and see what I can come up with. Normally to get a good AC TRANSFER FUNCTION graph with a high gain amp, I plot data every 1mvp of guitar input, but for low gain amps, sometimes 10mv jumps also are fairly representative.

Thing is, these can be mimicked with diode ladders.
  • SUPPORTER
Rules apply only for those who are not allowed to break them

Vivek

Quote from: Steben on September 29, 2021, 01:31:01 PM

Thing is, these can be mimicked with diode ladders.

 
My thread on LG1 stage for my Amp building block approach got hijacked with Tanh  :(   ;)

But all along, it could be done with a diode ladder, which I prefer since we can build the response piecewise.

Please help me to design LG1 stage on that thread.

Thanks  :)





PRR

Quote from: Vivek on September 29, 2021, 01:14:44 PM
Quote
Bipolar diffamps have quite low distortion below about +/- 25mV of signal. More than that, the peaks get into the knee. 
I know nothing about diffamps, so please permit me to humbly remark that I think the +/- 25mV of signal could be related to gain of that stage and power supply to that stage. I submit it might be possible to design diffamps that start to clip at 2mv or 20mv or 200mv or 2V by playing around with gain and power supply.

No. Or not trivially.

Shockley's Law. 26mV is baked into Silicon junctions. It is how far apart the Silicon charges sit in the crystal.
https://en.wikipedia.org/wiki/Shockley_diode_equation

Yes, this could be 52mV by doubling-up the junctions etc. But Gain Control is a KEY skill of the audio technician. You got 26mV and want 2V? Put in a gain of 78 after the junction. All of audio is about control of the gain.

  • SUPPORTER

Vivek

Quote from: bowanderror on September 27, 2021, 04:01:35 PM


I played around with Thomas Henry Tri-to-Sine Waveshaper from his book:



This sounded really nice on the breadboard, but still needs to have the level dialed in as the diff pair can go from no clipping to too much with a very small change in signal level:



I'd like to keep working on a tanhx-style design like this, so let me know if anyone else is interested!


Does this mean that the gain before the differential is too high ? Do you need to make trimmer around 75K or more ?

Vivek

Quote from: PRR on September 29, 2021, 03:17:50 PM
Quote from: Vivek on September 29, 2021, 01:14:44 PM
Quote
Bipolar diffamps have quite low distortion below about +/- 25mV of signal. More than that, the peaks get into the knee. 
I know nothing about diffamps, so please permit me to humbly remark that I think the +/- 25mV of signal could be related to gain of that stage and power supply to that stage. I submit it might be possible to design diffamps that start to clip at 2mv or 20mv or 200mv or 2V by playing around with gain and power supply.

No. Or not trivially.

Shockley's Law. 26mV is baked into Silicon junctions. It is how far apart the Silicon charges sit in the crystal.
https://en.wikipedia.org/wiki/Shockley_diode_equation

Thanks Paul,

Can you please explain a bit more.

I currently do not see how thermal voltage of Shockley's equation for diodes is related with RG's assertion that Differential Pairs are linear only around +/- 25mV of signal

Please help me to understand.

PS : Spice seems to say that the THOMAS HENRY SINE WAVESHAPER schematic posted by BOWANDERROR has a differential pair that is linear for input signals below 100mvp at the base of the left transistor of the pair. How is that possible ?

ashcat_lt

It's my understanding that we use tanh in code because it is very close to the diode transfer curve, but a bit more efficient to calculate, and just ultimately makes a nice continuous curve with a hard limit which will theoretically never be reached.  Trying to then approximate that tanh more closely in analog seems a bit strange to me.

Tanh is not actually a particularly good approximation of sine, sine being even further off from the diode "ideal".  I actually play through these functions in "pure" digital form literally all of the time.  The difference, while subtle, is noticeable both in sound and in feel, and I very much prefer the tanh.  Sine, however, is very slightly more efficent, so I use that for the overdrive stage of my "amp sim" in live performances just to buy that  little extra CPU headroom.

ElectricDruid

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.
How you practically get a second differential from a circuit on the breadboard I have no idea. I can imagine it's possible in a sim (although I don't know how) but distortion characteristics is one area where I don't trust sims to be accurate at all.

ElectricDruid

Quote from: ashcat_lt on September 29, 2021, 04:39:44 PM
It's my understanding that we use tanh in code because it is very close to the diode transfer curve, but a bit more efficient to calculate, and just ultimately makes a nice continuous curve with a hard limit which will theoretically never be reached.  Trying to then approximate that tanh more closely in analog seems a bit strange to me.

No, we use tanh because it's the mathematical model for transistor behaviour in this configuration. It's what the theory says. This is a good source:

https://wiki.analog.com/university/courses/electronics/text/chapter-12

Obviously the usual disclaimer applies: In theory, there's no difference between theory and practice. In practice, there is.

If you use the tanh curve in code to generate distortion for the reasons given, then fair enough - efficiency of calculation and a nice continuous curve are good enough reasons in themselves. But that's not where tanh comes from.
 

R.G.

Quote from: ElectricDruid on September 29, 2021, 05:00:16 PM
I can imagine it's possible in a sim (although I don't know how) but distortion characteristics is one area where I don't trust sims to be accurate at all.
It is possible. My particular circuit simulator contains a number of pre-fabbed control functions and one of them is differentiating. I messed with it some before posting that.
I fed a pair of 1N4148 models hooked up anti-parallel to ground an triangle signal through a 100K resistor. This performed as expected, wit not much effect below the conduction voltage of the diodes, and rounding over as they were driven harder. By tinkering the triangle peak voltage I could get a "sine" at the diodes of as little as 2.2% THD. The base-emitter junctions of two bipolars set up as a diff-amp would produce much the same effect, and for the same reasons. As Paul points out, the 25mV number is a rough variant of the Shockley voltage, out of the semiconductor physics of silicon.
The derivative took some thinking. It was flat, as expected, for the linear-ish slopes of the voltage across the diodes, and swooped when the waveform started curling. There was a glitch where the waveform peaked and reversed.
This was level sensitive, of course. Where the signal voltage on the diodes changed rapidly, not at the "pretty" 2.2% distortion sine point, it got a bit unruly.

I'm left with my internal feel for distortion characteristics. I think that the size of the mostly-linear region compared to the size of the clipper knee is a fundamental item for distortion. The bigger the mostly-linear region is compared to the size of the knee, the more hard-edged the resulting waveform is, and the more Mr. Fourier's monster creates harmonics. If the knee is "small" compared to the linear region, you get more harmonics. The symmetry of top and bottom side knees get involved in production and cancellation of even order harmonics in the series, just like theory says. This is all flavored with the signal size compared to the linear and knee regions and how offset it may be from the knees. Non-symmetrical knees will also hash up the Fourier series.

I messed with this stuff back in the 2000's and never came up with a good guideline for what curve/form of knee was most musical. There may be a Magical Truth buried there, but I didn't find it.
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.

Rob Strand

QuoteCan you please explain a bit more.

I currently do not see how thermal voltage of Shockley's equation for diodes is related with RG's assertion that Differential Pairs are linear only around +/- 25mV of signal

Please help me to understand.

It's not tanh(x) but tanh(V/VT)  where VT = thermal voltage.  In reality the tanh() has a scaling factor.
(If you want Vin, V = Vin/2, look up some diff-pair derivations. maybe this one,
http://www.ittc.ku.edu/~jstiles/412/handouts/7.3%20The%20BJT%20differntial%20pair/section%207_3%20The%20BJT%20Differential%20Pair%20lecture.pdf
)

If you consider tanh(1) = 0.76, that's not overly compressed but to get the same linearity from tanh(V/VT) the V required is now V=VT.  At V = VT/2,  ie Vin = VT,  tanh(0.5) = 0.46 which is getting more linear.

The VT scaling factor is built into the diff-pair.     If you want to get around that an obvious method is a voltage divider before the diff-part.  That's exactly what OTA circuits do like the MXR compressor.    Another way to get more input voltage is to put a coupling resistor (or two in series) between the emitters.


Here you can see what RE does,




Here's the DC transfer function from Vin to Vout with the gain of 2 at the input of the RE case in order to get the same overall gain.  Input and output levels are differential.




The RE case is more linear in the central region.  The overall clipping characteristic is harder.
Don't forget the input voltage going into the diff-pair with RE is higher.


Taking things a bit further we can compare the two clippers posted here with the diff-pair and diff-pair with RE,
https://www.diystompboxes.com/smfforum/index.php?topic=127936.msg1229753#msg1229753

I've scaled the input and output of the clippers in the previous thread so the gain for small signals is the same as the diff-pair and the peak output is the same as the diff-pair.   The 10k input resistor needs to be just over 1k.  A divider is placed at the output to drop the ~4.5V clip voltage down to 55mV.



So you can see:
- diff-pair no RE is softest.   Technically this is the only one intrinsically approximating tanh(x)
- diff-part with RE next ;  shape depends on RE.
- the softest version of two current sense clippers, ie. no offset, is harder than both of those
  Well sort of because it kinks more.  The shape of the non-linearity is different to the RE case.
- the current sense with offset is the hardest.
- the hot cake type clipper which only has a voltage threshold and not current sense will be harder still.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Rob Strand

QuoteI'd like to keep working on a tanhx-style design like this, and have a pretty massive library of reference articles & example designs on the topic, so let me know if anyone else is interested!

Technically the differential pair without input resistors or emitter resistors is essentially a tanh(x) function.

The sine shapers attempt to approximate sine.      The addition of emitter resistors in the differential helps the sine approximation a lot.   For example, figure 11 of this old National Semiconductor Applications note AN263,

https://www.researchgate.net/file.PostFileLoader.html?id=57636fd5cbd5c2f4952ed7e1&assetKey=AS%3A373809279455233%401466134485778

IIRC, you could do little better than this circuit but it's pretty close just the same.

Mathematically the sine approximation adds a linear term to the tanh(x).  That's what the RE resistor does.   Looks like Don Tillman has written up something along these lines.

http://till.com/articles/sineshaper/
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.