Anti-aliasing as a discrete module?

Squinky beat me to it, but yeah to summarize:

If you know what the signal is suppose to look like, you could try and correct for aliasing. That is what you are doing with minblep inside your VCO. And yes you could do that as a separate module. But it would only work on the waveforms from your VCO or other VCOs like it.

Making a general-purpose anti-aliiaser that works on any input signal with no knowledge about what that single should look like, is impossible. That is what the nyquist theory proves.

Doing something in the middle, an anti-aliaser that works on a wide range of wave forms but not all would be interesting. You could call it a “Semi-Anti-Aliaser”. But I don’t have a good enough understanding of the math involved to know how successful something like that might be. A simple example would be one that works on square waves and step functions. It would look at the input voltage, and whenever it changes it would minbleep that jump. But what that would do to a saw or sine wave, idk.

In general I agree with your post - will written, too! But this square wave example doesn’t work. How would you “determine” where the discontinuity occurred in time? I think you need to be accurate to 1/16 of a sample, at least with the minBLEP parameters that VCV uses in their VCOs.

1 Like

Yeah I get it - you would somehow have to inform the module of the subsample timing of the discontinuity, which is where it falls apart. The fallacy in my line of thinking was quite simply that I was looking at it from a sample-based point of view, which isn’t exactly how it works in reality. You could write an algorithm that says “a discontinuity occured during this sample”, but you can’t get any more precision than that.

2 Likes

I don’t think its just the subsample timing, although I’m not an expert.

Surely the minblep has to have the correct frequency. You could try to work that out using an fft, but since the signal into the fft already has the unwanted alias frequencies, i don’t thonk that would be effective.

Bobbins

No, part of the beauty of minBLEP is that it doesn’t need freq. it only needs step size and position.

Thank you. I thought I understood minblep, clearly i don’t

I have a repo from a few years back that shows how to make a minBLEP VCO. Basically a simplified version of the 2.0 version of Fundamental. It has no theory, though. GitHub - squinkylabs/Demo: A collection of code and articles of interest to VCV users and developers.

2 Likes

I’d be interested in a module that downsamples without anti-aliasing, but only reproduces the aliasing. You can fake it with a high-pass filter, but I wonder if subtracting the original samples from the output of bad downamplign would work.

I discover that mixing a clean signal inverted with a crudely downsampled version of the signal really seems to filter almost all of the clean signal out of the aliasing noise. This patch is more complicated than it needs to be but it illustrates the principle.

2022-04-05.vcv (10.8 KB)

1 Like

And you haven’t found any “bitcrusher” or “lofi” modules in VCV that will do this well? There are certainly some ones that sound promising.

It isn’t that you can’t downsample a signal, I was talking about filtering out the good signal to just keep the aliasing noise.

Not your cup of tea I know, but it can have an intriguing sonc quality all it’s own.

I tried inverting the clean signal and adding it to the downsampled signal. I think frequency-dependent phase issues mean the clean signal isn’t entirely filtered out. The lower the frequency the more the original signal comes through. This is what it sounds like to me, it’s not a conclusing I reached by applying theory and doing math.

I just wondered if mathematically you could get just the ‘error’ signal - the aliasing all by itself.

with my limited dsp understanding, getting only aliasing of an arbitrary wave is equally impossible to anti-aliasing because you don’t know what harmonics are supposed to be in the “pure” version of the signal. but with your specific downsampling idea, i think you could get close by doing some kind of spectral analysis of the original signal. or if it’s phase issues you can just delay the dry signal until it lines up?

1 Like

What you are doing is phase cancelling X samples of a signal, where X is the downsampled rate. To my understanding, the remaining signal doesn’t really relate to aliasing noise at all.

Just adding a slightly different perspective:

Aliasing “happens” when we convert a continuous time signal x = f(t) to a discrete time signal x[i] = f(i / Fs). When we make that conversion, we lose information, and any frequencies above the Nyquist are “folded” down into that range. These folded frequencies become the aliasing. The reason a true generalized anti-aliaser can’t exist is because sampling discards information, i.e. there are an infinite number of possible continuous time reconstructions for any given discrete time signal, and we have no way of knowing which was the original. It’s tempting to just add a MinBLEP to every sample in a signal (which mathematically would be the same as a lowpass filter), but, because we don’t have the information to reconstruct the original signal, those MinBLEPs would be also applied to the aliased parts of the waveform.

The reason MinBLEP works when used within an oscillator, even though it’s being applied to a descretized signal, is that we still have information about the original continuous signal. The designer can use that information to figure out where to place MinBLEPs before that information is discarded.

3 Likes

Now, if you know for sure exactly what kind of signal is coming into a module, e.g. it’s always a square wave, or a sawtooth, etc, there’s no reason anti-aliasing couldn’t occur in a second module after “leaving” the oscillator. But to get useful results, you’d need to make some pretty big assumptions about what the original continuous time waveform looked like, which wouldn’t hold in the general case.

If it were square, how would you know where the step occurs at sub sample resolution? Saw I get, as per above discussion.

That’s the “very big assumptions” part. You could in theory estimate the frequency and use that to guess where sub-sample transitions occur, or just take that info in via a second cable, but it’s not really generalizable or accurate. The point is more that anti-aliasing doesn’t strictly need to happen within the same module, but you Do either need extra info or big assumptions for it to work.

I should think you would also need to know (or assume) something about the pulse width.

Good point!

Well, you did say square…. So pw is a given. I figured you might come back with estimate the fundamental. Sorry, that is wildly out of scope here. That why I said OP method could not work for a square. I think we both know that not only is that a super special case, but it probably wouldn’t work in the real world, and for sure no sane person would try it.