Hi, I have a question about sound after a long time. I have a simple script for getting amplitudes from a wav file, which returns values between 0 and 65535 (approximately), but should return values ranging from -32768 to 32767. Don’t know how to modify the script correctly?
Thank you for every answer.
f = assert(io.open("C:\\Users\\karel\\downloads\\a.wav", "rb"))
f:seek("cur", 44)
count = 0
while true do
bytes = f:read(1)
if not bytes then print(count) break end
b = string.byte(bytes, 1, -1)
b = string.format("%02x", b)
bytes = f:read(1)
b1 = string.byte(bytes, 1, -1)
b1 = string.format("%02x ", b1)
x = b .. b1
x = tonumber(x, 16)
print(x)
f:seek("cur", 2)
count = count + 1
end