ac.go_to_seconds("sample4.wav", 0) ac.play_sound("sample4.wav") elif val == "W": ac.go_to_seconds("sample5.wav", 0) ac.play_sound("sample5.wav") last_dir = val ac = AudioController() print "Loading sounds..." ac.add_sound("bg01.wav") ac.add_sound("bg02.wav") ac.add_sound("sample2.wav") ac.add_sound("sample3.wav") ac.add_sound("sample4.wav") ac.add_sound("sample5.wav") ac.play_sound("bg01.wav", loops=-1) ac.play_sound("bg02.wav", loops=-1) ac.set_volume("bg02.wav",0.0) print("finished loading sounds.") print "Starting communications..." com = Broadcaster(port=port, host=host) com.on("windSpeedUpdate", updateSpeed) com.on("windDirectionUpdate", updateDirection) print "communications established." print "Enjoy..." com.wait_forever() print "Finished"
def updateSpeed(data): val = data["value"] sendWindSpeed(val) def updateDirection(data): global last_dir global ac val = data["value"] #print "windDirection: %s" % val if val != last_dir: sendWindDirection(val) last_dir = val print "Starting communications..." com = Broadcaster(port=8080, host="192.168.42.1") com.on("windSpeedUpdate", updateSpeed) com.on("windDirectionUpdate", updateDirection) print "communications established." print "Enjoy..." sendWindDirection("N") sendWindSpeed(200) com.wait_forever() print "Finished"