updated
This commit is contained in:
@@ -31,8 +31,10 @@ end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
local function playSpeaker(speaker, data)
|
||||
while not speaker.playAudio(data, 3) do
|
||||
local function playSpeaker(speaker, input)
|
||||
local decoder = require("cc.audio.dfpwm").make_decoder()
|
||||
local decoded = decoder(input)
|
||||
while not speaker.playAudio(decoded, 3) do
|
||||
os.pullEvent("speaker_audio_empty")
|
||||
end
|
||||
end
|
||||
@@ -41,12 +43,13 @@ local function playSound(speakers, fileName)
|
||||
local fileStream = getFileName(fileName)
|
||||
local values = io.lines(fileStream, 16 * 1024)
|
||||
for input in values do
|
||||
print("playing audo....")
|
||||
local decoded = decoder(input)
|
||||
print("playing audio...")
|
||||
|
||||
local tasks = {}
|
||||
for _, speaker in ipairs(speakers) do
|
||||
table.insert(tasks, function()
|
||||
playSpeaker(speaker, decoded)
|
||||
-- each speaker needs its own decoder for the same input chunk
|
||||
playSpeaker(speaker, input)
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user