8000 Make spectral rolloff return bound values by Polochon-street · Pull Request #318 · aubio/aubio · GitHub
[go: up one dir, main page]

Skip to content

Make spectral rolloff return bound values - #318

Closed
Polochon-street wants to merge 1 commit into
aubio:masterfrom
Polochon-street:fix-order-rolloff
Closed

Polochon-street wants to merge 1 commit into
aubio:masterfrom
Polochon-street:fix-order-rolloff

Conversation

@Polochon-street
@Polochon-street Polochon-street commented Nov 16, 2020 •
Copy link
Copy Markdown
Contributor

Hi,

The current code returns an out of bound bin (length + 1) if everything is contained in the last bin. This returns instead the last bin.

Not really sure where to test that, but here's a small excerpt that shows it working:

X = [0., 0., 0., 0., 1.]
cumsum = 0.

for x in X:
    cumsum += x

cumsum *= 0.95
j = 0
rollsum += X[j]

while rollsum < cumsum:
    j += 1
    rollsum += X[j]
print(j)

It returns 4 (the right value), and if you instead use

j = 0

while rollsum < cumsum:
    rollsum += X[j]    
    j += 1
print(j)

you can see it returns 5, one too much.

We could also do it the other way, where you go through the norm array and then break whenever you reach 95% of the energy, but I didn't want to change stuff too much :)

@Polochon-street
Copy link
Copy Markdown
Contributor Author

Build seems to fail because of missing public keys?

@rec
rec commented Nov 17, 2020
Copy link
Copy Markdown

Ah, I appear to see that too: #312

See also: #317

@Polochon-street
Copy link
Copy Markdown
Contributor Author

@rec yep, tried to rebuild it today - failed. I guess we just need to wait til the key is updated 😄

@autoantwort autoantwort mentioned this pull request Dec 7, 2020
Copilot AI added a commit to LedFx/aubio-ledfx that referenced this pull request Nov 13, 2025
Co-authored-by: shauneccles <21007065+shauneccles@users.noreply.github.com>
piem added a commit that referenced this pull request Nov 16, 2025
…hon-street)

We now return at least the first bin, and at most the last bin number, to
prevent returning a value greater than the length of the norm vector size.
@piem
piem commented Nov 16, 2025
Copy link
Copy Markdown
Member

hey @Polochon-street

thank you for that. I adopted a slightly different approach just for clarity. I also added unit tests to check the behavior is correct for both edge cases.

cheers, piem

8000

@Polochon-street
Copy link
Copy Markdown
Contributor Author

no worries, glad that it's fixed! Cheers.

piem added a commit that referenced this pull request Nov 16, 2025
…hon-street)

We now return at least the first bin, and at most the last bin number, to
prevent returning a value greater than the length of the norm vector size.
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

Successfully merging this pull request may close these issues.

3 participants

0