public void startIteration() {
        // has timestep been changed?
        if (sim.getTimeStep() != savedTimeStep) {
            setParams();
        }
        v = Math.sin(freqTime) * maxV;
        freqTime += frequency * 2 * pi * sim.getTimeStep();
        frequency = frequency * fmul + fadd;
        if (frequency >= maxF && dir == 1) {
            if ((flags & FLAG_BIDIR) != 0) {
                fadd = -fadd;
                fmul = 1 / fmul;
                dir = -1;
            } else {
                frequency = minF;
            }
        }
        if (frequency <= minF && dir == -1) {
            fadd = -fadd;
            fmul = 1 / fmul;
            dir = 1;
        }
    }