Add current speed to samplepos and
fit currentSamplePos into loop values
or signal Sample finished
@since 18.06.2006
@param aktMemo
773181
protected void fitIntoLoops(final ChannelMemory actMemo)
	{
		final Sample ins = actMemo.currentSample;
		
		// If Forward direction:
		if (actMemo.currentDirection>=0)
		{
			actMemo.currentTuningPos += actMemo.currentTuning;
			if (actMemo.currentTuningPos >= Helpers.SHIFT_ONE)
			{
				actMemo.currentSamplePos += (actMemo.currentTuningPos >> Helpers.SHIFT);
				actMemo.currentTuningPos &= Helpers.SHIFT_MASK;
				if ((ins.loopType & Helpers.LOOP_ON)==0) // NoLoop
				{
					actMemo.instrumentFinished = actMemo.currentSamplePos>=ins.length;
				}
				else // loop is On
				{
					if ((ins.loopType & Helpers.LOOP_IS_PINGPONG)==0) // No Ping Pong
					{
						if (actMemo.currentSamplePos >= ins.repeatStop)
							actMemo.currentSamplePos = ins.repeatStart + ((actMemo.currentSamplePos-ins.repeatStart)%ins.repeatLength);
					}
					else // is PingPong
					{
						if (actMemo.currentSamplePos >= ins.repeatStop)
						{
							actMemo.currentDirection = -1;
							actMemo.currentSamplePos = ins.repeatStop - ((actMemo.currentSamplePos-ins.repeatStart)%ins.repeatLength) - 1;
						}
					}
				}
			}
		}
		else // Loop is on and we have ping pong!
		{
			actMemo.currentTuningPos -= actMemo.currentTuning;
			if (actMemo.currentTuningPos <= 0)
			{
				int hi = ((-actMemo.currentTuningPos) >> Helpers.SHIFT) + 1;
				actMemo.currentSamplePos -= hi;
				actMemo.currentTuningPos += hi<<Helpers.SHIFT;
				if (actMemo.currentSamplePos <= ins.repeatStart)
				{
					actMemo.currentDirection = 1;
					actMemo.currentSamplePos = ins.repeatStart + ((ins.repeatStart-actMemo.currentSamplePos)%ins.repeatLength);
				}
			}
		}
	}
201359
def _sample(self, position, trajectory_length, stepsize, lsteps=None):
        
        # Resampling momentum
        momentum = np.reshape(np.random.normal(0, 1, len(position)), position.shape)

        # position_m here will be the previous sampled value of position
        position_bar, momentum_bar = position.copy(), momentum

        # Number of steps L to simulate dynamics
        if lsteps is None:
            lsteps = int(max(1, round(trajectory_length / stepsize, 0)))

        grad_bar, _ = self.grad_log_pdf(position_bar, self.model).get_gradient_log_pdf()

        for _ in range(lsteps):
            position_bar, momentum_bar, grad_bar =\
                self.simulate_dynamics(self.model, position_bar, momentum_bar,
                                       stepsize, self.grad_log_pdf, grad_bar).get_proposed_values()

        acceptance_prob = self._acceptance_prob(position, position_bar, momentum, momentum_bar)

        # Metropolis acceptance probability
        alpha = min(1, acceptance_prob)

        # Accept or reject the new proposed value of position, i.e position_bar
        if np.random.rand() < alpha:
            position = position_bar.copy()
            self.accepted_proposals += 1.0

        return position, alpha
810165
@Inject
    public void setSamplerConfiguration(@Nullable Configuration.SamplerConfiguration samplerConfiguration) {
        if (samplerConfiguration != null) {
            configuration.withSampler(samplerConfiguration);
        }
    }
574107
def add!(&blk)
      t = Benchmark.measure(&blk)
      @utime  = utime + t.utime
      @stime  = stime + t.stime
      @cutime = cutime + t.cutime
      @cstime = cstime + t.cstime
      @real   = real + t.real
      self
    end
1003701
protected void doVolumeSlideEffekt(ChannelMemory aktMemo)
	{
		int x = aktMemo.volumSlideValue>>4;
		int y = aktMemo.volumSlideValue&0xF;
		if (x!=0)
		{
			if (x==0xF && y!=0)
				aktMemo.currentSetVolume = aktMemo.currentVolume -= y;
			else
				aktMemo.currentSetVolume = aktMemo.currentVolume += x;
		}
		else
		if (y!=0)
		{
			if (x!=0 && y==0xF)
				aktMemo.currentSetVolume = aktMemo.currentVolume += x;
			else
				aktMemo.currentSetVolume = aktMemo.currentVolume -= y;
		}
	}
1305478
def step_amp(self):
        
        difference = self.drift_target - self._raw_value
        if abs(difference) < self.change_rate:
            self.value = self.drift_target
        else:
            delta = self.change_rate * numpy.sign(difference)
            self.value = self._raw_value + delta
1266003
def update_control_board_calibration(control_board, fitted_params):
    '''
    
    '''
    # Update the control board with the new fitted capacitor and resistor
    # values for the reference load analog input (channel 0).
    control_board.a0_series_resistance = fitted_params['fitted R'].values
    control_board.a0_series_capacitance = fitted_params['fitted C'].values
170214
public static void addSampler(Sampler sampler) {
    synchronized (samplerLock) {
      Sampler[] samplers = additionalSamplers;
      /* create a new list of samplers from the old, adding this sampler */
      if (samplers != null) {
        Sampler[] newSamplers = new Sampler[samplers.length + 1];
        System.arraycopy(samplers, 0, newSamplers, 0, samplers.length);
        newSamplers[samplers.length] = sampler;
        additionalSamplers = newSamplers;
      } else {
        Sampler[] newSamplers = new Sampler[1];
        newSamplers[0] = sampler;
        additionalSamplers = newSamplers;
      }
    }
  }
140707
public void currentSampleChanged(float [] leftSample, float [] rightSample)
	{
		getVULMeterPanel().setVUMeter(leftSample);
		getVURMeterPanel().setVUMeter(rightSample);

		getSALMeterPanel().setMeter(leftSample);
		getSARMeterPanel().setMeter(rightSample);
	}
208319
def update(self, source_clock_sample, target_clock_sample):
        
        if self._resolved_time is None or self.source_clock_overflow_period is None:
            self._resolved_time = decimal.Decimal(source_clock_sample)
            self._prev_source_sample = source_clock_sample
            self._prev_target_sample = target_clock_sample
        else:
            # Time between updates in the target clock domain
            tgt_delta = target_clock_sample - self._prev_target_sample
            self._prev_target_sample = target_clock_sample
            assert tgt_delta >= 0

            # Time between updates in the source clock domain
            src_delta = source_clock_sample - self._prev_source_sample
            self._prev_source_sample = source_clock_sample

            # Using the target clock we can resolve the integer ambiguity (number of overflows)
            full_cycles = int(round((tgt_delta - src_delta) / float(self.source_clock_overflow_period), 0))

            # Updating the source clock now; in two steps, in order to avoid error accumulation in floats
            self._resolved_time += decimal.Decimal(full_cycles * self.source_clock_overflow_period)
            self._resolved_time += decimal.Decimal(src_delta)

        return self._resolved_time
757601
protected int getFineTunePeriod(final ChannelMemory aktMemo)
	{
		if (frequencyTableType>=Helpers.AMIGA_TABLE)
			return (aktMemo.assignedNoteIndex==0)?0:getFineTunePeriod(aktMemo, aktMemo.assignedNoteIndex + aktMemo.currentTranspose);
		else
		if (frequencyTableType==Helpers.IT_LINEAR_TABLE || frequencyTableType==Helpers.STM_S3M_TABLE)
			return (aktMemo.assignedNoteIndex==0)?0:getFineTunePeriod(aktMemo, aktMemo.assignedNoteIndex);
		else
			return (aktMemo.assignedNotePeriod==0)?0:getFineTunePeriod(aktMemo, aktMemo.assignedNotePeriod<<4);
	}
535671
protected void doTremorEffekt(ChannelMemory aktMemo)
	{
		if (aktMemo.tremorCount<aktMemo.tremorOntime)
			aktMemo.currentVolume = aktMemo.currentSetVolume;
		else
			aktMemo.currentVolume = 0;
		
		aktMemo.tremorCount++;
		if (aktMemo.tremorCount>(aktMemo.tremorOntime + aktMemo.tremorOfftime)) aktMemo.tremorCount=0;
	}
938480
def add_fast_step(self, fastsim):
        
        for wire_name in self.trace:
            self.trace[wire_name].append(fastsim.context[wire_name])
966828
def timing(self, stat, time, sample_rate=1):
        
        stats = {stat: "%f|ms" % time}
        self.send(stats, sample_rate)
741153
public void record(double sample) {
        rotate();
        long sampleLong = Double.doubleToLongBits(sample);
        for (AtomicLong max : ringBuffer) {
            updateMax(max, sampleLong);
        }
    }
941825
private void populateNextRate() {
    final MutableDataPoint prev_data = new MutableDataPoint();
    if (source.hasNext()) {
      prev_data.reset(next_data);
      next_data.reset(source.next());
      
      final long t0 = prev_data.timestamp();
      final long t1 = next_data.timestamp();
      if (t1 <= t0) {
        throw new IllegalStateException(
            "Next timestamp (" + t1 + ") is supposed to be "
            + " strictly greater than the previous one (" + t0 + "), but it's"
            + " not.  this=" + this);
      }
      // TODO: for backwards compatibility we'll convert the ms to seconds
      // but in the future we should add a ratems flag that will calculate
      // the rate as is.
      final double time_delta_secs = ((double)(t1 - t0) / 1000.0);
      double difference;
      if (prev_data.isInteger() && next_data.isInteger()) {
        // NOTE: Calculates in the long type to avoid precision loss
        // while converting long values to double values if both values are long.
        // NOTE: Ignores the integer overflow.
        difference = next_data.longValue() - prev_data.longValue();
      } else {
        difference = next_data.toDouble() - prev_data.toDouble();
      }
      
      if (options.isCounter() && difference < 0) {
        if (options.getDropResets()) {
          populateNextRate();
          return;
        }
        
        if (prev_data.isInteger() && next_data.isInteger()) {
          // NOTE: Calculates in the long type to avoid precision loss
          // while converting long values to double values if both values are long.
          difference = options.getCounterMax() - prev_data.longValue() +
              next_data.longValue();
        } else {
          difference = options.getCounterMax() - prev_data.toDouble() +
              next_data.toDouble();
        }
        
        // If the rate is greater than the reset value, return a 0
        final double rate = difference / time_delta_secs;
        if (options.getResetValue() > RateOptions.DEFAULT_RESET_VALUE
            && rate > options.getResetValue()) {
          next_rate.reset(next_data.timestamp(), 0.0D);
        } else {
          next_rate.reset(next_data.timestamp(), rate);
        }
      } else {
        next_rate.reset(next_data.timestamp(), (difference / time_delta_secs));
      }
    } else {
      // Invalidates the next rate with invalid timestamp.
      next_rate.reset(INVALID_TIMESTAMP, 0);
    }
  }
341291
public synchronized void tick() {
        long currentTime = GVRTime.getMilliTime();
        long cutoffTime = currentTime - BUFFER_SECONDS * 1000;
        ListIterator<Long> it = mTimestamps.listIterator();
        while (it.hasNext()) {
            Long timestamp = it.next();
            if (timestamp < cutoffTime) {
                it.remove();
            } else {
                break;
            }
        }

        mTimestamps.add(currentTime);
        mStatColumn.addValue(((float)mTimestamps.size()) / BUFFER_SECONDS);
    }