Handle sound card saturation

This commit is contained in:
zenith391 2021-09-19 21:24:58 +02:00
parent 2f63a37476
commit b0fabfd026

View File

@ -189,7 +189,7 @@ function obj.setFrequency(channel, frequency)
channels[channel].frequency = frequency channels[channel].frequency = frequency
end end
local firstProc = false local firstProc = true
table.insert(machineTickHandlers, function(dt) table.insert(machineTickHandlers, function(dt)
if processEnd ~= 0 then if processEnd ~= 0 then
local timeMs = elsa.timer.getTime() * 1000 local timeMs = elsa.timer.getTime() * 1000
@ -227,6 +227,8 @@ table.insert(machineTickHandlers, function(dt)
end end
end end
end end
if value > 32000 then value = 32000 end
if value < -32000 then value = -32000 end
data[i-1] = value data[i-1] = value
time = time + (1 / rate) time = time + (1 / rate)
end end