@@ -141,7 +141,7 @@ Functions
141141
142142 :return: A representation of the sound pressure level in the range 0 to 255.
143143
144- .. py :function :: record(duration, rate = 11000 )
144+ .. py :function :: record(duration, rate = 7812 )
145145
146146 Record sound into an ``AudioRecording `` for the amount of time indicated by
147147 ``duration `` at the sampling rate indicated by ``rate ``.
@@ -267,10 +267,8 @@ An example of recording and playback with a display animation::
267267 "00000"
268268 )
269269
270- RECORDING_RATE = 3906
271- RECORDING_MS = 5000
272-
273- my_recording = audio.AudioRecording(duration=RECORDING_MS, rate=RECORDING_RATE)
270+ RECORDING_RATE = 7812 # The default sample rate
271+ my_recording = audio.AudioRecording(duration=5000, rate=RECORDING_RATE)
274272
275273 while True:
276274 if button_a.is_pressed():
@@ -283,7 +281,10 @@ An example of recording and playback with a display animation::
283281 if button_b.is_pressed():
284282 audio.play(clipped_recording, wait=False)
285283 while audio.is_playing():
286- x = accelerometer.get_x()
287- audio.set_rate(scale(x, (-1000, 1000), (2250, 11000)))
284+ clipped_recording.set_rate(scale(
285+ accelerometer.get_x(),
286+ (-1000, 1000),
287+ (RECORDING_RATE // 2, RECORDING_RATE * 2)
288+ ))
288289 sleep(50)
289290 sleep(100)
0 commit comments