Custom Osc Object Oversampling Possible?


#1

Is it possible to oversample (i.e. use a higher sample-rate that the standard 48kHz), just for a specific object?
I'm assuming not, but just wanted to check.

a|x


Up/downsampling
#2

That is a responsibility of the oscillator code, there are several potentially useful compromises in the downsampling filter, that impact the oscillator code. Depends on the type of oscillator...


#3

Makes sense, there's no provision for an oversampled signal path, but objects can upsample and then downsample within themselves.


#4

Doesn't it destroy the point of oversampling, if the signal isn't oversampled all the way to the DAC?

a|x


#5

There really is a point in oversampling inside a single object without going all the way to the DAC.
There are use cases for an oversampled signal path too, but currently no provisions.


#6

I see. Maybe I'm misunderstanding the purpose of oversampling. I thought it was to push the Nyquist limit well above the audible range, to reduce aliasing artifacts. I'd have thought that effect would be lost as soon as you downsampled again...

a|x


#7

All depends on what is in the signal chain.
A oversampled-filtered-then-downsampled oscillator will have reduced aliasing artifacts, but no ultrasonic spectral content anymore. Is the ultrasonic spectral content relevant? Non-linear processing (distortions, modulations) potentially demodulates ultrasonic content to audio range.

It is required to filter out ultrasonic frequencies before downsampling.


#8

I see. So you filter out frequencies that might cause aliasing before downsampling.

Thank you for the explanation.

a|x


#9

The idea is that you upsample to raise the nyquist limit, do whatever it is you need to do (usually some kind of oscillator code or a non-linear function like distortion), then low-pass the signal to remove components above the target nyquist frequency and finally downsample safe in the knowledge that you already filtered out the stuff that would alias.

EDIT: I should have kept on reading and seen that Johannes explained.
But yes, downsampling as soon as you can get away with can be a good optimisation. If the entire signal path was 96kHz then all s-rate objects would take approximately twice as much processing power.


#10

I see. Are there any Factory objects you know of that use this technique? I'm interested to see how it's done, particularly the filtering and downsampling.

a|x


#11

I'm not sure, maybe some of the oscillators? It's something I understand conceptually a lot more than I do in terms of actually implementing it. Oversampling is something I've been trying to learn about recently but I've not got as far as actually doing anything with it.
Plus I'm awful (and lazy) at reading code so I've not analysed many of the more complex factory objects. :stuck_out_tongue:


#12

The standard (not the cheap or medium versions) saw, square and pwm oscillators use a 64-fold oversampled/filtered table of a step function (0th order discontinuity), rather than explicit oversampled+filtering+downsampling. The triangle wave oscillator uses a 64-fold oversampled/filtered 1st order discontinuity table.
http://www-ccrma.stanford.edu/~stilti/papers/blit.pdf


#13

@johannes since we're in topic: is there any way to implement an alias-reduced version of table/read and table/read_interp to be used with generic sources? I have noticed that feeding high pitched phasor to such table read objects results in truly heavy aliasing


#14

Well I would think the problem is the harmonic content of the table you're reading. Clearly the table contains harmonics that you're pushing beyond nyquist with those high notes.
Unless it aliases with a table containing a sine-wave then this isn't really a problem with table/read_interp.


#15

Well that is the problem, clearly. But in case one wants to use such objects as waveshapers? As far as i know oversampling is diffusely implemented in waveshapers to mitigate this effect.
Also table/read is (by now) the only way to implement phase modulation synthesis with waveforms different than sine, so it's a very big big deal


#16

Reducing aliases from table playback is hard when there is high-frequency content in the table. An oscillator tuned to over 12kHz should in fact output a sine wave, no matter what the table content really is, all other spectral content would be aliased. An interpolation filter that reduces a (relatively) long table to a sine wave would need a lot of coefficients...
One approach is to expand one wavetable to a set of tables, with every table filtered to limit harmonic content. And then selecting the right table during playback. But then it becomes critical to hide artifacts originating from switching between tables, this could become problematic when pitch is modulated...


#17

Ok, so I guess you're suggesting that the tabled be interpolated at 2x (or 4x or whatever) the rate and then lowpassed and downsampled.
I think that would require upsampling/interpolation of the phasor input? But only interpolation on increase as it's important that the phasor wraps cleanly from maximum to minimum (otherwise you'd end up with an incredibly fast 'rewind' through the table).


#18

What i don't understand is the 12 KHz limit. Why is that low? Shouldn't it be closer to 24?


#19

Generally waveshapers using a lookup-table is hard to get right. Often a waveshaper curve is relatively low-frequency content, like soft-saturation distortion. In that case it is more important to do the waveshaping on oversampled signal than improving the wavetable interpolation.
Some other tricks can be used for special waveshapes. A comparator function only requires the location of zero-crossings. Those locations can be found by linear (or higher order) interpolation, the result can be constructed from an oversampled/filtered step function. "dist/inf" takes this approach.
Half- and fullwave rectifiers are similar, but using an oversampled 1st order discontinuity table.

I've been thinking : a sine-waveshaper can be evaluated to obey the nyquist limit when assuming linear segments... But I have not implemented this.


#20

For a 12kHz fundamental frequency (pitch) the next harmonic is at 24kHz already. So ideally, all oscillators at a pitch over 12kHz should output a pure sine wave, above 24kHz pitch all oscillators should output just silence...