Oversampling

Post Reply
UrbanCyborg
Posts: 599
Joined: Mon Nov 15, 2021 9:23 pm

Oversampling

Post by UrbanCyborg »

Basic question: just how do you oversample in VM? I don't mean the algorithm; I mean, how do you do it, given that the only access you have is via a method that is locked to the 48K base frequency? Is it a matter of taking it into the frequency domain?

Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
UrbanCyborg
Posts: 599
Joined: Mon Nov 15, 2021 9:23 pm

Re: Oversampling

Post by UrbanCyborg »

Let me modify the initial post. Is the method to maintain a circular buffer with the n most recent samples (likely a power of 2) and apply the oversample/downsample algorithm on the buffer at each 48K sample call? Seems that could get expensive pretty fast.

If that's the method, does Java have a library container that works as a circular buffer, or do I just write my own?

Reid
Cyberwerks Heavy Industries -- viewforum.php?f=76
ColinP
Posts: 951
Joined: Mon Aug 03, 2020 7:46 pm

Re: Oversampling

Post by ColinP »

I had hoped that someone who has actually implemented oversampling might chip in with useful tips but not so far, so here are my thoughts...

I looked at this a while ago but haven't tried it yet because I have had bigger fish to fry. Although I'm approaching beta stage now so we shall see.

Yes, it does look expensive and I'm not sure the processing hit is worth it as I'm currently getting OK results with linear interpolation so am going to just try polynomial interpolation in a while to see if there's much improvement for my application. My hunch is that oversampling is in effect just one way of implementing polynomial interpolation anyway but I'm not a mathematician.

In my current granular synthesis project I've managed to get 500 "VCOs", 500 "envelope generators" and several thousand "VCAs" running at once just about without any obvious glitches so going down the oversampling route is something I'm wary of as it would reduce my scope considerably.

As for Java implementations of various data structures the website Stack Overflow is your best port of call. For me I built a Buffer class that hides all the implementation from the rest of the program and that enables me to tinker with deep buffer algorithms at my leisure without it having any impact elsewhere. If you are looking for maximum performance then it's perhaps best to do the same rather than rely on someone else's code, although it depends on how much experience you have of optimization.
UrbanCyborg
Posts: 599
Joined: Mon Nov 15, 2021 9:23 pm

Re: Oversampling

Post by UrbanCyborg »

Thanks for the response, Colin. I've come to the conclusion that no one is actually oversampling; what they're doing is upsampling, which amounts to a resampling of a zero-inflated history buffer, followed by low-pass filtering. You upsample, do your work at the new, fake higher sample rate, then downsample via another filter to kill noise above your max usable frequency. The essence of the algorithm is that it kills frequencies in upsampled space that would have aliased had they just been generated in non-upsampled space.

I don't think there's any way to actually oversample without having access to the guts of VM, and the ability to make it cycle at more than 48K. I wonder whether the "oversampling" built into most of the stand-alone CA synths is actual oversampling or upsampling.

I'm fine with code optimization, although most of my experience has been in C, C++, and various assembly languages (mainly x86, 68xxx, and even Z80, but with some mainframe ones, like IBM 1130 and 360/370). I'd just not wanted to reinvent the travois, if it already existed. :)

Your code sounds impressive; I think I'm going to love playing with it when you release it.

As for Stack Overflow, the few times I've bothered to ask anything there, the responses were hostile, non-helpful, and generally supercilious in tone. I'd rather just roll my own than go there again.
Cyberwerks Heavy Industries -- viewforum.php?f=76
ColinP
Posts: 951
Joined: Mon Aug 03, 2020 7:46 pm

Re: Oversampling

Post by ColinP »

Hi Reid. Oversampling is indeed just up-sampling, doing some processing followed by low-pass filtering at the higher virtual sample rate and then down-sampling . It's a useful anti-aliasing technique but not a silver bullet. And as I think you are hinting at, it's in danger of becoming a marketing phrase.

Library code is great but opaque so in specific mission critical situations I think it's best to DIY and it sounds like you definitely have the skills required to roll your own.

Obviously (and rightly) there's no access to pointer arithmetic in Java but I think if you work sensibly on arrays with primitive types then the compiler and JVM can do pretty clever automatic optimizations that produce essentially pointer like machine code.

Us old git have to keep reminding ourselves that there's no need to do olde worlde stuff like algebraic optimizations anymore because the machine intelligence underneath Java does a far better job.

I'm looking forward to checking out what you publish.

Yeah, there are some very immature posters on Stack Overflow (as everywhere) but it's still a useful resource.
Post Reply

Return to “Module Designer”