X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fplugins%2Freasonablesynth.lv2%2Frsynth.c;h=68bd81714db997ad7d1007aa08a8e479a47f7f79;hb=36135baaacb8249f5a812aab6b547557c6c37f73;hp=a6c74aa26c1e2057e62582053dc1e0f2415394b2;hpb=a1a3f6c8265264227ce19f731bf1863aff229a94;p=ardour.git diff --git a/libs/plugins/reasonablesynth.lv2/rsynth.c b/libs/plugins/reasonablesynth.lv2/rsynth.c index a6c74aa26c..68bd81714d 100644 --- a/libs/plugins/reasonablesynth.lv2/rsynth.c +++ b/libs/plugins/reasonablesynth.lv2/rsynth.c @@ -186,22 +186,25 @@ static void synthesize_sineP (RSSynthChannel* sc, 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); + 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; @@ -221,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; @@ -399,8 +402,9 @@ static uint32_t synth_sound (void *synth, uint32_t written, const uint32_t nfram uint32_t nremain = nframes - written; if (rs->boffset >= BUFFER_SIZE_SAMPLES) { - rs->boffset = 0; - synth_fragment(rs, BUFFER_SIZE_SAMPLES, rs->buf[0], rs->buf[1]); + const uint32_t tosynth = MIN(BUFFER_SIZE_SAMPLES, nremain); + rs->boffset = BUFFER_SIZE_SAMPLES - tosynth; + synth_fragment(rs, tosynth, &(rs->buf[0][rs->boffset]), &(rs->buf[1][rs->boffset])); } uint32_t nread = MIN(nremain, (BUFFER_SIZE_SAMPLES - rs->boffset));