fixed wrapped read of samples from end of buffer