Fix sample index calculation in addSample.

Two terms were reversed. The calculation in addSample now matches thati in addSamples (plural).