SynthMaker

oversampling oscillators

Archive · 2005 6 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

global goon ·

how does this work then? how can i make a sin oscillator using stefancrs sin osc with less aliasing at v. high freqs?

global goon ·

here's stefancrs code:

polyin freq; polyin phase; polyout out; float cos; float sin; float tCos,tSin; float mul; // since the code component does not support initialising of variables we have to do a hack float isInitialised; isInitialised= ((cos > 0) & 1.0) + ((cos < 0) & 1.0); cos = (1.0 - isInitialised) * 0.99 + (isInitialised > 0) & cos; mul = freq * 1.0 * 3.141592; // roughly pi

cos = cos - sin * mul; sin = sin + cos * mul;

/* this is the "obvious" implementation of phase modulation tCos = cos - sin * phase; tSin = sin + tCos * phase; out = tSin; but we can simplify it into one expression instead for better perfomance, like this */ out = sin + (cos - sin * phase) * phase;

stefan ·

I'd say that it's probably more effecient to just reduce the phase modulation at high frequencies. Oversampling is easier now that you can have loops though.

global goon ·

thanks stef.

so to oversample 3x, i do something like this??:

multiply each sample by 8 (2^3) do processing apply LP filter at 22050 Hz divide by 8

I just made that up - really i've no idea how to do this !! 🙂

stefan ·

Hm. Well. It's a bit tricky to do it nicely without having any arrays.

If it's a filtering/effect process (working on audio input) you can do it like this for 3x oversampling:

1) Make new input (I) where every third sample comes from original input, and the other two are 0.0.

2) Lowpass (I) at original nyquist (for instance 22050hz)

3) Do processing, (I)->(O) where (O) is your oversampled output

4) Lowpass (O) at original nyquist (for instance 22050hz)

5) Output every third sample from (O)

Remember that you're working at original samplerate * 3 when implementing the process and filtering. It's easier atm to do this in oscillators for instance, because all you have to care about then is to pick every third sample from (O), you don't have to worry about step 1 and 2 if you do it right.

global goon ·

thanks stefancrs\!!

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.