Move wav detection code to a separate file.