Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local dfpwm = require("cc.audio.dfpwm")
- local speaker = peripheral.find("speaker")
- -- Ask user for the base name (without extension)
- write("Enter the name of the song (without .dfpwm): ")
- local filename = read() .. ".dfpwm"
- -- Create the decoder
- local decoder = dfpwm.make_decoder()
- -- Stream and play the audio
- for chunk in io.lines(filename, 16 * 1024) do
- local buffer = decoder(chunk)
- while not speaker.playAudio(buffer) do
- os.pullEvent("speaker_audio_empty")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement