From f5877abafee43438f49a6e1a472139c1651210da Mon Sep 17 00:00:00 2001 From: LTVA1 <87536432+LTVA1@users.noreply.github.com> Date: Sat, 10 Aug 2024 23:45:12 +0300 Subject: [PATCH] add distortion to wave channel as well... --- src/engine/platform/sound/sid3.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/engine/platform/sound/sid3.c b/src/engine/platform/sound/sid3.c index 3ee185f2e..d7057553f 100644 --- a/src/engine/platform/sound/sid3.c +++ b/src/engine/platform/sound/sid3.c @@ -2978,6 +2978,19 @@ int32_t sid3_process_wave_channel_filters_block(sid3_wavetable_chan* ch) break; } + if(ch->filt.filt[i].distortion_level > 0) + { + if(Vo > 0.0) + { + Vo = (tanh((Vo / 39767.0) * ch->filt.filt[i].distortion_multiplier) / ch->filt.filt[i].tanh_distortion_multiplier) * 39767.0; + } + else + { + double ahh = (Vo / 39767.0) * ch->filt.filt[i].distortion_multiplier; + Vo = ((exp(ahh) - 1.0) / ch->filt.filt[i].tanh_distortion_multiplier) * 39767.0; + } + } + ch->filt.filt[i].output = Vo * ch->filt.filt[i].output_volume / 0xff; } else