예제 #1
0
void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
{
	//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this
	llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this));

	//precondition: groupp MUST be null or groupp MUST contain this
	llassert(!groupp || groupp->hasElement(this));

/*if (mSpatialGroupp && (groupp != mSpatialGroupp))
	{
		mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
	}*/

	if (mSpatialGroupp != groupp && getVOVolume())
	{ //NULL out vertex buffer references for volumes on spatial group change to maintain
		//requirement that every face vertex buffer is either NULL or points to a vertex buffer
		//contained by its drawable's spatial group
		for (S32 i = 0; i < getNumFaces(); ++i)
		{
			LLFace* facep = getFace(i);
			if (facep)
			{
				facep->clearVertexBuffer();
			}
		}
	}

	//postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
	//postcondition: if next group is NOT NULL, binIndex must not be -1
	llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 :
							getBinIndex() != -1);

	mSpatialGroupp = groupp;
}
예제 #2
0
	/* CONSTRUCTORS */
	LiveFFT::LiveFFT(unsigned int points, unsigned int averageWindow, float gain)
	{
		this->points = points;
		this->gain = gain;

		fft = (ofxFftBasic *)ofxFft::create(points, OF_FFT_WINDOW_HAMMING);	

		average = new RollingAverage<float>[fft->getBinSize()];
		eqFunction = new float[fft->getBinSize()];
		initialised = false;
		musicalRangePtr = getBinIndex(MUSIC_MIN_FREQ);
		musicalRangeBinCount = getBinIndex(MUSIC_MAX_FREQ) - musicalRangePtr;
		output = new float[fft->getBinSize()];
		samples = new float[points];
		streamOpen = false;

		for(int i = 0; i < fft->getBinSize(); i++)
		{
			average[i] = *new RollingAverage<float>(averageWindow);
		}

		for(int i = 0; i < fft->getBinSize(); i++)
		{
			float x = (float)(i + 1) / (float)fft->getBinSize();
			eqFunction[i] = powf(x, 0.5f);
		}

		initAudio();
	}
예제 #3
0
float Binner::getBinDelta(float sample) {
    /* If this Binner uses equally spaced bins in linear or logarithmic
     * space, return the bin delta */
    if (_bin_type == EQUAL || _bin_type == LOGARITHMIC)
        return _bin_delta;

    /* If instead this Binner uses irregularly spaced bin edges defined
     * by a users, compute bin delta of the bin around the sample */
    else {
        int bin_index = getBinIndex(sample);
        return (_edges[bin_index] - _edges[bin_index-1]);
    }
}
예제 #4
0
/**
 * Tallies a weight for a sample
 * @param sample a sample to tally
 * @param weight the weight to increment tally by
 */
void Binner::weightedTally(float sample, float weight) {

    if (_num_bins == 0)
        log_printf(ERROR, "Cannot tally weighted sample in Binner %s since "
                   "the bins have not yet been created", _name);

    int bin_index = getBinIndex(sample);

    if (bin_index >= 0 && bin_index < _num_bins) {
        _tallies[bin_index] += double(weight);
        _num_tallies[bin_index]++;
    }

    return;
}
예제 #5
0
/**
 * Tallies a weight for each sample in a double array of samples
 * @param samples array of samples to tally
 * @param sample_weights array of sample weights to increment tallies by
 * @param num_samples the number of samples to tally
 */
void Binner::weightedTally(float* samples, float* sample_weights,
                           int num_samples) {
    if (_num_bins == 0)
        log_printf(ERROR, "Cannot tally weighted samples in Binner %s "
                   "since the bins have not yet been created", _name);

    int bin_index;

    /* Loop over and tally all samples */
    for (int i=0; i < num_samples; i++) {
        bin_index = getBinIndex(samples[i]);
        if (bin_index >= 0 && bin_index < _num_bins) {
            _tallies[bin_index] += sample_weights[i];
            _num_tallies[bin_index]++;
        }
    }

    return;
}
예제 #6
0
LLSpatialGroup* LLDrawable::getSpatialGroup() const
{ 
	llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1);
	return mSpatialGroupp; 
}