Implementing a simple softclip algo, pr voice.

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

Previous topic - Next topic

Paradox Uncreated

Or maybe it is intereger code, then you aren`t working with +-1 ofcourse.. We`ll work it out.

Saga Musix

Quote from: Paradox Uncreated on April 17, 2012, 14:48:45
Is there any problem with including GPL code in a BSD project btw?
It can lead to problems. I'd rather prefer to incorporate BSD code. You can actually dual-license your code if it's necessary.

Concerning an inclusion in OpenMPT, that is theoretically possible of couse, but I personally don't think it's a good idea to implement obvious colouring on mixing level (yes, EQ, Reverb and Pro Logic Surround do the same, but I didn't say that it's a good idea to have them *at all*). If it is possible to apply the algorithm globally (i.e. on the whole mix instead of individual samples), it might be more feasible to implement it as a plug-in instead.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Paradox Uncreated

Quote from: Jojo on April 18, 2012, 13:55:23
Quote from: Paradox Uncreated on April 17, 2012, 14:48:45
Is there any problem with including GPL code in a BSD project btw?
It can lead to problems. I'd rather prefer to incorporate BSD code. You can actually dual-license your code if it's necessary.

Concerning an inclusion in OpenMPT, that is theoretically possible of couse, but I personally don't think it's a good idea to implement obvious colouring on mixing level (yes, EQ, Reverb and Pro Logic Surround do the same, but I didn't say that it's a good idea to have them *at all*). If it is possible to apply the algorithm globally (i.e. on the whole mix instead of individual samples), it might be more feasible to implement it as a plug-in instead.

On mixing levels? I don`t understand that statement. It is simply to declip samples, that were hardclipped to gain a bit more SNR back in the old days. By introducing a softknee before clip, we simply change the overtones of the clipping, into something more pleasant. And as I said earlier, that is the kind of sound many people actually want. Implementing it globally would defeat this purpose. But you do as you wish with your tracker. If you do not want to include it in your upstream version, can you compile the hack for me? I would really like to listen to my old modules, fixing some of my hardclipping there. As for the DSP stuff, yes I do agree, there is not neccesarily any point in having that, but this is not DSP in that sense. This is about fixing old 8bit samples. :)

Peace.

Saga Musix

QuoteOn mixing levels? I don`t understand that statement.
On the whole mixing buffer instead of individual samples. But I see that this wouldn't make much sense anyway, so forget about it.

It would also be possible to implement it as a new sample editor tool (of course with appropriate shortcuts to apply it to all samples at once). You'd still have to apply it manually then, but I feel better about that than implementing it as a mixing step at the moment.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.

Paradox Uncreated

A batch process in the sample editor would be fine aswell. Maybe even better.

Harbinger

I agree -- this would serve better as a sample editing tool....

But if i understand this correctly: your algorithm lessens a hard-clipped sample (which would then sound badly distorted) and attempts to re-form the peaks based on the slopes of the waves?

If this is true, this could DEFINITELY be useful, especially in MPT! :D

Paradox Uncreated

No, it`s not a declipper. It`s a dehardclippingknee.

Usually "digital clip", and a/d converters at the time of amiga/atari/acorn, usually clipped abruptly.
That means small clips, in the a/d converters, as many did then, because it was 8bit, and tried to make the most use of the headroom, will give very particular distortion, that is psychoacoustically often percieved as noise, clicks, sparks, etc. However if one simply adds a softknee after the clip, aka "gradual clip", gradually reducing the level before clip, the overtones changes, and much higher levels of clip can be tolerated psychoacoustically, before one thinks of signal degradation. Infact, some even PREFER the sound of softclip, to digital nonclipped sound, and buy analog mixers with transistors purely for that purpose.

It`s been quite a big discussion online. Declipping would be reconstructing the signal, yes. I have heard some declippers, and it is not something I have used. Could be that there are other declippers there that are better though, I could always have a look into it. It might be possible to alter overtones more sophistically with more of a declipper algorithm.

Soundexample:

1 - hardclipped
2 - softclip -2.4 knee. One should ofcourse tweak the amount for ones liking, or more of a average sound, which is what I am trying to do with my modules, for just a little more refinement. I am inspired to have a look into declipper algorithms now though, maybe I can improve it.
3 - softclip exaggarated +9dB gain (all clipped), -23.55knee

As you can hear, hardclip sounds itchy and scratchy.
With softclip it is less noticable.
Exaggarated softclip shows just how much you can drive a signal, without neccesarily it being unmusical.

The exaggarated softclip is also closer to many vintage synths level of distortion. Because they softclip, people generally tend to think they are more hifi than they are, it isn`t until recent times that actually including a good softclip algorithm in a digital softsynth, has become standard. And has also been part of feeding the "analog is better/phatter/warmer etc than digital" debate.

Everybody agrees that the hardclipped version sounds odd right?

Very typically on old modulars, levels were hot. A lot of people who have sampled them, sample them that way. They do set the osc levels that high, and that is part of the sound they like. Moogs are also widely stated to be saturated. etc.

Paradox Uncreated

Maybe just having batchprocessing with VST plugins, in the sampleeditor will be better.

This is declipped version.

Declipped with http://www.perfectdeclipper.com/download/

Much better, if you are not looking for "analog" sound. Which I was originally looking for, but I can try this aswell.


Paradox Uncreated

Well I tried it on more of a mix now. The samples I am talking about will probably exibit the same, although it would probably work well on bass samples, like the one before. I have mixed some drums though, in my modules, wellknowing that the output would clip, but kindof setting the levels so it wouldn`t be so noticable. That way I could do some nonlame drumtracks, without using all the amazing 4 tracks. :)

This declipper as many declippers output much higher levels than the sample, I had to set this to a minimum of 3x original level, for decent declipping. I think that is far too much, and it changes the sound of the samples too much. It sounds very much like a typical declipper that way. Suddently you have large peaks there, that shouldn`t be there anyway.

It is possible to implement a little bit of declipping mindset into a more of an overtone based approach though, which would not need so much higher levels.

I can think a little bit about it, and whip up a plug, if something easily doable occurs to me.

Harbinger

Okay, now i understand...
I think a clipping softener would be useful, as, it seems from the way you describe it, that aurally higher volumes could be more tolerated and not so drastic in the clip distortion effect.

I think this and a declipping function would be great in MPT's sample page.  8)

Paradox Uncreated

A vst plugin function, so people can apply whatever they want would probably be nice. No need to hurry though, I have pretty much done what I wanted to do anyway.

Just to follow up on my last post, I did try to combine a bit of looakhead, to apply softknee to the clipped area only. My first experiments are that good. So obviously one needs to get into the whole algorithm more, to find out where one can tweak it. Which well, I have already done what I wanted to do so, I am not too interested in it. But yeah, there are many declippers out there, and people who have spent time on this, so vstplugin function would probably cover the needs of anyone who needs to apply such things.

Peace.

Saga Musix

Quote from: Paradox Uncreated on April 26, 2012, 13:33:36
A vst plugin function, so people can apply whatever they want would probably be nice. No need to hurry though, I have pretty much done what I wanted to do anyway.
That has been long on the to-do list, but it's not a trivial thing to do.
» No support, bug reports, feature requests via private messages - they will not be answered. Use the forums and the issue tracker so that everyone can benefit from your post.


TheRealByteraver

I found a short paper about this subject, the math is (as usual) above my paycheck though  :'( . It has been the subject of quite some research in recent years apparently.

https://mathematical-coffees.github.io/slides/mc04-kowalski-additional.pdf

Paradox Uncreated

Well, that was a bit more sophisticated version, that I had in mind though, and actually may add peaks to the signal one does not want. Rather a declipping knee, probabably two third order knees in parallel, with slightly different thresholds.