コード例 #1
0
/**
 * @param aVowel {double} interpolated value within
 *                       the range of the amount specified in the coeffs Array
 */
FormantFilter::FormantFilter( double aVowel )
{
    int i = 0;
    for ( i; i < 11; i++ )
        _currentCoeffs[ i ] = 0.0;

    for ( i = 0; i < 10; i++ )
        _memory[ i ] = 0.0;

    calculateCoeffs();
    setVowel( aVowel );
}
コード例 #2
0
void BEQBaseUGenInternal::processBlock(bool& shouldDelete, const unsigned int blockID, const int channel) throw()
{
	int numSamplesToProcess = uGenOutput.getBlockSize();
	float* outputSamples = uGenOutput.getSampleData();
	float* inputSamples = inputs[Input].processBlock(shouldDelete, blockID, channel);
	float* freqSamples = inputs[Freq].processBlock(shouldDelete, blockID, channel);
	float* controlSamples = inputs[Control].processBlock(shouldDelete, blockID, channel);
	float* gainSamples = inputs[Gain].processBlock(shouldDelete, blockID, channel);
	float newFreq = *freqSamples;
	float newControl = *controlSamples;
	float newGain = *gainSamples;
	float y0;
	
	if((currentFreq != newFreq) || (currentControl != newControl) || (currentGain != newGain))
	{				
		while(numSamplesToProcess--)
		{
			calculateCoeffs(*freqSamples++, *controlSamples++, *gainSamples++);
			
			y0 = *inputSamples++ + b1 * y1 + b2 * y2; 
			*outputSamples++ = (float)(a0 * y0 + a1 * y1 + a2 * y2);
			y2 = y1; 
			y1 = y0;			
		}
				
		currentFreq = *(freqSamples-1);
		currentControl = *(controlSamples-1);
		currentGain = *(gainSamples-1);
	}
	else
	{		
		while(numSamplesToProcess--)
		{
			y0 = *inputSamples++ + b1 * y1 + b2 * y2; 
			*outputSamples++ = a0 * y0 + a1 * y1 + a2 * y2;
			
			y2 = y1; 
			y1 = y0;
		}
	}
	
	y1 = zap(y1);
	y2 = zap(y2);
}