summaryrefslogtreecommitdiff
path: root/shared-bindings/audiocore/WaveFile.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared-bindings/audiocore/WaveFile.c')
-rw-r--r--shared-bindings/audiocore/WaveFile.c105
1 files changed, 49 insertions, 56 deletions
diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c
index 178d2a139..f57e1f877 100644
--- a/shared-bindings/audiocore/WaveFile.c
+++ b/shared-bindings/audiocore/WaveFile.c
@@ -33,44 +33,43 @@
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
-//| .. currentmodule:: audiocore
+//|class WaveFile:
+//| """.. currentmodule:: audiocore
//|
-//| :class:`WaveFile` -- Load a wave file for audio playback
-//| ========================================================
+//| :class:`WaveFile` -- Load a wave file for audio playback
+//| ========================================================
//|
-//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must
-//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
-//| an internal buffer.
+//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must
+//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
+//| an internal buffer."""
+//| def __init__(self, file: typing.BinaryIO, buffer: bytearray):
+//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
-//| .. class:: WaveFile(file[, buffer])
+//| :param typing.BinaryIO file: Already opened wave file
+//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally.
//|
-//| Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
-//| :param typing.BinaryIO file: Already opened wave file
-//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two 512 byte buffers are allocated internally.
+//| Playing a wave file from flash::
//|
+//| import board
+//| import audiocore
+//| import audioio
+//| import digitalio
//|
-//| Playing a wave file from flash::
+//| # Required for CircuitPlayground Express
+//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
+//| speaker_enable.switch_to_output(value=True)
//|
-//| import board
-//| import audiocore
-//| import audioio
-//| import digitalio
-//|
-//| # Required for CircuitPlayground Express
-//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
-//| speaker_enable.switch_to_output(value=True)
-//|
-//| data = open("cplay-5.1-16bit-16khz.wav", "rb")
-//| wav = audiocore.WaveFile(data)
-//| a = audioio.AudioOut(board.A0)
-//|
-//| print("playing")
-//| a.play(wav)
-//| while a.playing:
-//| pass
-//| print("stopped")
+//| data = open("cplay-5.1-16bit-16khz.wav", "rb")
+//| wav = audiocore.WaveFile(data)
+//| a = audioio.AudioOut(board.A0)
//|
+//| print("playing")
+//| a.play(wav)
+//| while a.playing:
+//| pass
+//| print("stopped")"""
+//| ...
STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 1, 2, false);
@@ -93,10 +92,9 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| .. method:: deinit()
-//|
-//| Deinitialises the WaveFile and releases all memory resources for reuse.
-//|
+//| def deinit(self, ) -> Any:
+//| """Deinitialises the WaveFile and releases all memory resources for reuse."""
+//| ...
STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) {
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audioio_wavefile_deinit(self);
@@ -110,17 +108,15 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) {
}
}
-//| .. method:: __enter__()
-//|
-//| No-op used by Context Managers.
-//|
+//| def __enter__(self, ) -> Any:
+//| """No-op used by Context Managers."""
+//| ...
// Provided by context manager helper.
-//| .. method:: __exit__()
-//|
-//| Automatically deinitializes the hardware when exiting a context. See
-//| :ref:`lifetime-and-contextmanagers` for more info.
-//|
+//| def __exit__(self, ) -> Any:
+//| """Automatically deinitializes the hardware when exiting a context. See
+//| :ref:`lifetime-and-contextmanagers` for more info."""
+//| ...
STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
common_hal_audioio_wavefile_deinit(args[0]);
@@ -128,12 +124,11 @@ STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__);
-//| .. attribute:: sample_rate
-//|
-//| 32 bit value that dictates how quickly samples are loaded into the DAC
-//| in Hertz (cycles per second). When the sample is looped, this can change
-//| the pitch output without changing the underlying sample.
-//|
+//| sample_rate: Any =
+//| """32 bit value that dictates how quickly samples are loaded into the DAC
+//| in Hertz (cycles per second). When the sample is looped, this can change
+//| the pitch output without changing the underlying sample."""
+//| ...
STATIC mp_obj_t audioio_wavefile_obj_get_sample_rate(mp_obj_t self_in) {
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
@@ -156,10 +151,9 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| .. attribute:: bits_per_sample
-//|
-//| Bits per sample. (read only)
-//|
+//| bits_per_sample: Any =
+//| """Bits per sample. (read only)"""
+//| ...
STATIC mp_obj_t audioio_wavefile_obj_get_bits_per_sample(mp_obj_t self_in) {
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
@@ -174,10 +168,9 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| .. attribute:: channel_count
-//|
-//| Number of audio channels. (read only)
-//|
+//| channel_count: Any =
+//| """Number of audio channels. (read only)"""
+//| ...
STATIC mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) {
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);