polygonal oscillator

DSP, Plugin and Host development discussion.
Post Reply New Topic
RELATED
PRODUCTS

Post

here's a version using a complex state (and a separate "edge" phasor) instead of single phasor, which solves the issue of wrapping the phasor with noninteger numbers of "sides".

Code: Select all

//init
if (sides < 2.f) sides = 2.f;
angle = tau / sides;
s0 = 1;	s1 = 0;

//loop
p0 += wc * sides * 0.159154943f; //1/tau
while (p0 >= 1.f) p0 -= 1.f;

//	1:	"complex" oscillator (go in circle) 2d rotation matrix
t = s0;
s0 = s0 * w0 + s1 * w1;
s1 = s1 * w0 - t * w1;		

//	2:	determine magnitude of polygon side at current rotation
float t0 = p0 * angle;	//	angle of phase through side
float t1 = .5f * (pi - angle);	//	other known angle in triangle
t = pi - t1 - t0;		//	angle opposite radius/side we are stepping from
t = sin(t1) / sin(t);	//	law of sines
	
oscillator = t * s0;
not faster but more convenient. nice and cheap in 32 bit fp and nifty because continuous partials :) teh pentagrams are sides = 2.5 loosers. only nonideal characteristic is osc is silent when sides = 2.

here's the referenced form locked to one cycle..

Code: Select all

float t0 = p * sides;	t0 = fmod(t0, 1.f);	
t = pi / t;
t = cos(t) / cos((t + t) * t0 - t);
p += wc;	while (p >= 1.f) p -= 1.f;
*out1 = t * sin(p0 * tau);
there is an existing polyblamp antialiasing scheme for this oscillator.

not able to suss it myself, but made this fudgy thing which seems to drop aliasing bands alright for a 1 sample delay,

Code: Select all

float mess = wc * sides * 0.159154943f;	
t0 = 0;
if (p0 + mess >= 1.f) {
	t0 = 1.f - (1.f - p0) / mess;
	t0 = (b0 - trivialosc - b1) * t0 * .5f;
}
else if (p0 < mess) {
	t0 = 1.f - p0 / mess;
	t0 = (b0 - trivialosc - b1) * t0 * .5f;
}
out = b0 + t0;	
b1 = b0 -  trivialosc;	b0 = trivialosc;
but waay more stoned to think what hapen, i just type teh thing.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

polygonaloscspectrum.png
aa method adds loads of noise when the fundamental gets up there (>4k?) but usually is about here (took distance to transition, multiplied it by derivative, end of day smoke, moved bits around got that, works alright for me).
You do not have the required permissions to view the files attached to this post.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

aah -

the original author, as i have above, noted that at a certain point, aliasing becomes worse rather than improved. his aa method and mine both address the corners of the polygon -

i have observed that this threshold is determined by the second partial crossing nyquist. ;) exactly, because, somehow, this harmonic is produced by the unmodulated region of the circle..?

the reason i observed this is because i added phase modulation to the above.. (works nicely, took difference of current and previous phase param and, if != 0, did a brute force cosine sine rotation of the states.)

phase modulation works nicely (it also is nice on the moppeltron complex DSF with inharmonic partials, does accelerating partial cancellations) but for some reason, it does not affect the second harmonic.

oh.

and i am stoned a bit also. so, i realising,

in my method above, we amplify a unit circle by tracing the magnitude of our continuous polygon. so, differently than the original algorithm, which produces the sum with some formula i am too stoned to think about,

my thingy up there can be used to modulate any complex signal.

comes back later and adds: interesting. i didn't note any mention.. polygonal oscillator generates same series as moorer's "equation 4" discrete summation formula. haha. amplitude is flatter. it offers new approaches, eg. shaping the polygon edges.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

ju stink ace your practice of dsp is hindered, as is mine, by some mechanism that prohibits perfect comprehension of various methods "documented" here and there,

here is i guess a generalised transition based antialiasing scheme. it is only derived from my very meagre practice and certainly may be improved, but if you like to fiddle around with things and get electric shocks in your brain from the moon when you try to read about statistics or such,

what i could gather from "transition point based antialiasing methods" (blamp? blep? i just stop paying attn at a point) is that .. say one wishes to treat only the two samples before and after a transition. maybe it fits the implementation better. the distance of the sample from the inter-sample transition is determined. this is then divided by the increment to normalise the distance as 0 to 1 of the sample distance (kind of the idea with the ramp in blamp, i think..). then this is scaled (multiplied) by the slope of the waveform at the current sample. combine the result (maybe with scaling?) with teh waveform, there's a bit of attenuation of high freqs and appreciable attenuation of aliases, about on par with the DPW method.

since i have an incredibly fast dev environment (under a second compile) with borland fclt, i can get stoned and just monkey/proto type all day, trying different thingys, which is pretty much how i settle on most methods.

kinda dumb but none of teh previous discussion clicked for moi so maybe you same.

here's teh sawtooth for perusal

Code: Select all

p0 += wc;
while (p0 >= 1.f) p0 -= 1.f;		

p1 = p0 + p0 - 1.f;

t = 0;	
if (p0 + wc >= 1.f) {
	t = 1.f - (1.f - p0) / wc;
	t = (p1 - b0) * t;
}
else if (p0 < wc) {
	t = 1.f - p0 / wc;
	t = (p1 - b0) * t;
}
		
*out1 = p1 - t;
b0 = p1;
i'd guess since this works pretty that polyblamp is about extending this ramp and shaping it as a polynomial. but off course wee gotta esplane using teh twaddlespeak otherwise teh esplode

https://terpconnect.umd.edu/~toh/spectr ... ation.html
antialiasedsaw.png

Code: Select all

omg strait spoonfed teh aa FM saw
		register float t;
		s0 += wc;
		t = *in2 - bp;
		if (t != 0.f) {
			s0 += t;	while (s0 < 0.f) s0 += 1.f;		
		}
		while (s0 >= 1.f) s0 -= 1.f;		
		bp = *in2;

		
		
		p0 = s0 * sides;	while (p0 >= 1.f) p0 -= 1.f;
		
		
		p1 = p0 + p0 - 1.f;
		
		t = 0;
		wm = sides * wc;
		if (p0 + wm >= 1.f) {
			t = 1.f - (1.f - p0) / wm;
			t *= p1 - b0;}
		else if (p0 < wm) {
			t = 1.f - p0 / wm;
			t *= p1 - b0;}
		
		*out1 = *out2 = dofilter(p1 - t);

You do not have the required permissions to view the files attached to this post.
Last edited by xoxos on Wed Apr 03, 2019 11:28 pm, edited 1 time in total.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

here's a version...
version? of what? has this thread a prequel that i missed? i have no idea what this is about, but it looks like it could be interesting :o
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Continuous Order Polygonal Waveform Synthesis
Christoph Hohnerlein, Maximilian Rest, Julius O. Smith III

further work
EFFICIENT ANTI-ALIASING OF A COMPLEX POLYGONAL OSCILLATOR
Christoph Hohnerlein, Maximilian Rest, Julian D. Parker

i'd thought you'd have done this with soundemote, hadn't checked to see yet.

(*edit* oops)
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

antialiasedstar.png
clipped teh screen capture but nvm
thats far enuff for me,
this is actually a revolving pentagram (sides = 2.5 and very very slightly off to make it spin). the outputs (cartesian axes) are distorted before the aa correction. of course the cartesian distortion kind of turns everything into a diamond shape. my aa correction method doesn't seem to mind the distortion, works just as well as it did, no adjustment. lots of partials.

not worth it for visuals, everything looks like a donut. the pentagram isn't really interesting sounding or anything (1st partial is 1.5x)

i had mentioned distorting the magnitude, this made the points pointier/loopy designs, which is nice for graphics. it only resulted in brighter harmonics. inverting the magnitude i don't remember but it wasn't interesting to me either.

also note that all the oscillator algorithms neglect to add phase modulation (in one of them somewhere) to the "w"/increment term used for antialiasing. works "alright to me" without it, i was seeing noise floor in modulation drop about 10dB with it, but was low anyway...
You do not have the required permissions to view the files attached to this post.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

aha! that looks interesting ideed! thanks!

https://quod.lib.umich.edu/cgi/p/pod/do ... format=pdf
http://www.dafx17.eca.ed.ac.uk/papers/D ... er_100.pdf

soundemote does a lot of geometric sound synthesis stuff, mostly based on max patches by jerobeam fenderson - but not that particular one (i think).
My website: rs-met.com, My presences on: YouTube, GitHub, Facebook

Post

Another thanks here, haven't seen that :tu:

Post

having a think this morning, this pluto conjunct south node morning, and, being impressed with teh benefit of this algorithm, thought it worth recapping.. all of this is obvious to some. only some.

so:
in this approach to polygon, we have an antialiased modulator that can be applied to arbitrary signals (in this case teh complex oscillator/circle). superficially interesting.. same series as equation 4, and ring modulation processing, not anything that novel. the connection between polygon and equation 4 is intriguing for me, to others possibly not.

am i making this too complicated.. can we get away with a cheaper estimate of the deviance between unit circle and polygon side at angle. like 1 - p * (1-p) * scale

note..
this method of generating teh polygon is simple and efficient audio synthesis. the band limiting can take abuse as demonstrated by distortion. as noted by another "transition point aa method" developer "you can pretty much do whatever you want as long as you handle teh transition points". i didn't understand this initially because their code was presented with some funky logic "while(true)" i have attempted to evade in my example.

but spelling it out:
any kind of "LineTo" procedure can be used to shape teh oscillator. you could draw donkey t's johnson, or make oscillators out of your company logo. you're just taking one orthogonal axis, and applying transition point antialiasing. so much cheaper than oversampling.

trivially. with mediocre dsp practice.

the polygon method itself can be adapted to prehensile architecture with minimal expense. we can perform modulation of the "sides" rate at the vertices only, saving cpu.

introduce one extra variable to write a temporary increment value which is computed at vertices. now a random value modulates "side" rate at each vertice.. inexpensive. what if we toggle between two rates at each vertice.. twice the number of harmonics, i expect.. complex functions to modulate the rate just here instead of constantly may achieve any number of spectra. all antialiased and superefficient. all taking zero statistics/calculus knowledge. we could modualte randomisation amount by side length, creating more variance in a region of the spectrum. we could modulate the side length by the phase of the circle. we could add in "chaos oscillator" feedback. lots of cheap n easy options any enthusiast could implement with significant control and flexibility, making n-DOF architecture for freaking cpu pennies.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

xoxos wrote: Thu Apr 04, 2019 10:34 pm this method of generating teh polygon is simple and efficient audio synthesis. the band limiting can take abuse as demonstrated by distortion. as noted by another "transition point aa method" developer "you can pretty much do whatever you want as long as you handle teh transition points". i didn't understand this initially because their code was presented with some funky logic "while(true)" i have attempted to evade in my example.
Is that something I wrote?

The reason I use "while(true)" with explicit breaks is because if you have multiple transitions during a single sample (which happens with high enough frequency; the method in principle works even beyond Nyquist), then it's necessary to keep checking until the next expected transition fails (in which case there's an explicit break).

You could also think of it as a suspendable state-machine as a stackless co-routine, but I doubt that's going to be helpful to anyone without some theoretical CS background.

Post

antialiasedpolygon.PNG
a phase derived distortion had serviceable sidebands, nothing you haven't heard before

yes mystran, i wasn't able to discern what was happening enough to use it for anything but the given saw. eg. gate reset awful clicky. had just finished a unison engine using your method, then found dpw, then the above.

it satisfies my sensibilities to see these simple methods being so effective after these years. what a kickback.
You do not have the required permissions to view the files attached to this post.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post

you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.

Post Reply

Return to “DSP and Plugin Development”