Skip to content

Commit 8f1420f

Browse files
committed
src: Update test_record.py.
Signed-off-by: Damien George <[email protected]>
1 parent 228bbd5 commit 8f1420f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/test_record.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
"00000"
2323
)
2424

25-
my_recording = audio.AudioFrame(5000)
25+
my_recording = audio.AudioRecording(duration=5000)
2626

2727
while True:
2828
if button_a.is_pressed():
29-
microphone.record_into(my_recording, wait=False)
29+
my_track = microphone.record_into(my_recording, wait=False)
3030
display.show([mouth_open, mouth_closed], loop=True, wait=False, delay=150)
3131
while button_a.is_pressed() and microphone.is_recording():
3232
sleep(50)
@@ -35,9 +35,13 @@
3535
while button_a.is_pressed():
3636
sleep(50)
3737
display.clear()
38-
my_recording *= 2 # amplify volume
38+
# amplify volume
39+
GAIN = 2
40+
#my_recording *= GAIN
41+
for i in range(len(my_track)):
42+
my_track[i] = max(0, min(128 + GAIN * (my_track[i] - 128), 255))
3943
if button_b.is_pressed():
40-
audio.play(my_recording, wait=False)
44+
audio.play(my_track, wait=False)
4145
level = 0
4246
while audio.is_playing():
4347
l = audio.sound_level()
@@ -47,7 +51,7 @@
4751
level *= 0.95
4852
display.show(play * min(1, level / 100))
4953
x = accelerometer.get_x()
50-
my_recording.set_rate(max(2250, scale(x, (-1000, 1000), (2250, 13374))))
54+
my_track.set_rate(max(2250, scale(x, (-1000, 1000), (2250, 13374))))
5155
sleep(5)
5256
display.clear()
5357
sleep(100)

0 commit comments

Comments
 (0)