File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ def show(self, data):
54
54
55
55
group = displayio .Group (scale = 3 )
56
56
graph = RollingGraph (3 )
57
- fft_size = 128
57
+ fft_size = 256
58
58
59
59
# Add the TileGrid to the Group
60
60
group .append (graph )
@@ -71,7 +71,7 @@ def show(self, data):
71
71
72
72
# Main Loop
73
73
def main ():
74
- max_all = 1
74
+ max_all = 10
75
75
76
76
while True :
77
77
mic .record (samples_bit , len (samples_bit ))
@@ -81,16 +81,20 @@ def main():
81
81
# to change any zeros to nonzero numbers
82
82
spectrogram1 = ulab .vector .log (spectrogram1 + 1e-7 )
83
83
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 ]
86
86
87
87
if max_curr > max_all :
88
88
max_all = max_curr
89
89
else :
90
90
max_curr = max_curr - 1
91
91
92
+ print (min_curr , max_all )
93
+ min_curr = max (min_curr , 3 )
92
94
# Plot FFT
93
95
data = (spectrogram1 - min_curr ) * (51. / (max_all - min_curr ))
96
+ # This clamps any negative numbers to zero
97
+ data = data * ulab .array ((data > 0 ))
94
98
graph .show (data )
95
99
96
100
main ()
You can’t perform that action at this time.
0 commit comments