From 114997b7e65c4c4fdab7870d6bac411752f6875a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 20 Jan 2014 21:42:47 +0100 Subject: tweak reasonable synth: * prevent denormals / cut low volume * reduce default amplitude of fundamental --- libs/plugins/reasonablesynth.lv2/rsynth.c | 37 +++++++++++++++++-------------- 1 file changed, 20 insertions(+), 17 deletions(-) (limited to 'libs/plugins/reasonablesynth.lv2') diff --git a/libs/plugins/reasonablesynth.lv2/rsynth.c b/libs/plugins/reasonablesynth.lv2/rsynth.c index a6c74aa26c..3f3db579b8 100644 --- a/libs/plugins/reasonablesynth.lv2/rsynth.c +++ b/libs/plugins/reasonablesynth.lv2/rsynth.c @@ -185,23 +185,26 @@ static void synthesize_sineP (RSSynthChannel* sc, for (i=0; i < n_samples; ++i) { float env = adsr_env(sc, note); if (sc->adsr_cnt[note] == 0) break; - const float amp = vol * env; - - left[i] += amp * sinf(2.0 * M_PI * phase); - left[i] += .300 * amp * sinf(2.0 * M_PI * phase * 2.0); - left[i] += .150 * amp * sinf(2.0 * M_PI * phase * 3.0); - left[i] += .080 * amp * sinf(2.0 * M_PI * phase * 4.0); - //left[i] -= .007 * amp * sinf(2.0 * M_PI * phase * 5.0); - //left[i] += .010 * amp * sinf(2.0 * M_PI * phase * 6.0); - left[i] += .020 * amp * sinf(2.0 * M_PI * phase * 7.0); - phase += fq; - right[i] += amp * sinf(2.0 * M_PI * phase); - right[i] += .300 * amp * sinf(2.0 * M_PI * phase * 2.0); - right[i] += .150 * amp * sinf(2.0 * M_PI * phase * 3.0); - right[i] -= .080 * amp * sinf(2.0 * M_PI * phase * 4.0); - //right[i] += .007 * amp * sinf(2.0 * M_PI * phase * 5.0); - //right[i] += .010 * amp * sinf(2.0 * M_PI * phase * 6.0); - right[i] -= .020 * amp * sinf(2.0 * M_PI * phase * 7.0); + const float amp = vol * env * .6; + if (amp > 1e-10) { + left[i] += amp * sinf(2.0 * M_PI * phase); + left[i] += .300 * amp * sinf(2.0 * M_PI * phase * 2.0); + left[i] += .150 * amp * sinf(2.0 * M_PI * phase * 3.0); + left[i] += .080 * amp * sinf(2.0 * M_PI * phase * 4.0); + //left[i] -= .007 * amp * sinf(2.0 * M_PI * phase * 5.0); + //left[i] += .010 * amp * sinf(2.0 * M_PI * phase * 6.0); + left[i] += .020 * amp * sinf(2.0 * M_PI * phase * 7.0); + phase += fq; + right[i] += amp * sinf(2.0 * M_PI * phase); + right[i] += .300 * amp * sinf(2.0 * M_PI * phase * 2.0); + right[i] += .150 * amp * sinf(2.0 * M_PI * phase * 3.0); + right[i] -= .080 * amp * sinf(2.0 * M_PI * phase * 4.0); + //right[i] += .007 * amp * sinf(2.0 * M_PI * phase * 5.0); + //right[i] += .010 * amp * sinf(2.0 * M_PI * phase * 6.0); + right[i] -= .020 * amp * sinf(2.0 * M_PI * phase * 7.0); + } else { + phase += fq; + } if (phase > 1.0) phase -= 2.0; } sc->phase[note] = phase; -- cgit v1.2.3 From fb8af167784e7e2a016bc16e195ffb902c4c48e2 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 22 Jan 2014 18:10:44 +0100 Subject: attenuate master volume --- libs/plugins/reasonablesynth.lv2/rsynth.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libs/plugins/reasonablesynth.lv2') diff --git a/libs/plugins/reasonablesynth.lv2/rsynth.c b/libs/plugins/reasonablesynth.lv2/rsynth.c index 3f3db579b8..eff01d8d69 100644 --- a/libs/plugins/reasonablesynth.lv2/rsynth.c +++ b/libs/plugins/reasonablesynth.lv2/rsynth.c @@ -185,7 +185,7 @@ static void synthesize_sineP (RSSynthChannel* sc, for (i=0; i < n_samples; ++i) { float env = adsr_env(sc, note); if (sc->adsr_cnt[note] == 0) break; - const float amp = vol * env * .6; + const float amp = vol * env; if (amp > 1e-10) { left[i] += amp * sinf(2.0 * M_PI * phase); left[i] += .300 * amp * sinf(2.0 * M_PI * phase * 2.0); @@ -224,7 +224,7 @@ static void process_key (void *synth, RSSynthChannel* sc = &rs->sc[chn]; const int8_t vel = sc->miditable[note]; const int8_t msg = sc->midimsgs[note]; - const float vol = /* master_volume */ 0.25 * fabsf(vel) / 127.0; + const float vol = /* master_volume */ 0.1 * fabsf(vel) / 127.0; const float phase = sc->phase[note]; sc->midimsgs[note] = 0; -- cgit v1.2.3