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

Implement binary search for power start / end search #4

Open
jonashoechst opened this issue Jan 12, 2021 · 0 comments
Open

Implement binary search for power start / end search #4

jonashoechst opened this issue Jan 12, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@jonashoechst
Copy link
Member

The signal extraction on the spectrogram relies on a linear search.

# loop down until threshold is undershot
start = ti
start_min = 0 if self._spectrogram_last is None else -len(self._spectrogram_last[0])
while start > start_min:
if start < 0:
power = self._spectrogram_last[fi, start]
else:
power = fft[start]
if power < self.signal_threshold:
break
start -= 1
# loop up until threshold is undershot
end = ti
while end < len(fft):
if fft[end] < self.signal_threshold:
ti_skip = end
break
end += 1

When using binary search, a significant performance gain in low signal thresholds can be expected.

@jonashoechst jonashoechst added the enhancement New feature or request label Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant