Oversample your Oscillators with R_OpenLib

Post Reply
User avatar
ChR_is
Posts: 106
Joined: Wed Sep 22, 2021 5:48 pm

Oversample your Oscillators with R_OpenLib

Post by ChR_is »

I updated R_OpenLib today with separate Upsampling and Downsamping classes that you can use, for instance, to oversample your own oscillator implementations.

Here's a tutorial on how to create an oversampled oscillator:
https://youtu.be/Lm0zI0a2Qus

Get R_OpenLib here:
https://github.com/NeverKnewTheName/R_OpenLib
poetix
Posts: 54
Joined: Mon Nov 28, 2022 3:26 pm

Re: Oversample your Oscillators with R_OpenLib

Post by poetix »

If I'm not mistaken, this:

Code: Select all

    public double process( double value, R_IOversampledProcessor processor )
    {
        double[] os = new double[m_osFactor];
        os[0] = value; // first value is valid, others are zero-stuffed

        //////// OVERSAMPLING
        for( int i = 0; i < m_osFactor; ++i )
        {
            os[i] = m_upSampler.process( os[i] );
            os[i] = processor.process( m_osFactor * os[i] );
            os[i] = m_downSampler.process( os[i] );
        }
        //////// OVERSAMPLING

        return os[0];
    }


could be rewritten as this:

Code: Select all

    public double process(double value, R_IOversampledProcessor processor) {
    	// Upsample, process and downsample the value itself, getting the result
        double result = m_downSampler.process(
                processor.process(factor * m_upSampler.process(value)));

	// Feed processed zeroes into the up/down filters so everything is in the right state for the next impulse
        for (int i = 1; i < factor; i++) {
            m_downSampler.process(
                    processor.apply(factor * m_upSampler.process(0)));
        }
        
        return result;
    }
I think there's no need to allocate an empty array and write values into it that you're just going to throw away anyway?
London, UK
Developer, Vulpus Labs
Musician, w/trem
poetix
Posts: 54
Joined: Mon Nov 28, 2022 3:26 pm

Re: Oversample your Oscillators with R_OpenLib

Post by poetix »

(It works great, by the way - using it on a waveshaper and it appreciably cleans up some of the high-frequency fuzz and whizz)
London, UK
Developer, Vulpus Labs
Musician, w/trem
User avatar
ChR_is
Posts: 106
Joined: Wed Sep 22, 2021 5:48 pm

Re: Oversample your Oscillators with R_OpenLib

Post by ChR_is »

You are correct. in fact i did that optimization already, but haven't pushed the update yet.
the allocation is unnecessary and can be optimized exactly the way you have pointed out. thanks!

update is now live in R_OpenLib. i also added a utility class with some helpful, optimized functions i tend to use often.
Post Reply

Return to “Module Designer”