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?
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].