Giter Club home page Giter Club logo

Comments (2)

loretoparisi avatar loretoparisi commented on July 25, 2024

I realized that the calculation should be done for each buffer:

while (inFile->eof() == 0)
{

    // ....

   for(int i=0;i<samples;i++) {
        float fSample = output[ i ] / 32768.0f;
        floatVect->push_back(fSample);
    }
    bpmDetect->process((*inFile).getElapsedMS(), *floatVect);


    // ....

 }


 bpm = bpmDetect->winning_bpm;
bpmDetect->reset();

The problem is the same in this case too, bpm = 0

Could it be a buffer problem with the

std::vector<float> floatVect[BUFF_SIZE];

from beatdetektor.

cjcliffe avatar cjcliffe commented on July 25, 2024

I can't tell from your code what the overall process before the detection is and whether you've cleared the floatVect, what the FFT output is, etc.. but I'll outline the basic idea as reference for everyone.

The input is the current FFT frame, and you'll want to keep the symmetry (don't just take half of the fft result array -- explanation for that is enough for another discussion though) and the time at which it was sampled from.

If you're processing an audio file you'll need to choose your frame rate so that you get enough quality FFT frames per second for your sample rate. For this example we'll assume a function exists that does that called getSamplesBySeconds, which at 29.4 fps for 44100hz would give us 1500 samples per frame.

Some basic pseudo-code for that process is:

timer = 0;
frames_per_second = 29.4;
while (samplesAvailable()) {

   // get a second worth of samples
   samples = getSamplesBySeconds(1 / frames_per_second);

   // get full FFT frame for this sample
   fft = getFFT(samples);

   // run BeatDetektor
   bpmDetect->process(timer, fft); 

   timer += 1 / frames_per_second;  // increment timer
}

from beatdetektor.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.