Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local sound = component.sound
- -- Reset Sound Card to known state
- sound.clear() -- clear out buffers
- sound.setTotalVolume(1) -- set overall volume to max
- for i = 1,8 do
- sound.resetEnvelope(i) -- remove any ADSRs
- sound.resetAM(i) -- remove any AM modulation
- sound.resetFM(i) -- remove any FM modulation
- sound.setVolume(i,1) -- set channel volume to max
- sound.close(i) -- close channels (stop emitting audio)
- end
- -- process commands
- while not sound.process() do
- os.sleep(0.05)
- end
- -- next statements add commands to the buffer
- sound.setWave(1, sound.modes.square) -- set channel 1 to square wave
- sound.setFrequency(1, 500) -- set channel 1 to 500Hz
- sound.open(1) -- open channel 1 (allow to emit audio)
- sound.delay(500) -- wait 500ms
- sound.close(1) -- close channel 1 (stop emitting audio)
- -- process commands
- while not sound.process() do
- os.sleep(0.05)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement