Example #1
0
void FIR::exec( Array< Sample > &samples )
{
	mutex.lock();
	const float *fir_coeff_data = fir_coeff.constData();
	for ( int i = 0 ; i < outputsCount() ; ++i )
	{
		float sum = 0.0;
		inputBuffer[ i ].set( inputSamples[ i ] );

		float *chunk1, *chunk2;
		int s1, s2;

		inputBuffer[ i ].getChunks( chunk1, s1, chunk2, s2 );

		int j, k;
		for ( j = 0 ; j < s1 ; ++j )
			sum += fir_coeff_data[ j ] * chunk1[ j ];
		k = j;
		for ( j = 0 ; j < s2 ; ++j, ++k )
			sum += fir_coeff_data[ k ] * chunk2[ j ];

		inputBuffer[ i ].advance();
		samples += ( Sample ){ getTarget( i ), sum };
	}
	mutex.unlock();
}
Example #2
0
bool Gain::start()
{
	if ( inputsCount() != outputsCount() )
		return false;
	settings->setRunMode( true );
	buffer.reset( new float[ inputsCount() ]() );
	return true;
}
Example #3
0
bool Math::start()
{
	if ( inputsCount() != outputsCount() )
		return false;
	buffer.reset( new float[ inputsCount() ]() );
	settings->setRunMode( true );
	setOperation();
	return true;
}
Example #4
0
bool FIR::start()
{
	if ( inputsCount() != outputsCount() )
		return false;
	settings->setRunMode( true );
	inputBuffer.reset( new RingBuffer< float >[ inputsCount() ] );
	inputSamples.reset( new float[ inputsCount() ]() );
	setInputBuffer();
	return true;
}
Example #5
0
    void play() {
        int n_outputs = outputsCount();
        Q_ASSERT( n_outputs == m_ways );
        int i = 0,
                s = m_inputs[0].count();
        foreach(Photo photo, m_inputs[0]) {
            if (aborted())
                continue;
            outputPush(i%n_outputs, photo);
            emitProgress(i, s, 0, 1);
            ++i;
        }
        if (aborted() )
            emitFailure();
        else
            emitSuccess();

    }
Example #6
0
void PWM::exec( Array< Sample > &samples )
{
	quint32 period = round( Global::getSampleRate() / freq );
	quint32 hi_samples = round( period * duty );
	quint32 lo_samples = period - hi_samples;

	if ( !state && num_samples >= lo_samples )
	{
		num_samples = 0;
		if ( hi_samples > 0 )
			state = true;
	}
	if ( state && num_samples >= hi_samples )
	{
		num_samples = 0;
		if ( lo_samples > 0 )
			state = false;
	}
	++num_samples;

	for ( int i = 0 ; i < outputsCount() ; ++i )
		samples += ( Sample ){ getTarget( i ), ( float )state };
}
Example #7
0
void Gain::exec( Array< Sample > &samples )
{
	for ( int i = 0 ; i < outputsCount() ; ++i )
		samples += ( Sample ){ getTarget( i ), buffer[ i ] * gain };
}
Example #8
0
void Math::exec( Array< Sample > &samples )
{
	MathFunc _math_func = math_func;
	for ( int i = 0 ; i < outputsCount() ; ++i )
		samples += ( Sample ){ getTarget( i ), ( float )_math_func( buffer[ i ] ) };
}
Example #9
0
void RandomGen::exec( Array< Sample > &samples )
{
	for ( int i = 0 ; i < outputsCount() ; ++i )
		samples += ( Sample ){ getTarget( i ), qrand() / ( RAND_MAX / 2.0f ) - 1.0f };
}