pouët.net

Go to bottom

How to get into synth / executable music?

category: music [glöplog]
switch(type)
{
case LowPass:
if (cutoff < 10.0f) { cutoff = 10.0f; }

c = 1.0f / tanf ( pi * cutoff / (float) Constants::Audio::SampleRate );

coef1.a1 = 1.0f / ( 1.0f + ( resonance * c ) + ( c * c ) );
coef1.a2 = 2.0f * coef1.a1;
coef1.b1 = 2.0f * ( 1.0f - ( c * c ) ) * coef1.a1;
coef1.b2 = ( 1.0f - ( resonance * c ) + ( c * c ) ) * coef1.a1;
break;
case HighPass:
if (cutoff > Constants::Audio::SampleRate / 2.0f) { cutoff = Constants::Audio::SampleRate / 2.0f; }

c = tanf ( pi * cutoff / ( float ) Constants::Audio::SampleRate );

coef1.a1 = 1.0f / ( 1.0f + resonance * c + c * c );
coef1.a2 = -2.0f * coef1.a1;
coef1.b1 = 2.0f * ( c * c - 1.0f ) * coef1.a1;
coef1.b2 = ( 1.0f - resonance * c + c * c ) * coef1.a1;
break;
}

And then..

output1 = ( coef1.a1 * input ) + ( coef1.a2 * in1 ) + ( coef1.a1 * in2 );
output1 -= ( coef1.b1 * out1 ) + ( coef1.b2 * out2 );

// Denormalise
output1 = undenormalize(output1);

if (changed) {
output2 = ( coef2.a1 * input ) + ( coef2.a2 * in1 ) + ( coef2.a3 * in2 );
output2 -= ( coef2.b1 * out1 ) + ( coef2.b2 * out2 );
output1 += (output2 - output1) * ((float) Constants::Audio::StepSize - s) * (1.0f / (float) Constants::Audio::StepSize);
}

// Write output
data[s] = output1;

// Write context
out2 = out1;
out1 = output1;

in2 = in1;
in1 = input;
added on the 2010-11-05 22:31:46 by MeteoriK MeteoriK
Your topology is a direct-form I biquad with the input coefficient normalized to 1.
added on the 2010-11-05 22:36:31 by trc_wm trc_wm
it works! the zero bug was a dumb casting error.

And yes.. well spotted.. you get the "I know my filters" trophy :-)
added on the 2010-11-05 22:47:31 by MeteoriK MeteoriK
b1 = -2 and b2 = 1 when c = infinity (cutoff = 0), if I did my math correctly.
Then, both the poles of the filter are _on_ the unit circle at z=1 and form two perfect integrators. These have _very_ high gain at frequencies close to 0 Hz. Round-off noise will accumulate causing a ramp (?) at the output.

My guess is that you're not clipping the audio to the soundcard and your float->short conversion will continuously overflow, causing a full-scale saw to appear.. *ouch* :)

Am I getting close?
added on the 2010-11-05 22:59:43 by trc_wm trc_wm
Can I have my "I know my z-transforms" trophy too? :)
added on the 2010-11-05 23:01:01 by trc_wm trc_wm
I'll have to make one.. here.. I've got a cigarette lighter stuffed into a potato.

It's yours.
added on the 2010-11-05 23:05:42 by MeteoriK MeteoriK
A few notes:

1. If you can live with slightly higher noise when you change the filter coefficients (ie. a filter sweep), Direct Form 2 will save you some CPU time.
2. If you use SSE math, setting the FP flags that flush denormals to zero will be a lot faster than any undenormalise routine you can write yourself.
added on the 2010-11-05 23:08:58 by Sesse Sesse
I avoid denormals for lowpass filters by adding 1e-20 to the input.
For highpass filters, you can do the same trick, but you should change the sign of 1e-20 every sample.

I prefer to make resonant filters using cascaded integrators. They have good noise properties and the coefficients are generally easier to calculate (and interpolate) than those of biquads.

added on the 2010-11-05 23:20:24 by trc_wm trc_wm
@Sesse the cpu problems were down to memory lookups on the wavetables (even though I got them small enough to fit the cache), so I'm going to leave it alone for now, but thanks for the advice.

added on the 2010-11-05 23:20:27 by MeteoriK MeteoriK
@trc_wm: excuse my ignorance.. you're obviously a synth coder.. point me at a demo with your synth in it! I want to listen!

@Sesse: see above :-)
added on the 2010-11-05 23:44:54 by MeteoriK MeteoriK
Buy a Waldorf Microwave II, XT, or XTk :)

or download this: http://www.scene.org/file.php?file=/parties/2006/breakpoint06/executable_music/newschool/can_i_have_my_pills_now_trc_mw.zip&fileinfo

Only synth related demoscene prod I did; I wrote the "music" in one day.
It's VA with lots of karplus strong stuff and 1 voice sample.
added on the 2010-11-06 00:00:25 by trc_wm trc_wm
FFFFFUUUUUUU
added on the 2010-11-06 00:01:28 by trc_wm trc_wm
added on the 2010-11-06 00:02:04 by trc_wm trc_wm
MeteoriK: There's been exactly one intro released with “my” synth in it, namely Nemesis from TG04. (I say “my” because most of the credit should go towards titanstar.) There's been quite a lot of bugfixing (taking a degree with DSP in it in the meantime surely helped) and some new features since that release, but I believe I've complained enough about musicians not being interested already :-)
added on the 2010-11-06 00:05:19 by Sesse Sesse
One day I'll understand why "FFFFFUUUUUUUUUUUUUUU" makes me lol.

I can't explain it and I'm the one who tried to make the whole of breakpoint laugh at the sundown quiz. At least there was logic to my humour.

Stephen Wright is a master of, er, taking drugs and then saying what he thinks :-)
added on the 2010-11-06 00:08:36 by MeteoriK MeteoriK
BB Image
added on the 2010-11-06 00:14:09 by trc_wm trc_wm
@Sesse: nice! I reckon pouet should set up a separate forum so that rabid eczema hairy bastards like maali can't accidentally click on a link about synth programming and post pictures of attractive babies he wishes he looked like in his dirty long-haired childhood.

I'm guessing from the samples that the drums were samples? I'm not giving up on my white whale - the fucking snare drum.. if I can't do it this time, then it's a 1k BRR compressed sample.
added on the 2010-11-06 00:16:10 by MeteoriK MeteoriK
MeteoriK: No, the drums are synthesized, save for the little shaker which is indeed a sample (compressed with the same LPC-based system as the sampled George W. Bush in the beginning).
added on the 2010-11-06 00:20:23 by Sesse Sesse
basically, maali's parents had a problem.. dummy in one hand.. maalii in the other..

which is which? they both look like rubber.
added on the 2010-11-06 00:21:02 by MeteoriK MeteoriK
Sesse: well your drums are better than mine! lets fight! (in a cooperatively competitive and mostly loving hell lets get gay and have a hug way)
added on the 2010-11-06 00:24:20 by MeteoriK MeteoriK
Can't run Nemesis on my Intel MAC :(
added on the 2010-11-06 00:24:45 by trc_wm trc_wm
trc_wm: get a computer!
added on the 2010-11-06 00:26:32 by MeteoriK MeteoriK
I can't, I'm gay.
added on the 2010-11-06 00:27:03 by trc_wm trc_wm

login

Go to top