Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

run basic.cpp to get full wav's key crash #27

Open
liaozi90 opened this issue Jul 14, 2023 · 0 comments
Open

run basic.cpp to get full wav's key crash #27

liaozi90 opened this issue Jul 14, 2023 · 0 comments

Comments

@liaozi90
Copy link

I meet a issue, when i test a wav file to get it's key by keyOfAudio function, I found a crash issue at below code stack:
finaChromagram()-->preprocess()-->lpf->filter() -->audio.advanceWriteIterator(shortcutFactor)

After debug, I think the flush remainder buffer has some issue, after first progressiveChromagram() operation of keyOfAudio(), the remainder buffer data is not enough for downsample(remainder lenght is small than downsampleFactor), so we will fail when we want to advance the flush buffer's write iterator.
_key_t KeyFinder::keyOfAudio(const AudioData& originalAudio) {

Workspace workspace;
progressiveChromagram(originalAudio, workspace);
finalChromagram(workspace);

return keyOfChromaVector(workspace.chromagram->collapseToOneHop());

}_
I think we can just erase the workspace's remainder buffer, since it's downsample result would be empty.
void KeyFinder::finalChromagram(Workspace& workspace) {
// flush remainder buffer
if (workspace.remainderBuffer.getSampleCount() > 0) {
AudioData flush;
preprocess(flush, workspace, true);
}
......
}

So I modified the code like below, and it works:
void KeyFinder::finalChromagram(Workspace& workspace) {
// flush remainder buffer
if (workspace.remainderBuffer.getSampleCount() > 0) {
//AudioData flush;
//preprocess(flush, workspace, true);
//remained data not enough for downsample, just skip them
workspace.remainderBuffer.discardFramesFromFront(workspace.remainderBuffer.getFrameCount());
}
.....
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant