Added some more documentation, cleaned up code and added comments. Made device index and sampling rate arguments which can be adjusted
Fixed all