From fa981a2a56d3ef4e42609e544a8cb47b443edaf8 Mon Sep 17 00:00:00 2001 From: foamyguy Date: Tue, 12 Nov 2024 16:20:43 -0600 Subject: [PATCH] rename _samples to _mic_samples and fix if condition --- adafruit_circuitplayground/bluefruit.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/adafruit_circuitplayground/bluefruit.py b/adafruit_circuitplayground/bluefruit.py index 5758267..7f36195 100755 --- a/adafruit_circuitplayground/bluefruit.py +++ b/adafruit_circuitplayground/bluefruit.py @@ -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: @@ -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.