cc-tweaked / cc-restitched

Other
80 stars 33 forks source link

Multiple speakers not playing in sync #84

Open Shroototem opened 2 years ago

Shroototem commented 2 years ago

Same issue as: #4

image

local speakers = table.pack(peripheral.find("speaker"))
local decoder = require("cc.audio.dfpwm").make_decoder()
local fn = {}
for chunk in io.lines("/disk/music/bo.dfpwm", 16 * 1024) do
    local buffer = decoder(chunk)
    for i, v in ipairs(speakers) do
        fn[i] = function()
            local name = peripheral.getName(v)
            while not v.playAudio(buffer) do
                repeat
                until select(2, os.pullEvent("speaker_audio_empty")) == name
            end
        end
    end
    parallel.waitForAll(table.unpack(fn))
end
MCJack123 commented 2 years ago

Here's a video reproduction:

https://user-images.githubusercontent.com/6236912/163661848-8cfc1d38-e2bb-4198-a2ba-d526bd31808f.mp4

Shroototem commented 2 years ago

CC: Tweaked Speaker: https://github.com/cc-tweaked/CC-Tweaked/blob/mc-1.16.x/src/main/java/dan200/computercraft/shared/peripheral/speaker/SpeakerPeripheral.java#:~:text=Push%20position%20updates%20to%20any%20speakers