-
Notifications
You must be signed in to change notification settings - Fork 156
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
use full decimation instead of fast #133
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,6 @@ def __init__(self): | |
def analyzelive(self, samples): | ||
samples = self.decimate(samples) | ||
|
||
# uncomment the following to disable the decimation altogether | ||
# decimation = 1 | ||
|
||
# FFT for a linear transformation in frequency scale | ||
fft = rfft(samples * self.window) | ||
spectrum = self.norm_square(fft) | ||
|
@@ -60,9 +57,9 @@ def decimate(self, samples): | |
if self.decimation > 1: | ||
samples.shape = len(samples) // self.decimation, self.decimation | ||
# the full way | ||
# samples = samples.mean(axis=1) | ||
# the simplest way | ||
samples = samples[:, 0] | ||
samples = samples.mean(axis=1) | ||
# the fastest way | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (I didn't actually profile this, idk how much computation time goes here vs actually doing the fft and rendering) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm, I just profiled (with a value of self.decimation == 16) and with the faster way, the decimation function takes about 7.05% of a the FFT's duration, and with the slower way it takes about 93.1% of the FFT's duration. So, a pretty significant cost, assuming the FFT is the expensivest part of this process. |
||
# samples = samples[:, 0] | ||
return samples | ||
|
||
def set_fftsize(self, fft_size): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried setting
self.decimation = 1
here, and that just resulted an error on the next line, "Operands cannot be broadcast together with shapes (4096,) (256,)"; so I think this comment is outdatedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I also tried using
self.decimation = 1
and "fixing" the below line to make the shapes line up, but that just resulted in this error instead; I guess the value of self.decimation affects a bunch of places)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, lol, actually settings self.decimation = 1 works just fine, you just have to do it in the set_maxfreq function so that it never sets it to any non-1 value