Custom Osc Object Oversampling Possible?


#21

How is downsampling of oversampled waveforms usually done? Is it just a case of throwing away half the samples, or is some kind of averaging done?

a|x


#22

Right! That's what i've been missing (together with a lot of other math related stuff)
Therefore the next step, which is waveshaping a generic signal with a generic waveshape would be only possible if that signal was insanely oversampled to be then downsampled after the waveshaper.
I guess i'll have to live with that aliased sound, then.

What about the linear segments approximation: would it work only with a sineshaper or could it be used in other circumstances?


#23

I think I've seen some implementations where they just throw away half the samples, as long as your filtering was adequate it's sort of already done the averaging for you.


#24

Essentially upsampling is inserting N zeroes between every sample, downsampling is keeping only every Nth sample.
That introduces pure aliases, to make it behave nicely, filters need to be added. The art is in the filter design...

in virtual analog there is a limit to what can be emulated nicely.
In theory, you should be able to create a sine wave oscillator by feeding a sawtooth oscillator through a sine waveshaper. But even a perfectly bandlimited sawtooth oscillator will fail to do so, in this situation the aliased osc/phasor without any oversampling is the right thing to use.

Only certain special cases "collapse" the computational complexity compared to an expensive but generic high-samplerate waveshaper implementation. I have not proven or implemented the sineshaper idea, so far it is only a rough idea. The attraction is that it is easy to evaluate if a certain segment will fit inside the nyquist limit. There are other possible waveshaper approximations - linear or parabolic segments. Assuming linear segments is not really great when the input signal gets any close to Nyquist. Or fitting the waveshape to a chebychev polynomial guarantees a certain oversampling factor to be sufficient... Often it is beneficial to consider what maps well to the processor, replacing complex functions with lookup tables, or using 8-bit operations where this causes a speedup, reducing the cost of oversampling. The low signal-to-noise ratio of 8 bit (48dB) may still be better than aliases in some cases, oscillators do not need headroom...


#25

This is very illuminating, thank you, guys.

a|x


#26

So there's no simple 'one-size-fits-all' alias-eliminating filter you can just stick on any oversampled oscillator (say a wavetable osc with arbitrary waves) before downsampling to the output sample-rate?

a|x


#27

Well, your objective is to make sure there are no harmonics above the target nyquist frequency. It's possible that you might not have oversampled enough though, each doubling of the sample rate only gives you another octave after all. So if something is hitting the oversampled nyquist (say 48kHz for a 96kHz sample rate) and then reflecting back down below your target nyquist (24kHz for the 48kHz SR), then no matter how adequate your downsampling filter is you'll still have aliasing.


#28

That's true..
I wonder what methods other hardware-based 'virtual modular' synths (eg Nord Modular/G2) took for anti-aliasing.

a|x


#29

Doesn't the G2 use 96kHz off the bat? It also might use oversampling within objects, but we don't know because it's not open source as far as I know...


#30

G2 is 96 khz yes. There is a hacked version of Nord G2(only windows) that has ALL features unlocked... Maybe you can look in the code for that one? I am not sure what to look for, so never tried and I am only on Mac.


#31

The G2 Demo software will be compiled, though. You won't be able to see the sourcecode.

I imagine the implementation details will be quite different from the G2 hardware firmware, too.

The G2 Editor software still works on the latest MacOS version, which is good, as I have a G2 Engine.

a|x


#32

Well, I think it is a hacked version of the demo, but as far as I know it has got all features unlocked..

I have an engine too :smile:


#33

It is, but running it won't tell you much about how things are done internally.

a|x


#34

A general wavetable requires a high oversampling factors. Imagine the two-point {-1,1} wavetable, that's a sine... Better to have some bandlimit already built into the wavetable.
There is more than one way to do sample rate downconversion by factor n. A polyphase FIR looks good but expensive. CIC is probably an interesting compromise, but often still complemented with a FIR to improve the CIC properties...

and even if it would, the algorithms are optimized for the constraints of its 24bit/56bit DSP, translating those to efficient code is less effective than writing them from scratch.