code: public int updatePosition(int p, boolean keyOff)
  	{
  		p++;
  		if (loop && p>=position[loopEndPoint]) p=position[loopStartPoint];
  		if (sustain && p>=position[sustainEndPoint] && !keyOff) p=position[sustainStartPoint];
  		return p;
  	}
docs: Get the new position
  @since 19.06.2006
  @param p
  @param keyOff
  @return