Take the duration to be the last end of a note, not the end of the last note. Fixes #6.
Simplify duration with reduce.