"""
            Mainloop which tries to analyze new audio data if there is new audio,
            then it very briefly polls the node.js server to see if there is 
            new data. If new data, it should be parsed into mode form and 
            the dance platform updater should be notified.
            """

            analyzeAudio()
            data = server.listen(0.001)

            if data:
                data = parser.parseServerData(data)
                if data == False:
                    # if returns False, kill was called from server
                    # otherwise data should be updated appropriately
                    platform.turnOffLEDs("all")
                    break
                mode = data
                platform.updateMode(mode)

        except:
            print traceback.format_exc()
            platform.turnOffLEDs("all")
            SR.continuousEnd()
            SR.close()
            server.disconnectSocket()
            nodeServer.kill()
            sys.exit("Killing App")

    # Kill threads, kills node server, cleanup, exit program
    SR.continuousEnd()