[LAU] Fw: Connie, an organ template for JACK
Martin Homuth-Rosemann
linuxaudio at cryptomys.de
Sun Aug 1 10:48:21 UTC 2010
Beginn der weitergeleiteten Nachricht:
Datum: Sun, 1 Aug 2010 12:40:14 +0200
Von: Martin Homuth-Rosemann <linuxaudio at cryptomys.de>
An: James Morris <james at jwm-art.net>
Betreff: Re: [LAU] Connie, an organ template for JACK
Am Sat, 31 Jul 2010 23:41:52 +0100
schrieb James Morris <james at jwm-art.net>:
> ...
> Same problem as Foo YC 20, a lack of volume envelope. The clicks
> resulting from sudden jumps in sample amplitude make it unusable for
> me.
>
> Cheers,
> James.
Hi James,
I do apply a simple envelope to the keys to reduce the awful clicking -
it's done in connie_main.c in rt_process_cb(), starting at line 370:
--- 8< ---
// process the keys (attac/decay/release), do stop mixture
if ( ++timer > tg_sample_rate / 4000 ) { // 4 kHz -> every 250us
timer = 0;
int *p_vol = tg_vol_key + LOWNOTE; // tg_vol_key[note]
int *p_raw = midi_vol_raw + LOWNOTE;
// ramp the midi volumes up/down to remove the clicking at key
press/release
for ( int note = LOWNOTE; note < HIGHNOTE; note++,
p_vol++, p_raw++ ) { if ( *p_vol < *p_raw ) {
if ( tg_percussion ) // attack immediately up to 0..256
(*p_vol) = 256 * tg_percussion; // then decay to 64 (0..48
ms)
else
(*p_vol) += 8; // attack quick up (2 ms)
} else if ( *p_vol > *p_raw ) {
(*p_vol)--; // decay/release slow down (16 ms)
}
} // for ( note )
...
--- 8< ---
If you change the line 382
(*p_vol) += 8; // attack quick up (2 ms)
to
(*p_vol) ++; // attack slow up (16 ms)
you'll get a slower attac.
But a soft click will be leftover because your envelope is a ramp (i.e.
non bandlimited frequency range and aliasing...) and it's only integer
range 0..64. I chose the quick up / slow down because if you press a key
the starting sound will "mask" the click and you'll get a more direct
feeling - no delay between key action and playing sound. It decays more
slowly because there is no "masking" (silence). Feel free to
improve this part to your needs.
If it's still unusable for you it willbe possible to use a more complex
envelope (e.g. bandlimited step) or shorter time steps - but this will
cost more cpu because at the moment the keys were calculated every
250µs only (-> sample rate 4KHz) to reduce cpu load.
Ciao Martin
More information about the Linux-audio-user
mailing list