the beginnings of a beautiful era for audio dsp

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

Post

i like that part in evil flow,
cos i'm modeling the future over and over
except it's like, the future, and, over like, over

clever things, appeal to the intellect, tricky

or like right there
the horns of the lord above, brother
see the horns on me - i get blowed
before they get to you - i get stuck
come see the horns on a big bad demon

course it's got that horn sound in the background. clever though. "doctor xo"
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

adding the saw.
normalisationsynthesis.png
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

viewtopic.php?p=6656238#p6656238
xoxos wrote:

Code: Select all

double t = s0;
s0 = s0 * w0 + s1 * w1;		//	circular oscillator
s1 = s1 * w0 - t * w1;

x = s0 * *in2;				//	scale
t = s1 + *in4;				//	offset
			
y = t * m0 - x * m1;		//	angle
x = x * m0 + t * m1;

*out1 = y / sqrt(x * x + y * y);
Has anyone been able to translate this into working C++ code? I'm too math-illiterate :(

oh wait I'm seeing something here.

rotation is defined as:

Code: Select all

*X = x * cos(angle) - y * sin(angle);
*Y = x * sin(angle) + y * cos(angle);
is this correct?

but it looks somewhat different than tis

Code: Select all

s0 = s0 * w0 + s1 * w1;		//	circular oscillator
s1 = s1 * w0 - t * w1;

y = t * m0 - x * m1;		//	angle
x = x * m0 + t * m1;
I'm guessing w0/w1/m0/m1 are -1 to +1 values coming out of a sin/cos function, so

m0 = cos(m);
m1 = sin(m);

w0 = cos(w)
w1 = sin(w)

s0,s1 is internal updated variable
x,y is the output

that leaves t, m, w, in2, in4 variables unknown
in2, in4 are parameters... t, m, w, not sure. one or two of those is phase?
t is angle?

that means m and w. 90 degrees phase different from a single phase/angle value?

Post

I want to possibly turn this into an envelope generator.

here's my attempt at C++ code, I don't know what to do with s0, s1, w0, w1. One of them is definitely phase.

Code: Select all

	double xoxos(double s0, double s1, double angle_m0, double angle_m1, double w0, double w1, double scale, double offset)
	{
		double x, y, t = s0;		

		s0 = s0 * w0 + s1 * w1;
		s1 = s1 * w0 - t * w1;

		x = s0 * scale;
		t = s1 + offset;

		y = t * angle_m0 - x * angle_m1;
		x = x * angle_m0 + t * angle_m1;

		return y / sqrt(x * x + y * y);
	}

Post

here's working version using formula given earlier, but it is not recursive, it just takes in a phase.

Code: Select all

  	double xoxos(double phase, double A, double B_sin, double B_cos, double C)
	{
		double sin_x, cos_x;
		sinCos(phase, &sin_x, &cos_x);

		double sqrt_val = sqrt(pow(A + cos_x, 2) + pow(C*sin_x, 2));
		double out = ((A + cos_x)*B_cos + (C*sin_x)*B_sin) / sqrt_val;

		return out;
	}
Last edited by Architeuthis on Sun Oct 01, 2017 5:46 pm, edited 1 time in total.

Post

st0 and st1 are used as state variables
this is a recursive structure, not a mere function
It doesn't matter how it sounds..
..as long as it has BASS and it's LOUD!

irc.libera.chat >>> #kvr

Post

antto wrote:st0 and st1 are used as state variables
this is a recursive structure, not a mere function
ok yes! So please correct my c++ code, i waaant iiiit :ud:

removed attempt 1
Last edited by Architeuthis on Sun Oct 01, 2017 6:25 pm, edited 1 time in total.

Post

attempt 2

Code: Select all

class XoxosOscillator
{
public:

	void setFrequency(double v) 
	{ 
		double phaseInc = (v*4)/sampleRate * PI_z_2 + PI_z_2;
		sinCos(phaseInc, &w0, &w1);
	}
	void setSampleRate(double v) { ; }
	void setAngle(double v) { sinCos(v, &m0, &m1); }
	void setScale(double v) { scale = v; }
	void setOffset(double v) { offset = v; }

	double getSample()
	{
		double x, y, t = s0;

		s0 = s0 * w0 + s1 * w1;
		s1 = s1 * w0 - t * w1;

		x = s0 * scale;
		t = s1 + offset;

		y = t * m0 - x * m1;
		x = x * m0 + t * m1;

		return y / sqrt(x * x + y * y);
	}

protected:
	double s0 = 0, s1 = 1;
	double w0 = 0, w1 = 1;
	double m0 = 0, m1 = 1;

	double
		sampleRate = 44100,
		frequency = 1,
		scale = 0,
		offset = 1;		
};
Last edited by Architeuthis on Sun Oct 01, 2017 7:19 pm, edited 2 times in total.

Post

removed attempt 3
Last edited by Architeuthis on Sun Oct 01, 2017 6:25 pm, edited 1 time in total.

Post

ok so attempt 2 is the most correct so far, and im correcting my earlier post for the formula that just takes in phase.

all i need to know is how to convert pi/2 to pi range to frequency.

Post

ok i got frequency control but I have no idea wtf I'm doing,

what is this equation? and I'm not sure it's correct to call the result phaseInc... maybe call it rotationSpeed?

Code: Select all

void setFrequency(double v) 
{ 
	double phaseInc = (v*4)/sampleRate * PI_z_2 + PI_z_2;
	sinCos(phaseInc, &w0, &w1);
}

Post

Rotations are good because they preserve signal energy (i.e sum of their squares).

To sort things out, maybe, you can have a look at :

https://ccrma.stanford.edu/courses/250a ... ilters.pdf

It shows how a pass band filter can be implemented with a rotation/scale i.e. a complex multiplication.
This implementation is very stable even with audio rate frequency modulation :hyper: .


I've derived a simple variant - much simpler than your attempts - of the Matthews filter.
Non linear modulation of the rotation depending on the input or/and output.

Even this basic variation leads to interesting sort of filtering/distortion.

I used this principle in a Reaper synth (cXf synth available in the Reaper Stash) :

https://soundcloud.com/thierry-rochebois-1/test-cxf03
https://soundcloud.com/thierry-rocheboi ... nth-rev-07

It uses a pair of sines as an input to a self-non-linearly-frequency-modulated Matthews filter.

Now... imagine this with coupled units.. and even delays in the feedback loops...
There is so many possibilities to experiment with !
See you here and there... Youtube, Google Play, SoundCloud...

Post

Smashed Transistors wrote:Rotations are good because they preserve signal energy (i.e sum of their squares).
In exact arithmetics, yeah.. in floating point, not so much. Rounding errors with "naive rotation" lead to both phase drift (=wrong frequency) and amplitude drift (which should be fixed periodically).

To get you an idea of how much the accuracy can cause trouble, one of the first version of my FFT used naive rotations. It turns out that (in double precision!) this made an FFT unstable somewhere around 1 million points (maybe earlier, I don't know). There are better recurrences though (eg. the undamped ZDF-SVF is a good one).

Post

ZDF-SVF can be cool to experiment with :D

Is ZDF-SVF stable with audio rate frequency and Q modulations ?
See you here and there... Youtube, Google Play, SoundCloud...

Post

Smashed Transistors wrote:ZDF-SVF can be cool to experiment with :D

Is ZDF-SVF stable with audio rate frequency and Q modulations ?
Yeah. It essentially comes down to damped rotations, just calculated in a different way.

Post Reply

Return to “DSP and Plugin Development”