updated
This commit is contained in:
@@ -30,7 +30,6 @@ end
|
|||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
local function playSpeaker(speaker, input)
|
local function playSpeaker(speaker, input)
|
||||||
local decoder = require("cc.audio.dfpwm").make_decoder()
|
local decoder = require("cc.audio.dfpwm").make_decoder()
|
||||||
local decoded = decoder(input)
|
local decoded = decoder(input)
|
||||||
@@ -42,17 +41,19 @@ end
|
|||||||
local function playSound(speakers, fileName)
|
local function playSound(speakers, fileName)
|
||||||
local fileStream = getFileName(fileName)
|
local fileStream = getFileName(fileName)
|
||||||
local values = io.lines(fileStream, 16 * 1024)
|
local values = io.lines(fileStream, 16 * 1024)
|
||||||
|
|
||||||
for input in values do
|
for input in values do
|
||||||
print("playing audio...")
|
print("playing audio...")
|
||||||
|
|
||||||
|
-- Create parallel tasks, each with its own decoder instance
|
||||||
local tasks = {}
|
local tasks = {}
|
||||||
for _, speaker in ipairs(speakers) do
|
for _, speaker in ipairs(speakers) do
|
||||||
table.insert(tasks, function()
|
table.insert(tasks, function()
|
||||||
-- each speaker needs its own decoder for the same input chunk
|
|
||||||
playSpeaker(speaker, input)
|
playSpeaker(speaker, input)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Execute all in parallel
|
||||||
parallel.waitForAll(table.unpack(tasks))
|
parallel.waitForAll(table.unpack(tasks))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user