示例#1
0
void
paFunImpactGen::initialize(paFunSurface* surface)
{
	// Copy / reference surface data.

	m_isNew = true;							
	m_surface = surface;
	m_otherSurface = 0;
   	m_contactGen.initialize(surface);		//!! Wasteful to always have skid contactgen with each impact. Probably its not used.
	m_limit = surface->m_impactAmpMax;

	m_lowpass.reset();

	if (m_surface->m_nImpactSamples > 0)
	{
		if (m_surface->m_nImpactSamples == 1) m_samplePlaying = 0;
		else
		{
			int lastSample = m_samplePlaying;
			m_samplePlaying = paRnd(0, m_surface->m_nImpactSamples -2);
			if (m_samplePlaying >= lastSample) m_samplePlaying += 1;  // Don't repeat sample.
		}
		m_endOfSample = false;
	}
	else m_endOfSample = true;	// 
}
示例#2
0
void
paWhiteFun :: tick(paFunContactGen* gen){

	paFloat* out = gen->getOutput()->getStart();
	int i;

	for(i = 0; i < paBlock::nFrames; i++)
		out[i] = paRnd(-1.0f, 1.0f);

}
示例#3
0
void
paRndFun :: tick(paFunContactGen* gen){

	paFloat* out = gen->getOutput()->getStart();
	paFloat r = gen->m_rate / paScene::nFramesPerSecond; //! Per rate adjust. Better to derive GridSurface and overide SetRateAtSpeed to include per sample factor.

	paFloat zr;
	paFloat y;
	int i;

	y = gen->m_y;
	if (r<0) r = -r;
	zr = r * m_zeroRate;		// As rate increases, zero_rate increases and size of bumps decreases.
	
//if (ghit) m_zr = paRnd(10000.0f, 10000.0f) / paScene::nFramesPerSecond;		// Fixed width for foil.

//	gen->getOutput()->fillWithNoise();		//! expt. noise modulation.

	ghit = false;
	for(i = 0; i < paBlock::nFrames; i++)
	{

		if (paRnd(1.0f) < r)		//! More efficient to calculate time to next bump once at each bump.
		{
			y = paRnd(m_min, 1.0f);
			ghit = true;			// expt. Flag new hit to other signal processes, eg FOIL filter change
		}
		else if (m_fastZero || paRnd(1.0f) < zr) y = 0.0f;	

//		out[i] = y;
		if (y != 0.0f) out[i] = paRnd(y);    else out[i] = 0.0f;

//		out[i] *= y*0.001;

	}

	gen->m_y = y;
}
示例#4
0
	// Move the deleted handle to the new first free handle index.
	m_handle[m_nActiveHandles] = deletedHandle;		

	// Move the displaced 'lastHandle' to where the deleted handle was.
	m_handle[deletedHandleIndex] = lastHandle;
	m_handle2index[lastHandle] = deletedHandleIndex;

	return 0;
}


paHandle 
paHandleManager :: getNextHandle() { 
	if (m_handleCounter >= m_nActiveHandles) {
		m_handleCounter = -1;			// Indicates ennumeration finito.
		return -1;
	}
	return m_handle[m_handleCounter++]; 
};


paHandle
paHandleManager :: getRandomHandle() {
	paLOCKCHECK
	if (m_nActiveHandles > 0)	
		return m_handle[ paRnd((int)0, (int)m_nActiveHandles-1) ];

	return -1;
};