Help identifying/naming a distortion pattern?

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

Hey everyone. I'm pretty new to DSP stuff so I'm not sure whether this question is trivial or the opposite.

Basically I have a tone from existing software/samples that I'm hoping to replicate as an effect (not as an oscillator/generator), but I'm not sure how to do it.

I measured it with an oscilliscope to get an idea of what's going on. The top wave here is a middle C, pretty close to a pure sine wave, and the lower wave is what I want to get out, another middle C with the distortion added.

Since the positive and negative zero crossings on the pure wave have different results on the output I'm guessing that a simple waveshaper function won't cut it here. Maybe some combination of a waveshaper and a rectifier would work? Or perhaps there's something more complex there which I'd have to model?
You do not have the required permissions to view the files attached to this post.

Post

Kylotan wrote: Since the positive and negative zero crossings on the pure wave have different results on the output I'm guessing that a simple waveshaper function won't cut it here. Maybe some combination of a waveshaper and a rectifier would work? Or perhaps there's something more complex there which I'd have to model?
You are over-thinking it, I think. There's no reason your wave-shaper has to be symmetric and in fact a "rectifier" is just another type of a wave-shaper too.

Post

Ok, let me see if I have this right - a waveshaper is just basically

Code: Select all

x' = f(x)
, where f is some arbitrary function and x is the sample/time domain value, correct? If so, I don't see how I can apply that to the above, because the above function seems to have 2 different output values where x=0 - it's roughly zero on the positive crossing, but significantly below zero on the negative crossing, because the sine-like crests on the second graph are narrower.

But, perhaps I'm just wrongly assuming there's some sort of phase shift here (as these were 2 arbitrary captures), and sliding the second pattern over so that it's in phase with the first would let me do it with just a single waveshaper. Hmm...

Post

from the pic, it looks like a foldback distortion
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

Kylotan wrote:Ok, let me see if I have this right - a waveshaper is just basically

Code: Select all

x' = f(x)
, where f is some arbitrary function and x is the sample/time domain value, correct? If so, I don't see how I can apply that to the above, because the above function seems to have 2 different output values where x=0 - it's roughly zero on the positive crossing, but significantly below zero on the negative crossing, because the sine-like crests on the second graph are narrower.
There is probably some filtering in addition to wave-shaping that is messing with the zero-crossings. It's also not entirely uncommon to have some feedback around a wave-shaper to essentially turn it into a non-linear filter. In general though, sine waves are not terribly helpful as test signals, because you don't really see what happens with regards to filtering. I'd probably try a saw-wave (use the cleanest band-limited source you can get your hands on) at very low amplitude (to avoid the non-linear behaviour as much as possible) to get an idea of what type of filtering might be going on (plot the spectrum and compare with reference).

Post

So much about this sound is unknown, so we can really only speculate. Share the source if you can.

Post

Maybe do a sine sweep and plot a 3D waveform or spectrogram. Should give you more info on the type of harmonic distortion it's doing.

Post

There may be some kind of foldback going on, dunno. But in addition to assymetrical waveshaping, applying different distortion to positive and negative excursions-- You can also get assymetrical results by adding some dc to the input before symmetrical waveshaping.

Adding DC offset before distortion might be more successful on a steady-amplitude synth oscillator output, and maybe less successful on a "real world" signal which has greater variability in amplitude, such as guitar or bass.

Or you could use symmetrical waveshaping but apply different amounts of pre-gain to positive vs negative excursions.

If you add DC blocking, highpass after assymetrical waveshaping-- The assymetrical waveshaping changes the duty cycle of the wave and so after the highpass to remove DC the wave can have odd dynamic behaviors because the zero-points of the distorted wave are dynamically changing according to the envelope and amplitude of the input signal.

Allpass filters can make a waveform look odder than it might sound to the ear. Assymetrical waveshaping followed by one of more midrange allpass filters could move the distorted peaks around relative to the input peaks, so that a "dual trace" comparison of input vs output might look strange indeed.

Or you could put allpass filters in front of the waveshaping. Or both front and back. Frequency contouring filters would do it as well. Anything with phase shift, including the DC blocking stage.

Post

Image
foldback, and a high-pass filter at the end
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

Hello all,

Thanks to your help and the ideas above, I managed to replicate the pattern in the initial post in an analytic form. The basic approach was:

1. amplify and DC offset/bias the signal, so it ranges from [-X, +1]
2. soft-clip the negative signal below some negative threshold to bring it back inside [-1, 1]
3. fold that area below the threshold back above the threshold.

I may need to add an extra high-pass to smooth off the corners of the fold as well, but we'll see.

Thanks!

Post

Here is how I would solve this:

1. Feed a 1-unit impulse into the "black box".
2. Reverse the resulting impulse response on the output, or if this is not possible, set all the phases to zero (or whatever the input) and reverse the frequency content as best you can. (The assumption here is that there is an EQ after the shaper).
3. Plot X and Y to visualize the waveshaper function.
4. Estimate parameters of some suitable function / set them by hand to fit the curve. Or if you can't find the right function/parameters, use the result as a table.
Last edited by Oden on Sun Aug 06, 2017 6:25 pm, edited 3 times in total.

Post

dp.

Post

Hello all, I'm working on this again after a delay of many months and I'm not happy with the solution I came up with. Mostly this is because I studied it a bit closer and the waveshape I want is a bit more complex than a simple foldback distortion.

I'm happy with the starting point of amplifying and biasing the signal - that part ppears to be correct. But looking at the waveform more closely, high signal levels seem to cancel out the foldback, and I can't work out how to replicate this shape.

Perhaps more importantly, it's clear that the waveform has an upwards slant on the distorted section. To me, this looks like the high-pass filter acting on a square wave as shown here - https://en.wikipedia.org/wiki/Distortio ... ic_signals - but I'm not sure how I would apply that here. Firstly, I'm starting with an arbitrary audio source (though obviously I test with a sine wave), and secondly the tones I'm modelling don't lose bottom end, they just gain harmonics from the distortion, so I'm pretty sure I don't just want a high pass filter.

Any suggestions, and/or C++/numpy code to get me on the right track?
You do not have the required permissions to view the files attached to this post.

Post Reply

Return to “DSP and Plugin Development”