Implementing a simple softclip algo, pr voice.

Started by Paradox Uncreated, April 16, 2012, 11:52:15

Previous topic - Next topic

Paradox Uncreated

As you know, in the 8-bit days, one usually clipped the samples a bit, to increase SNR.

I just made a very simple and optimal softclip, using two x-(x*x*x*0.3etc), in series with a threshold. This gives the third-order distortion of vintage gear, driven mixers, and often what people like with "hot" signals, on whatever it may be, on typically analog gear.

I recently tried OpenMPT on one of my old tracks, and with the Blackman Exact interpolation, it sounded actually quite good. I did however remember driving the levels there quite hot, but with the sampler of the time, (and most of them I think) there was no softclipping. So that can be retrofitted to the samples :) (probably pr. voice, before interpolation?)

What do you think?

(Edit: having the softclippers in parallel might be even better!)

Paradox Uncreated

#1
I actually tried a batch-process on the samples now, with the softclip algo.
And it definately sounds smoother. Maybe I`ll adjust it abit, because I was used to the hardclipping overtones being present. But it`s already quite low -3.6dB knee.

I tried downloading the source, but I haven`t got visual studio installed, just an old MSVC6.0. So for the time being, me doing the tweak is not going to happen.

LPChip

I'm not a developer, but this sounds very nice. :)
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Paradox Uncreated

#3
Yes, it is one of those things you can actually do to remedy hardclipped samples. Ofcourse it`s mostly a problem with older modules probably. Maybe someone used noisy 16bit converters and felt the need to drive the levels hot too.

It`s actually a big discussion out there, about hardclip vs softclip. And the sound of softclip. And doing the softclip I am doing, is close to some good sounding transistors. It is actually optimized for transparent clipping, and therefore even preferrable to analog, for me.

So in addition to improving the sound with Blackman Exact, and smooth level changes, you can do this too :)

Knee-adjustments might need finetuning resolution, of two decimals. For the use here, on samples knees from 0 - -6dB is probably the range we are talking about.

Also ofcourse processing in 8bit would be bad, which I doubt is happening. So conversion to the resolution used, would be required.

Peace.

LPChip

Can you provide an audio example that shows the difference between normal hardclipping and your softclipping version?
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Paradox Uncreated

Yes, the mod only, or do you want to hear it with the mastering effects aswell?

Paradox Uncreated

#6

Paradox Uncreated

#7
I am still tweaking the algo a bit.

It`s the kind of thing were two decimalplaces matter, if you know what I mean. So doing batchprocessing on that, reloading samples, setting vols/tune, is a bit tedious, to actually try and find that value in practise.

Paradox Uncreated

#8
Notice particulary on the 303 sound there, that some digital edgyness is gone. That was purely due to hardclip.

Maybe a better name for the usage of this particular algorithm in this context, would be Softclip/De-hardclipping-knee.

Peace.

LPChip

Cool. I'll check them out tonight when am at home.
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Paradox Uncreated

#10
:-)

Do you have any idea if/when the developers might insert this tweak into the code?

And if they are busy maybe they could just say where in the code it would need to be inserted, and I might get someone else with the compiler installed, to do it. And maybe, if it is asm or not, maybe that complicates things.

Paradox Uncreated


LPChip

Quote from: Paradox Uncreated on April 17, 2012, 12:51:41
Do you have any idea if/when the developers might insert this tweak into the code?

And if they are busy maybe they could just say where in the code it would need to be inserted, and I might get someone else with the compiler installed, to do it. And maybe, if it is asm or not, maybe that complicates things.
Jojo is pretty active on the forums too. He'll probably answer that himself. :)
"Heh, maybe I should've joined the compo only because it would've meant I wouldn't have had to worry about a damn EQ or compressor for a change. " - Atlantis
"yes.. I think in this case it was wishful thinking: MPT is makng my life hard so it must be wrong" - Rewbs

Paradox Uncreated

#13
Anyone has this compiling?

Paradox Uncreated

#14
I think the function would look something like this:

double kn(double val)
{
   // antihcknee (anti-hardclipping-knee) should probably be a double, and a setting in the gui.(range 0..-6dB)
   // 0 being 0dB (no knee, which can also be optimized) and 1 being -6dB.  Two digit decimals in dB is probably good. e.g: -2.51dB knee.
   double b_knam = pow(2,(((antihcknee)*-6))/ 6); // should probably be placed somewhere else..
   double b_3rdmul = 1; b_3rdmul = b_3rdmul / 3; double b_3rdnorm = 1/(1-b_3rdmul); // same
 
   if (val > 1) {val = 1;} else if (val < -1) {val = -1;} // can be optimzed out, if there is no weirdness anywhere.

   double valr = val;
   if (valr < 0) {valr = -valr;}
   if (valr > b_knam) {
    valr = valr - b_knam;
    valr = valr / (1-b_knam);

   valr = (valr - (valr * valr * valr * b_3rdmul)) * b_3rdnorm;
   valr = (valr - (valr * valr * valr * b_3rdmul)) * b_3rdnorm; // can reduce the 3rdnorm here, and a div in the next.
   valr = (valr / b_3rdnorm) / b_3rdnorm;

    valr = valr * (1-b_knam);
    valr = valr + b_knam;
    if (val < 0) {valr = -valr;}
    val = valr;
   }
   return val;
}

This would do the monosamples anyway. It seems he has different code for stereo.. Someone would have to modify that aswell, if they want to use it on stereostuff.