示例#1
0
double speaker_sound_device::update_interm_samples_get_filtered_volume(int volume)
{
	double filtered_volume, tempx;

	/* We may have one or more interm. samples to go */
	if (m_interm_sample_index < RATE_MULTIPLIER)
	{
		/* First interm. sample may be composed. */
		finalize_interm_sample(volume);

		/* Subsequent interm. samples will be homogeneous. */
		while (m_interm_sample_index + 1 < RATE_MULTIPLIER)
		{
			init_next_interm_sample();
			m_composed_volume[m_composed_sample_index] = volume;
		}
	}
	/* Important: next interm. sample not initialised yet, so that no data is destroyed before filtering... */
	filtered_volume = get_filtered_volume();
	init_next_interm_sample();
	/* Reset counter to next stream sample: */
	m_interm_sample_index = 0;

	/* simple DC blocker filter */
	tempx = filtered_volume;
	filtered_volume = tempx - m_prevx + 0.995 * m_prevy;
	m_prevx = tempx;
	m_prevy = filtered_volume;

	return filtered_volume;
}
示例#2
0
static double update_interm_samples_get_filtered_volume(speaker_state *sp, int volume)
{
	double filtered_volume;

	/* We may have one or more interm. samples to go */
	if (sp->interm_sample_index < RATE_MULTIPLIER)
	{
		/* First interm. sample may be composed. */
		finalize_interm_sample(sp, volume);

		/* Subsequent interm. samples will be homogeneous. */
		while (sp->interm_sample_index + 1 < RATE_MULTIPLIER)
		{
			init_next_interm_sample(sp);
			sp->composed_volume[sp->composed_sample_index] = volume;
		}
	}
	/* Important: next interm. sample not initialised yet, so that no data is destroyed before filtering... */
	filtered_volume = get_filtered_volume(sp);
	init_next_interm_sample(sp);
	/* Reset counter to next stream sample: */
	sp->interm_sample_index = 0;

	return filtered_volume;
}