summaryrefslogtreecommitdiff
path: root/shared-bindings/audiomp3/MP3Decoder.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared-bindings/audiomp3/MP3Decoder.c')
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.c96
1 files changed, 44 insertions, 52 deletions
diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c
index 224042212..e6d48e32c 100644
--- a/shared-bindings/audiomp3/MP3Decoder.c
+++ b/shared-bindings/audiomp3/MP3Decoder.c
@@ -34,41 +34,38 @@
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
-//| .. currentmodule:: audiomp3
+//| class MP3:
+//| """Load a mp3 file for audio playback"""
//|
-//| :class:`MP3Decoder` -- Load a mp3 file for audio playback
-//| =========================================================
+//| def __init__(self, file: typing.BinaryIO, buffer: bytearray):
//|
-//| An object that decodes MP3 files for playback on an audio device.
+//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
-//| .. class:: MP3(file[, buffer])
+//| :param typing.BinaryIO file: Already opened mp3 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 buffers are allocated internally. The specific buffer size required depends on the mp3 file.
//|
-//| Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
-//| :param typing.BinaryIO file: Already opened mp3 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 buffers are allocated internally. The specific buffer size required depends on the mp3 file.
+//| Playing a mp3 file from flash::
//|
+//| import board
+//| import audiomp3
+//| import audioio
+//| import digitalio
//|
-//| Playing a mp3 file from flash::
+//| # Required for CircuitPlayground Express
+//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
+//| speaker_enable.switch_to_output(value=True)
//|
-//| import board
-//| import audiomp3
-//| import audioio
-//| import digitalio
+//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb")
+//| mp3 = audiomp3.MP3Decoder(data)
+//| a = audioio.AudioOut(board.A0)
//|
-//| # Required for CircuitPlayground Express
-//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
-//| speaker_enable.switch_to_output(value=True)
-//|
-//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb")
-//| mp3 = audiomp3.MP3Decoder(data)
-//| a = audioio.AudioOut(board.A0)
-//|
-//| print("playing")
-//| a.play(mp3)
-//| while a.playing:
-//| pass
-//| print("stopped")
+//| print("playing")
+//| a.play(mp3)
+//| while a.playing:
+//| pass
+//| print("stopped")"""
+//| ...
//|
STATIC mp_obj_t audiomp3_mp3file_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);
@@ -92,9 +89,9 @@ STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_ar
return MP_OBJ_FROM_PTR(self);
}
-//| .. method:: deinit()
-//|
-//| Deinitialises the MP3 and releases all memory resources for reuse.
+//| def deinit(self, ) -> Any:
+//| """Deinitialises the MP3 and releases all memory resources for reuse."""
+//| ...
//|
STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -109,16 +106,16 @@ STATIC void check_for_deinit(audiomp3_mp3file_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 audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
@@ -127,9 +124,8 @@ STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *arg
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__);
-//| .. attribute:: file
-//|
-//| File to play back.
+//| file: Any = ...
+//| """File to play back."""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_file(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -158,11 +154,10 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = {
-//| .. attribute:: sample_rate
-//|
-//| 32 bit value that dictates how quickly samples are loaded into the DAC
+//| 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.
+//| the pitch output without changing the underlying sample."""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -186,9 +181,8 @@ const mp_obj_property_t audiomp3_mp3file_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 audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -204,9 +198,8 @@ const mp_obj_property_t audiomp3_mp3file_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 audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
@@ -222,9 +215,8 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = {
(mp_obj_t)&mp_const_none_obj},
};
-//| .. attribute:: rms_level
-//|
-//| The RMS audio level of a recently played moment of audio. (read only)
+//| rms_level: Any = ...
+//| """The RMS audio level of a recently played moment of audio. (read only)"""
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_rms_level(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);