Skip to content

Commit

Permalink
rename _samples to _mic_samples and fix if condition
Browse files Browse the repository at this point in the history
  • Loading branch information
FoamyGuy committed Nov 12, 2024
1 parent 5a1e7db commit fa981a2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions adafruit_circuitplayground/bluefruit.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self) -> None:
sample_rate=16000,
bit_depth=16,
)
self._samples = None
self._mic_samples = None

@staticmethod
def _normalized_rms(values) -> float:
Expand Down Expand Up @@ -91,10 +91,10 @@ def sound_level(self) -> float:
while True:
print(cpb.sound_level)
"""
if self._sample is None:
self._samples = array.array("H", [0] * 160)
self._mic.record(self._samples, len(self._samples))
return self._normalized_rms(self._samples)
if self._mic_samples is None:
self._mic_samples = array.array("H", [0] * 160)
self._mic.record(self._mic_samples, len(self._mic_samples))
return self._normalized_rms(self._mic_samples)

def loud_sound(self, sound_threshold: int = 200) -> bool:
"""Utilise a loud sound as an input.
Expand Down

0 comments on commit fa981a2

Please sign in to comment.