Deref the riff ref once only to avoid the (slim) possibility that the final duration and the loop are calculated based on different states of riff.