Skip to content

Commit

Permalink
src: Update test_record.py.
Browse files Browse the repository at this point in the history
Signed-off-by: Damien George <[email protected]>
  • Loading branch information
dpgeorge committed Aug 2, 2024
1 parent 228bbd5 commit 8f1420f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/test_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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)

0 comments on commit 8f1420f

Please sign in to comment.