summaryrefslogtreecommitdiff
path: root/shared-bindings/audiomp3
diff options
context:
space:
mode:
authordherrada <dylan.herrada@gmail.com>2020-04-27 17:29:50 -0400
committerdherrada <dylan.herrada@gmail.com>2020-04-27 17:29:50 -0400
commit829da5c12732337cc72f2c089bc72cb437a02e0c (patch)
tree49c17456a88667490208993b6872fddf991526a2 /shared-bindings/audiomp3
parent8330471068c4cba89802c2b0b9a91a60e656c12e (diff)
Added inline pyi to audiomp3
Diffstat (limited to 'shared-bindings/audiomp3')
-rw-r--r--shared-bindings/audiomp3/MP3Decoder.c113
1 files changed, 53 insertions, 60 deletions
diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c
index 224042212..0bb2c8829 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);