예제 #1
0
파일: oping.c 프로젝트: anarcat/liboping
static double latency_to_ratio (ping_context_t *ctx, /* {{{ */
		double latency)
{
	size_t low;
	size_t high;
	size_t index;

	clean_history (ctx);

	/* Not a single packet was received successfully. */
	if (ctx->history_received == 0)
		return NAN;

	low = 0;
	high = ctx->history_received - 1;

	if (latency < ctx->history_by_value[low])
		return 0.0;
	else if (latency >= ctx->history_by_value[high])
		return 100.0;

	/* Do a binary search for the latency. This will work even when the
	 * exact latency is not in the array. If the latency is in the array
	 * multiple times, "low" will be set to the index of the last
	 * occurrence. The value at index "high" will be larger than the
	 * searched for latency (assured by the above "if" block. */
	while ((high - low) > 1)
	{
		index = (high + low) / 2;

		if (ctx->history_by_value[index] > latency)
			high = index;
		else
			low = index;
	}

	assert (ctx->history_by_value[high] > latency);
	assert (ctx->history_by_value[low] <= latency);

	if (ctx->history_by_value[low] == latency)
		index = low;
	else
		index = high;

	return (((double) (index + 1)) / ((double) ctx->history_received));
} /* }}} double latency_to_ratio */
예제 #2
0
파일: oping.c 프로젝트: anarcat/liboping
static double percentile_to_latency (ping_context_t *ctx, /* {{{ */
		double percentile)
{
	size_t index;

	clean_history (ctx);

	/* Not a single packet was received successfully. */
	if (ctx->history_received == 0)
		return NAN;

	if (percentile <= 0.0)
		index = 0;
	else if (percentile >= 100.0)
		index = ctx->history_received - 1;
	else
	{
		index = (size_t) ceil ((percentile / 100.0) * ((double) ctx->history_received));
		assert (index > 0);
		index--;
	}

	return (ctx->history_by_value[index]);
} /* }}} double percentile_to_latency */
예제 #3
0
void config_iir(int srate, int bands, int original)
{
  band_count = bands;
  iir_cf = get_coeffs(&band_count, srate, original);
  clean_history();
}
예제 #4
0
void   uninit_equliazer()
{
	clean_history();
}