CapsAdmin

Untitled

Mar 27th, 2012
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local data = file.Read("G:/space televator.wav", "b")
  2.  
  3. local function waveform()
  4.     local w = 0
  5.     local t = math.ceil(time*4*44000%#data)
  6.     local left = 0
  7.     local right = 0
  8.  
  9.     local size = 16
  10.  
  11.     for i=0, size do
  12.         local byte = data:getbyte(t+i)
  13.         if i%1 == 1 then
  14.             byte = -byte + 128
  15.         else
  16.             byte = byte - 128
  17.         end
  18.         if i < size/2 then
  19.             left = left + byte
  20.         else
  21.             right = right + byte
  22.         end
  23.     end
  24.  
  25.     left = left / 1024
  26.     right = right / 1024
  27.  
  28.     left = math.clamp(left, -1, 1)
  29.     right = math.clamp(right, -1, 1)
  30.  
  31.     return left, right
  32. end
Advertisement
Add Comment
Please, Sign In to add comment