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;
{
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;
Your topology is a direct-form I biquad with the input coefficient normalized to 1.
it works! the zero bug was a dumb casting error.
And yes.. well spotted.. you get the "I know my filters" trophy :-)
And yes.. well spotted.. you get the "I know my filters" trophy :-)
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?
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?
Can I have my "I know my z-transforms" trophy too? :)
I'll have to make one.. here.. I've got a cigarette lighter stuffed into a potato.
It's yours.
It's yours.
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.
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.
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.
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.
@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.
@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 :-)
@Sesse: see above :-)
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.
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.
FFFFFUUUUUUU
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 :-)
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 :-)
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 :-)
@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.
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.
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).
basically, maali's parents had a problem.. dummy in one hand.. maalii in the other..
which is which? they both look like rubber.
which is which? they both look like rubber.
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)
Can't run Nemesis on my Intel MAC :(
trc_wm: get a computer!
I can't, I'm gay.