You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
336 B
Lua
19 lines
336 B
Lua
local PCMGenerator = require('class')('PCMGenerator')
|
|
|
|
function PCMGenerator:__init(fn)
|
|
self._fn = fn
|
|
end
|
|
|
|
function PCMGenerator:read(n)
|
|
local pcm = {}
|
|
local fn = self._fn
|
|
for i = 1, n, 2 do
|
|
local left, right = fn()
|
|
pcm[i] = tonumber(left) or 0
|
|
pcm[i + 1] = tonumber(right) or pcm[i]
|
|
end
|
|
return pcm
|
|
end
|
|
|
|
return PCMGenerator
|