Skip to content

Commit f47a1bb

Browse files
committed
tweaks to waterfall -- reduces background noise reception
1 parent f8af760 commit f47a1bb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

ulab_Crunch_Numbers_Fast/waterfall.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def show(self, data):
5454

5555
group = displayio.Group(scale=3)
5656
graph = RollingGraph(3)
57-
fft_size = 128
57+
fft_size = 256
5858

5959
# Add the TileGrid to the Group
6060
group.append(graph)
@@ -71,7 +71,7 @@ def show(self, data):
7171

7272
# Main Loop
7373
def main():
74-
max_all = 1
74+
max_all = 10
7575

7676
while True:
7777
mic.record(samples_bit, len(samples_bit))
@@ -81,16 +81,20 @@ def main():
8181
# to change any zeros to nonzero numbers
8282
spectrogram1 = ulab.vector.log(spectrogram1 + 1e-7)
8383
spectrogram1 = spectrogram1[1:(fft_size//2)-1]
84-
min_curr = min(spectrogram1)
85-
max_curr = max(spectrogram1)
84+
min_curr = ulab.numerical.min(spectrogram1)[0]
85+
max_curr = ulab.numerical.max(spectrogram1)[0]
8686

8787
if max_curr > max_all:
8888
max_all = max_curr
8989
else:
9090
max_curr = max_curr-1
9191

92+
print(min_curr, max_all)
93+
min_curr = max(min_curr, 3)
9294
# Plot FFT
9395
data = (spectrogram1 - min_curr) * (51. / (max_all - min_curr))
96+
# This clamps any negative numbers to zero
97+
data = data * ulab.array((data > 0))
9498
graph.show(data)
9599

96100
main()

0 commit comments

Comments
 (0)