Example #1
0
TestFFTDisplay::TestFFTDisplay(QWidget *parent) :
    QWidget(parent)
{
    m_Controller = new libbeat::BeatController(0,4096,44100,192);
    //Setup two test frequencies: 600Hz and 12000Hz
    m_Controller->addCustomBeat(600);
    m_Controller->addCustomBeat(12000);
    //Draw when processed and analysed data is ready to be displayed
    connect(m_Controller,SIGNAL(processingDone()),this,SLOT(drawNewData()));
    //Connect some test slots to the Controller's signals
    connect(m_Controller,SIGNAL(beatDrum()),this,SLOT(processDrum()));
    connect(m_Controller,SIGNAL(beatSnare()),this,SLOT(processSnare()));
    connect(m_Controller,SIGNAL(beatCustom(QSet<uint16_t>)),this,SLOT(processCustom(QSet<uint16_t>)));
}
void BeatController::processNewData()
{

    m_FFT->processData();
    m_Analyser->processData();
    emit processingDone();
    if(m_Analyser->getDrumBeat())
        emit beatDrum();
    if(m_Analyser->getSnareBeat())
        emit beatSnare();
    //Check for a beat for every frequency in our list
    QSet<uint16_t> myBeats;
    QSetIterator<uint16_t> i(m_customBeats);
    while(i.hasNext())
    {
        if(m_Analyser->getBeatFrequency(i.peekNext()))
            myBeats.insert(i.peekNext());
        i.next();
    }
    if(!myBeats.empty())
        emit beatCustom(myBeats);
}