Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local clock = os.clock
- function sleep(n)
- local t0 = clock()
- while clock() - t0 <= n do end
- end
- print("please give audio name with .dfpwm")
- input = read()
- print("Do you want to be in repeat mode? Y/N")
- while x == True do
- inputYN = read()
- if inputYN == ("Y") then
- r = 1
- x = false
- elseif inputYN == ("N") then
- r = 0
- x = false
- else
- print("Please type Y or N")
- end
- end
- while reapeat == True do
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- local decoder = dfpwm.make_decoder()
- for chunk in io.lines(input, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
- sleep(15)
- if r == 0 then
- reapeat = false
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment