Ejemplo n.º 1
0
// Runs update logic
void KissFileSampleApp::update() 
{

	// Check if track is playing and has a PCM buffer available
	if (mTrack->isPlaying() && mTrack->isPcmBuffering())
	{

		// Get buffer
		mBuffer = mTrack->getPcmBuffer();
		if (mBuffer && mBuffer->getInterleavedData())
		{

			// Get sample count
			uint32_t mSampleCount = mBuffer->getInterleavedData()->mSampleCount;
			if (mSampleCount > 0)
			{

				// Initialize analyzer, if needed
				if (!mFftInit)
				{
					mFftInit = true;
					mFft.setDataSize(mSampleCount);
				}

				// Analyze data
				if (mBuffer->getInterleavedData()->mData != 0) 
					mFft.setData(mBuffer->getInterleavedData()->mData);

			}

		}

	}

}
Ejemplo n.º 2
0
//*********************************************************************************
void BeatDetectorApp::Init( uint32_t mSampleCount )
{
	mFftInit = true;
	mFft.setDataSize(mSampleCount);

	int num_bins = mFft.getBinSize();
	CSoundAnalyzer::StaticInit(num_bins, samples_per_frame);

	for(int i=0; i<5; i++)
	{
		float i_f = i/(float)5 - 0.4f;
		m_Cirlces.push_back(Circle(Color(1, 0, 0), 0, Vec2f(0, getWindowHeight() * i_f)));
	}
}