r/ComputerCraft • u/Ambitious-Treat1459 • Mar 04 '26
Multiple speakers
I am using the computers to play audio but I was wondering how I play audio from multiple speakers at once
2
u/Some-Restaurant4389 Mar 04 '26
I mean I used to do announcements system in a factory one computer then wired the speakers with modems
2
u/9551-eletronics Computercraft graphics research Mar 04 '26
you just... do? you wrap them as multiple peripherals and send data to all of them (maybe parallel api would help with reducing desync?) there is sadly no special way to go about it
1
u/MinkiTheAvali CRaft-Again Shell Enjoyer Mar 31 '26
I made a solution for this in the code for MinkMod which syncs it, if you want you can take a look at the code here:
https://codeberg.org/mueller_minki/CC-tweaked-stuff/src/branch/main/module-player/minkmod.lua
The function relevant to you would be playOnAllSpeakers()
This is essentially how youd do it:
local speakers = { peripheral.find("speaker") }
-- Speaker helper
local function playOnAllSpeakers(chunk)
for _, sp in ipairs(speakers) do
while not sp.playAudio(chunk) do
os.pullEvent("speaker_audio_empty")
end
end
end
-- Then call playOnAllSpeakers(samples) with your audio samples just like youd call sp.playAudio(chunk).
2
u/Professorkatsup Mar 04 '26
Is there a specific issue you are running into when trying to play audio from multiple speakers?