Fixed to work with arbitrary output sample rates.