Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- local protocol = "red-fm"
- term.clear()
- term.setCursorPos(1,1)
- peripheral.find("modem", rednet.open)
- print(protocol.." > Synchronisé")
- term.setCursorPos(1,2)
- print("Maintenez CTRL + T pour arrêter la radio")
- while true do
- local id, message = rednet.receive(protocol)
- local file = fs.open("red-fm.dfpwm", "wb")
- file.write(message)
- file.flush()
- file.close()
- local decoder = dfpwm.make_decoder()
- for chunk in io.lines("red-fm.dfpwm", 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- end
Add Comment
Please, Sign In to add comment