Skip to content

Implement binary search for power start / end search #4

Description

@jonashoechst

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions