The role of musical analogies in Newton's optical and cosmological work