This commit is contained in:
2025-06-16 20:27:40 -04:00
parent e4a91a47a6
commit c76e8c9677

View File

@@ -17,58 +17,30 @@ local function randomFileName()
return name
end
-- local function playSound(speaker, fileName)
-- local fileStream = getFileName(fileName)
-- local values = io.lines(fileStream, 16 * 1024)
-- for input in values do
-- print("playing audo....")
-- local decoded = decoder(input)
-- while not speaker.playAudio(decoded, 3) do
-- os.pullEvent("speaker_audio_empty")
-- end
-- end
-- end
local function playFullFile(speaker, fileName)
local decoder = require("cc.audio.dfpwm").make_decoder()
local file = fs.open(fileName, "rb")
if not file then
print("Failed to open file: " .. fileName)
return
end
while true do
local chunk = file.read(16 * 1024)
if not chunk then break end
local decoded = decoder(chunk)
local function playFullFile(fileName)
local fileStream = getFileName(fileName)
local values = io.lines(fileStream, 16 * 1024)
for input in values do
print("playing audo....")
local decoded = decoder(input)
while not speaker.playAudio(decoded, 3) do
os.pullEvent("speaker_audio_empty")
end
end
file.close()
end
local function playSound(placeholder,fileName)
local function playSound(speaker, fileName)
local speakers = table.pack(peripheral.find("speaker"))
local tasks = {}
for i = 1, speakers.n do
tasks[i] = function()
playFullFile(speakers[i], fileName)
end
end
parallel.waitForAll(table.unpack(tasks, 1, speakers.n))
end
local function playControlRoomAlarm(speakers)
playSound(speakers,"short_control_alarm")
end