From 8f1420f3ee0d078f218392fb832145653ab04557 Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 2 Aug 2024 16:04:11 +1000 Subject: [PATCH] src: Update test_record.py. Signed-off-by: Damien George --- src/test_record.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/test_record.py b/src/test_record.py index 3bd8b0a..20d2306 100644 --- a/src/test_record.py +++ b/src/test_record.py @@ -22,11 +22,11 @@ "00000" ) -my_recording = audio.AudioFrame(5000) +my_recording = audio.AudioRecording(duration=5000) while True: if button_a.is_pressed(): - microphone.record_into(my_recording, wait=False) + my_track = microphone.record_into(my_recording, wait=False) display.show([mouth_open, mouth_closed], loop=True, wait=False, delay=150) while button_a.is_pressed() and microphone.is_recording(): sleep(50) @@ -35,9 +35,13 @@ while button_a.is_pressed(): sleep(50) display.clear() - my_recording *= 2 # amplify volume + # amplify volume + GAIN = 2 + #my_recording *= GAIN + for i in range(len(my_track)): + my_track[i] = max(0, min(128 + GAIN * (my_track[i] - 128), 255)) if button_b.is_pressed(): - audio.play(my_recording, wait=False) + audio.play(my_track, wait=False) level = 0 while audio.is_playing(): l = audio.sound_level() @@ -47,7 +51,7 @@ level *= 0.95 display.show(play * min(1, level / 100)) x = accelerometer.get_x() - my_recording.set_rate(max(2250, scale(x, (-1000, 1000), (2250, 13374)))) + my_track.set_rate(max(2250, scale(x, (-1000, 1000), (2250, 13374)))) sleep(5) display.clear() sleep(100)