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