// 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); } } } }
//************************************************************************* void BeatDetectorApp::update() { if(write_frames) { if(curr_sample < p_sample->m_SampleCount) { // Initialize analyzer, if needed if (!mFftInit) { Init(samples_per_frame); } mFft.setData(p_sample->mp_Buffer + (curr_sample)); curr_sample += samples_per_frame; CSoundAnalyzer::Get().ProcessData(mFft.getAmplitude(), mFft.getData()); } else { shutdown(); } } else { // 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->getChannelData(CHANNEL_FRONT_LEFT)->mSampleCount; if (mSampleCount > 0) { // Initialize analyzer, if needed if (!mFftInit) { Init(samples_per_frame); } // Analyze data if (mBuffer->getChannelData(CHANNEL_FRONT_LEFT)->mData != 0) mFft.setData(mBuffer->getChannelData(CHANNEL_FRONT_LEFT)->mData); CSoundAnalyzer::Get().ProcessData(mFft.getAmplitude(), mFft.getData()); } } } } }