Пример #1
0
LfoController::LfoController( Model * _parent ) :
	Controller( Controller::LfoController, _parent, tr( "LFO Controller" ) ),
	m_baseModel( 0.5, 0.0, 1.0, 0.001, this, tr( "Base value" ) ),
	m_speedModel( 2.0, 0.01, 20.0, 0.0001, 20000.0, this, tr( "Oscillator speed" ) ),
	m_amountModel( 1.0, -1.0, 1.0, 0.005, this, tr( "Oscillator amount" ) ),
	m_phaseModel( 0.0, 0.0, 360.0, 4.0, this, tr( "Oscillator phase" ) ),
	m_waveModel( Oscillator::SineWave, 0, Oscillator::NumWaveShapes,
			this, tr( "Oscillator waveform" ) ),
	m_multiplierModel( 0, 0, 2, this, tr( "Frequency Multiplier" ) ),
	m_duration( 1000 ),
	m_phaseOffset( 0 ),	
	m_currentPhase( 0 ),
	m_sampleFunction( &Oscillator::sinSample ),
	m_userDefSampleBuffer( new SampleBuffer )
{
	setSampleExact( true );
	connect( &m_waveModel, SIGNAL( dataChanged() ),
			this, SLOT( updateSampleFunction() ) );
	
	connect( &m_speedModel, SIGNAL( dataChanged() ),
			this, SLOT( updateDuration() ) );
	connect( &m_multiplierModel, SIGNAL( dataChanged() ),
			this, SLOT( updateDuration() ) );
	connect( engine::mixer(), SIGNAL( sampleRateChanged() ), 
			this, SLOT( updateDuration() ) );
	
	connect( engine::getSong(), SIGNAL( playbackStateChanged() ),
			this, SLOT( updatePhase() ) );
	connect( engine::getSong(), SIGNAL( playbackPositionChanged() ),
			this, SLOT( updatePhase() ) );
			
	updateDuration();
}
Пример #2
0
	//BEAUTIFUL SINE WAVE GENERATOR IMPORTANT
float wavetableSynth(void)
{

	int intPart;
	float fracPart, samp0, samp1, single_samp, temp;

	//for (i = 0; i < BUFFER_LENGTH; i++)
	//{
		//linear interpolation
		temp = phasor * VECTOR_LENGTH;
		intPart = temp;
		fracPart = temp - intPart;
		samp0 = theFunction[intPart];
		if (++intPart >= VECTOR_LENGTH)
			intPart = 0;
		samp1 = theFunction[intPart];
		single_samp = (samp0 + (samp1 - samp0) * fracPart) * INV_TWO_TO_15; //scale amplitude down

		updatePhase();
		return single_samp;
	//}
}