added pitch detector and split out some js