DCO VCO and Hillary Clintons underwear!
Magnus Danielson
magnus at analogue.org
Fri Nov 6 00:39:07 CET 1998
>>>>> "BN" == Bjarne Nillson <bnillson at hotmail.com> writes:
BN> regarding to the VCO DCO discussion, there are many
BN> shemos solving the problems about taht but how a
BN> some digital solutions?
BN> I hear lot of talking that this person and that person have done
BN> phase accumulator oscilators,circularbuffer osc's, FIR filters and lots
BN> of otter stuf.
BN> But i have seen a single piece of shemo and software that actually
BN> does some sythesis of some kind!
BN> I feel it are lots of big words and no action!
Well, let's fix that!
In some C code:
typedef struct
{
/* bit precission */
int p;
/* Sample frequency */
double fs;
/* Cut off frequency */
double f0;
/* input value */
long x;
/* output value */
long y;
/* memory storage */
long c;
/* feedback/pole constant */
long b1;
/* forward/zero constants */
long a0, a1;
} iir;
void iir_setup(iir * p)
{
/* Filter preparation variables */
double w0, T, w0p, b;
long A;
A = 1 << p->p;
/* Prepare filter - Bilinear transform of a passive RC filter */
w0 = 2 * PI * p->f0;
T = 1/p->fs;
w0p = 2/T*tan(w0*T/2);
b = 1/(1 + 2/(w0p*T));
p->a0 = (long)floor(b * A);
p->a1 = (long)floor(b * A);
p->b1 = (long)floor((1 - 2/(w0p*T)) * b * A);
}
void iir_step(iir * p)
{
/* intermediate storage */
long d;
/* Loop Filter */
d = p->c;
p->c = p->x - p->b1 * d >> p->p;
p->y = p->a0 * p->c >> p->p + p->a1 * d >> p->p;
}
Now, this is a simple implementation of a IIR equivalent of a bilinear
transformed 1-pole RC lowpass filter. You run the setup after selected
a sample frequency fs, a filter cut-off f0 and a bit precission p in
the struct. The setup function will calculate the filter constants.
The step function will execute a 1-sample run of the filter, you
insert a new x value from your source and take out the result on y for
every time you run the step function.
Althought this is avery simple example it may be usefull. Oh, BTW: the
bilinear transform is such that the filter will not be stable if f0 >
fs/4 but at and below this limit it works fine.
Now, for a simple phase accumulator:
typedef struct
{
/* bit precission */
int p;
/* Sample frequency */
double fs;
/* Requested frequency */
double f0;
/* accumulation value */
long accval;
/* mask value */
long mask;
/* phase */
long phase;
} phaseacc;
void phaseacc_setup(phaseacc * p)
{
long A;
A = 1 << p->p;
/* Calculate accumulation value */
p->accval = (long)(f0/fs*A);
/* Prepare mask */
p->mask = A-1;
}
void phaseacc_step(phaseacc * p)
{
phase = (phase & mask) + accval;
}
This will implement a phase accumulator where you use the setup
function to calculate the accumulation constant (note that it is
linear with requested frequency) from the given sample frequency and
requested frequency. The requested precission will be the number of
bits used for phase, 2 bits will give:
00 => 0 degrees
01 => 90 degrees
10 => 180 degrees
11 => 270 degrees
where 3 bits would give
000 => 0 degrees
001 => 45 degrees
010 => 90 degrees
011 => 135 degrees
100 => 180 degrees
101 => 225 degrees
110 => 270 degrees
111 => 305 degrees
The mask will ensure that the overflow (number of cycles) will not be
feedback, only the residue phase. The phase accumulator will generate
a ramp/sawtooth waveform. The frequency of this waveform is
accval
f = ------ * f
0 p s
2
So the output frequency will be linear with the accval value. However,
due to good old Nyquist will the maximum frequency be half the sample
frequency, but when you drive the accval above this value the phase
accumulator will go backwards and thus allow negative frequencies ;)
BN> Maybe it is that people want to protect thier software or what!
See above. I share.
BN> Quit dissapointing since today many are talking about DSP and stuff
True.
BN> I belive the C sound was a failure , it tok too long to put the dam
BN> thing out.
BN> And the nord modular, remember the list talk a 1.5 year ago about
BN> many of you people beeing sceptic about the realtime performance.
True.
BN> And the expensivness of the Kyma system.
BN> And finaley have any one any experience about the Creamware Pulsar
BN> DSP software synt??
BN> BJ in the land of confusion.
Magnus in the land of BJ
More information about the Synth-diy
mailing list