diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 2240422127..0bb2c88292 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -34,42 +34,42 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audiomp3 +//|class MP3: +//| """.. currentmodule:: audiomp3 //| -//| :class:`MP3Decoder` -- Load a mp3 file for audio playback -//| ========================================================= +//| :class:`MP3Decoder` -- Load a mp3 file for audio playback +//| ========================================================= //| -//| An object that decodes MP3 files for playback on an audio device. +//| An object that decodes MP3 files for playback on an audio device.""" //| -//| .. class:: MP3(file[, buffer]) +//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. //| -//| 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. +//| :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:: +//| Playing a mp3 file from flash:: //| -//| import board -//| import audiomp3 -//| import audioio -//| import digitalio +//| import board +//| import audiomp3 +//| import audioio +//| import digitalio //| -//| # Required for CircuitPlayground Express -//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) -//| speaker_enable.switch_to_output(value=True) +//| # 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") +//| 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")""" +//| ... 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,10 +92,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); common_hal_audiomp3_mp3file_deinit(self); @@ -109,17 +108,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; common_hal_audiomp3_mp3file_deinit(args[0]); @@ -127,10 +125,9 @@ 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); check_for_deinit(self); @@ -158,12 +155,11 @@ 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 -//| 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 audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) { audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -186,10 +182,9 @@ 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); check_for_deinit(self); @@ -204,10 +199,9 @@ 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); check_for_deinit(self); @@ -222,10 +216,9 @@ 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); check_for_deinit(self);