From b0fabfd0266327c4a01dbb132b07fc3ce4a9c1ed Mon Sep 17 00:00:00 2001 From: zenith391 <39484230+zenith391@users.noreply.github.com> Date: Sun, 19 Sep 2021 21:24:58 +0200 Subject: [PATCH] Handle sound card saturation --- src/component/sound_card.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/component/sound_card.lua b/src/component/sound_card.lua index e8c22ec..b8aaf59 100644 --- a/src/component/sound_card.lua +++ b/src/component/sound_card.lua @@ -189,7 +189,7 @@ function obj.setFrequency(channel, frequency) channels[channel].frequency = frequency end -local firstProc = false +local firstProc = true table.insert(machineTickHandlers, function(dt) if processEnd ~= 0 then local timeMs = elsa.timer.getTime() * 1000 @@ -227,6 +227,8 @@ table.insert(machineTickHandlers, function(dt) end end end + if value > 32000 then value = 32000 end + if value < -32000 then value = -32000 end data[i-1] = value time = time + (1 / rate) end