adamstark/Gist

Do onset detection

victorpalle opened this issue · 4 comments

Hello !

I'm new to audio manipulation and I'd like to know how to use properly your gists function to do onset detection. First question is I don't know what to put in the energyDifference function paramaters. Can you explain me a little bit ?
Thank you ;)

For the energyDifference function, you just need to pass it a frame of audio samples (the exact size will be determined by the environment you are using, but should be something between 128 and 512 samples - you should also initialise Gist with this frame size so it knows what to expect).

Thank you for your response !
We are a group of IT student working on an audio project for Sony CSL. We have a track of 42 seconds and we'd like to do onset detection on it. To do so we store all the samples of our track in a vector and then call the energyDifference function every 512 samples and store the result. But it is not very satisfying. Are we doing it the right way ?

Thank you very much again !

That sounds roughly correct to me. Something like this?

std::vector<double> fullTrackAudio;
std::vector<double> onsetDetectionFunction;

// load full track audio somehow...

for (int i = 0; i < fullTrackAudio.size(); i += 512)
{
    std::vector<double> audioFrame;

    for (int j = 0; j < 512; j++)
    {
        audioFrame[j] = fullTrackAudio[i + j];
    }

    gist.processAudioFrame (audioFrame);
    double energyDifference = gist.energyDifference();
    onsetDetectionFunction.push_back (energyDifference);
}

I've not tested the above code (I just wrote it here in the chat), but something like that should work...

Regarding the quality of the energy difference function - you will get much better results from spectral difference or complex spectral difference onset detection functions.

Also - to actually get the onsets, you will need a peak-picking algorithm to process the onset detection function. The quality of that algorithm will affect the results also.

Thanks,
Adam

Closing this as it has been a few weeks with no activity