@@ -72,6 +72,13 @@ Functions
72
72
73
73
Stops all audio playback.
74
74
75
+ .. py :function :: sound_level()
76
+
77
+ Get the sound pressure level produced by audio currently being played.
78
+
79
+ :return: A representation of the output sound pressure level in the
80
+ range 0 to 255.
81
+
75
82
76
83
Built-in sounds **V2 **
77
84
======================
@@ -251,11 +258,15 @@ AudioFrame
251
258
During playback, increasing the sampling rate speeds up the sound
252
259
and decreasing it slows it down.
253
260
261
+ :param sample_rate: The sample rate to set.
262
+
254
263
.. py :function :: get_rate()
255
264
256
265
(**V2 only **) Return the configured sampling rate for this
257
266
``AudioFrame `` instance.
258
267
268
+ :return: The configured sample rate.
269
+
259
270
.. py :function :: copyfrom(other)
260
271
261
272
Overwrite the data in this ``AudioFrame `` with the data from another
@@ -272,12 +283,13 @@ Technical Details
272
283
273
284
The ``audio.play() `` function can consume an instance or iterable
274
285
(sequence, like list or tuple, or generator) of ``AudioFrame `` instances,
275
- The ``AudioFrame `` default playback rate is 7812 Hz, and the output is a
276
- a PWM signal at 32.5 kHz.
286
+ The ``AudioFrame `` default playback rate is 7812 Hz, and can be configured
287
+ at any point with the ``AudioFrame.set_rate() `` method.
288
+ The ``AudioFrame.set_rate() `` also works while the ``AudioFrame `` is being
289
+ played, which will affect the playback speed.
277
290
278
291
Each ``AudioFrame `` instance is 32 samples by default, but it can be
279
- configured to a different size via constructor and the
280
- ``AudioFrame.set_rate() `` method.
292
+ configured to a different size via constructor parameters.
281
293
282
294
So, for example, playing 32 samples at 7812 Hz takes just over 4 milliseconds
283
295
(1/7812.5 * 32 = 0.004096 = 4096 microseconds).
0 commit comments