This commit is contained in:
2025-06-16 20:40:57 -04:00
parent 8f64d54c00
commit 65934b61ce
2 changed files with 9 additions and 45 deletions

View File

@@ -17,40 +17,18 @@ local function randomFileName()
return name
end
local function playSingleSound(speaker, values)
local decoded = decoder(values)
speaker.playAudio(decoded, 3)
end
local function playSound(speaker, fileName)
local fileStream = fs.open(getFileName(fileName), "r")
local data = fileStream.readAll()
local speakers = table.pack(peripheral.find("speaker"))
local tasks = {}
for i = 1, speakers.n do
tasks[i] = function()
playSingleSound(speakers[i], data)
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
parallel.waitForAll(table.unpack(tasks, 1, speakers.n))
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 playControlRoomAlarm(speakers)
playSound(speakers,"short_control_alarm")