HertzDevil icon

DPCM mixer

HertzDevil | PRO | 06/11/15 09:16:39 AM UTC | 0 ⭐ | 481 👁️ | Never ⏰ | []
Lua |

1.26 KB

|

None

|

0 👍

/

0 👎

local loop = false
 
function bit(x, d)
  return (x >> d) & 1
end
 
if #arg < 2 then print("Usage: lua dpcm.lua [sample1] [sample2] [output]") os.exit() end
input = {io.open(arg[1], "rb"), io.open(arg[2], "rb")}
if not input[1] then print(arg[1] .. " not found") os.exit() end
if not input[2] then print(arg[2] .. " not found") os.exit() end
output = io.open(arg[3] or "out.dmc", "wb")
if input[1]:seek("end") < input[2]:seek("end") then input[1], input[2] = input[2], input[1] end
input[1]:seek("set", 0)
input[2]:seek("set", 0)
 
local alt = false
while true do
  local a = input[1]:read(1)
  if not a then break end
  a = string.byte(a)
 
  local b = input[2]:read(1)
  if b then
    b = string.byte(b)
  elseif loop then
    input[2]:seek("set", 0)
    b = string.byte(input[2]:read(1))
  else
    b = 0xAA
  end
  
  local out = 0
  if avg then
    for i = 0, 7 do
      local delta = (bit(a, i) + bit(b, i) - 1) / 2
      
    end
  else
    for i = 0, 6, 2 do
      local delta = bit(a, i) + bit(a, i + 1) + bit(b, i) + bit(b, i + 1) - 2
      if delta >= 0 then out = out + (1 << i) end
      if delta > 0 then out = out + (1 << i + 1) end
    end
  end
  output:write(string.char(out))
end
 
input[1]:close()
input[2]:close()
output:close()

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  • Syizuxtrn icon
    05/15/26 01:37:24 PM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    Best Pastebin.com alternatives paste sites list
     Copy and paste the link in a new browser tab and then hit enter!
     https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400