示例#1
0
bool SPECTACLE2_BASE::set_freqrange(float min, float max, const char *type)
{
	if (min != _minfreq || max != _rawmaxfreq) {
		_rawmaxfreq = max;
		if (max == 0.0f)
			max = _nyquist;
		if (max < min)
			_fswap(&min, &max);
		if (max > _nyquist)
			max = _nyquist;
		_minfreq = _fclamp(0.0f, min, max);
		update_bin_groups(_bin_groups, _minfreq, max, _control_table_size, type);
		return true;
	}
	return false;
}
示例#2
0
// --------------------------------------------------------- set_eq_freqrange --
// Similar to set_freqrange in base class, but for _eq_bin_groups.
bool SPECTACLE2::set_eq_freqrange(float min, float max)
{
	if (min != _eq_minfreq || max != _eq_rawmaxfreq) {
		_eq_rawmaxfreq = max;
		if (max == 0.0f)
			max = _nyquist;
		if (max < min)
			_fswap(&min, &max);
		if (max > _nyquist)
			max = _nyquist;
		_eq_minfreq = _fclamp(0.0f, min, max);
		update_bin_groups(_eq_bin_groups, _eq_minfreq, max, _eqtablen, "EQ");
		return true;
	}
	return false;
}
示例#3
0
bool SpectacleBase::set_freqrange(float min, float max)
{
	if (min != _minfreq || max != _maxfreq) {
		if (max == 0.0f)
			max = _nyquist;
		if (max < min)
			_fswap(&min, &max);
		if (max > _nyquist)
			max = _nyquist;
		_maxfreq = max;
		_minfreq = _fclamp(0.0f, min, max);
		update_bin_groups(_bin_groups, NULL, _minfreq, max, _control_table_size);
		return true;
	}
	return false;
}
示例#4
0
// ------------------------------------------------------ set_delay_freqrange --
// Similar to set_freqrange in base class, but for _delay_bin_groups.
bool Spectacle::set_delay_freqrange(float min, float max)
{
	if (min != _delay_minfreq || max != _delay_maxfreq) {
		if (max == 0.0f)
			max = _nyquist;
		if (max < min)
			_fswap(&min, &max);
		if (max > _nyquist)
			max = _nyquist;
		_delay_maxfreq = max;
		_delay_minfreq = _fclamp(0.0f, min, max);
		update_bin_groups(_delay_bin_groups, _delay_binmap_table,
		                             _delay_minfreq, max, _delay_table_size);
		return true;
	}
	return false;
}
示例#5
0
// ---------------------------------------------------------- modify_analysis --
void SPECTACLE2::modify_analysis(bool reading_input)
{
	DPRINT1("modify_analysis: .............. reading_input=%d\n", reading_input);
#ifdef DUMP
	dump_anal_bins();
#endif

#ifdef PRINT_DELTIMES
	static float *prevdeltimes = NULL;
	if (prevdeltimes == NULL) {
		prevdeltimes = new float [_control_table_size];
		printf("\nmodify_analysis: delay times --------------------------\n");
		for (int i = 0; i < _control_table_size; i++) {
			prevdeltimes[i] = _deltimetable[i];
			printf("[%d] %f\n", i, _deltimetable[i]);
		}
 #ifdef PRINT_DELTIME_CHANGES
		printf("\nmodify_analysis: delay time changes -------------------\n");
 #endif
	}
#endif

	for (int i = 0; i <= _half_fftlen; i++) {
		int index = i << 1;

		float eq;
		if (_eqtable) {
			int bg = _eq_bin_groups ? _eq_bin_groups[i] : i;
			eq = _eqtable[bg];
		}
		else
			eq = _eqconst;

		// Delay time and feedback use base class bin groups array.
		const int bg = _bin_groups[i];

		float deltime = _deltimetable ? _deltimetable[bg] : _deltimeconst;
		deltime = _fclamp(0.0f, deltime, kMaxDelayTime);
#ifdef PRINT_DELTIME_CHANGES
		if (deltime != prevdeltimes[bg]) {
			printf("[%d] %f\n", bg, deltime);
			prevdeltimes[bg] = deltime;
		}
#endif

		float mag = reading_input ? (_anal_bins[index] * _ampdb(eq)) : 0.0f;
		float phase = _anal_bins[index + 1];

		if (deltime == 0.0f) {
			_anal_bins[index] = mag;
			_anal_bins[index + 1] = phase;
		}
		else {
			float feedback = _feedbacktable ? _feedbacktable[bg] : _feedbackconst;

			long delsamps = long((deltime * SR) + 0.5) / _decimation;

			// Not sure why this is necessary, but without it, delayed copies
			// sound distorted...

			if (_overlap > 1) {
				int remainder = delsamps % _overlap;
				if (remainder)
					delsamps -= remainder;
			}

			float newmag = _mag_delay[i]->getsamp(delsamps);
			float newphase = _phase_delay[i]->getsamp(delsamps);
			_anal_bins[index] = newmag;
			_anal_bins[index + 1] = newphase;
			_mag_delay[i]->putsamp(mag + (newmag * feedback));

			if (reading_input)
				_phase_delay[i]->putsamp(phase);
			else
				_phase_delay[i]->putsamp(newphase);
		}
	}
}