[LAU] Sequencer suggestions?

Fons Adriaensen fons at linuxaudio.org
Tue Aug 26 16:06:30 UTC 2014


On Tue, Aug 26, 2014 at 05:20:24PM +0200, Philipp Überbacher wrote:

> Thanks Fons, much appreciated. It seems the original author didn't
> touch the code in more than 1 1/2 years, so the bug report would likely
> had no effect.


The following patches seem to fix the problem. They remove the 
(inoperative) per patch DC blocker and add one per voice, just
after the oscillators. More testing may be required.


--- engine.h.orig   2013-01-13 08:18:49.000000000 +0100
+++ engine.h    2014-08-26 17:18:13.514909324 +0200
@@ -84,9 +84,7 @@
    sample_t    bps;                        /* beats per second */
    sample_t    out1;                       /* output sample 2 */
    sample_t    out2;                       /* output sample 1 */
-#ifdef ENABLE_DC_REJECTION_FILTER
-   sample_t    dcR_const;
-#endif
+   sample_t    wdcf;
 } GLOBAL;
 
 
@@ -105,6 +103,8 @@
    int         portamento_sample;          /* sample number within portamento */
    int         portamento_samples;         /* portamento time in samples */
    int         age;                        /* voice age, in samples */
+        sample_t    dcf1;                       /* DC filter state 1 */
+        sample_t    dcf2;                       /* DC filter state 2 */
    sample_t    out1;                       /* output sample 1 */
    sample_t    out2;                       /* output sample 2 */
    sample_t    amp_env;                    /* smoothed final output of env generator */





--- engine.c.orig   2013-01-13 08:18:49.000000000 +0100
+++ engine.c    2014-08-26 17:54:29.301481175 +0200
@@ -193,9 +193,7 @@
 
    /* (-3dB @ 20Hz) DC blocking filter */
    /* 1.0 - (M_PI * 2 * freq / (sample_t) f_sample_rate) */
-#ifdef ENABLE_DC_REJECTION_FILTER
-   global.dcR_const = 1.0 - (125.6 / (sample_t) f_sample_rate);
-#endif
+   global.wdcf = 125.7 / (sample_t) f_sample_rate;
 }
 
 
@@ -487,6 +485,10 @@
            voice->midi_key   = -1;
            voice->keypressed = -1;
 
+           /* init dc filters */
+           voice->dcf1 = 0.0;
+           voice->dcf2 = 0.0;
+
            /* initialize moog filters */
            voice->filter_y1_1    = 0.0;
            voice->filter_y1_2    = 0.0;
@@ -780,10 +782,6 @@
 run_part(PART *part, PATCH_STATE *state, unsigned int part_num)
 {
    unsigned int    osc;
-#ifdef ENABLE_DC_REJECTION_FILTER
-   sample_t        tmp1;
-   sample_t        tmp2;
-#endif
 
    /* generate amplitude envelopes for all voices */
    run_voice_envelopes(part, state, part_num);
@@ -842,19 +840,6 @@
    if (state->delay_mix_cc) {
        run_delay(get_delay(part_num), part, state);
    }
-
-   /* output this sample to the buffer */
-#ifdef ENABLE_DC_REJECTION_FILTER
-   tmp1 = part->out1;
-   part->out1 = part->out1 - part->dcR_in1 + global.dcR_const * part->dcR_out1;
-   part->dcR_in1  = tmp1;
-   part->dcR_out1 = part->out1;
-
-   tmp2 = part->out2;
-   part->out2 = part->out2 - part->dcR_in2 + global.dcR_const * part->dcR_out2;
-   part->dcR_in2  = tmp2;
-   part->dcR_out2 = part->out2;
-#endif
 }
 
 
@@ -1300,6 +1285,12 @@
        run_osc(voice, part, state, osc);
    }
 
+   /* apply DC filters */
+   voice->dcf1 += global.wdcf * (voice->out1 - voice->dcf1);
+   voice->out1 -= voice->dcf1;
+   voice->dcf2 += global.wdcf * (voice->out2 - voice->dcf2);
+   voice->out2 -= voice->dcf2;
+
    /* oscs are mixed.  now apply AM oscs. */
    for (osc = 0; osc < NUM_OSCS; osc++) {
        if (state->osc_modulation[osc] == MOD_TYPE_AM) {



-- 
FA

A world of exhaustive, reliable metadata would be an utopia.
It's also a pipe-dream, founded on self-delusion, nerd hubris
and hysterically inflated market opportunities. (Cory Doctorow)



More information about the Linux-audio-user mailing list