diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index cad17ad184..765e0a12dc 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -36,63 +36,63 @@ #include "supervisor/shared/translate.h" //|class I2SOut: -//| """.. currentmodule:: audiobusio +//|""".. currentmodule:: audiobusio //| -//| :class:`I2SOut` -- Output an I2S audio signal -//| ======================================================== +//|:class:`I2SOut` -- Output an I2S audio signal +//|======================================================== //| -//| I2S is used to output an audio signal on an I2S bus.""" -//| def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): -//| """Create a I2SOut object associated with the given pins. +//|I2S is used to output an audio signal on an I2S bus.""" +//|def __init__(self, bit_clock: microcontroller.Pin, word_select: microcontroller.Pin, data: microcontroller.Pin, *, left_justified: bool): +//|"""Create a I2SOut object associated with the given pins. //| -//| :param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin -//| :param ~microcontroller.Pin word_select: The word select (or left/right clock) pin -//| :param ~microcontroller.Pin data: The data pin -//| :param bool left_justified: True when data bits are aligned with the word select clock. False -//| when they are shifted by one to match classic I2S protocol. +//|:param ~microcontroller.Pin bit_clock: The bit clock (or serial clock) pin +//|:param ~microcontroller.Pin word_select: The word select (or left/right clock) pin +//|:param ~microcontroller.Pin data: The data pin +//|:param bool left_justified: True when data bits are aligned with the word select clock. False +//|when they are shifted by one to match classic I2S protocol. //| -//| Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ -//| using `UDA1334 Breakout `_:: +//|Simple 8ksps 440 Hz sine wave on `Metro M0 Express `_ +//|using `UDA1334 Breakout `_:: //| -//| import audiobusio -//| import audiocore -//| import board -//| import array -//| import time -//| import math +//|import audiobusio +//|import audiocore +//|import board +//|import array +//|import time +//|import math //| -//| # Generate one period of sine wave. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//|# Generate one period of sine wave. +//|length = 8000 // 440 +//|sine_wave = array.array("H", [0] * length) +//|for i in range(length): +//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) -//| i2s.play(sine_wave, loop=True) -//| time.sleep(1) -//| i2s.stop() +//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//|i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//|i2s.play(sine_wave, loop=True) +//|time.sleep(1) +//|i2s.stop() //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import audiocore -//| import audiobusio -//| import digitalio +//|import board +//|import audioio +//|import audiocore +//|import audiobusio +//|import digitalio //| //| -//| f = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(f) +//|f = open("cplay-5.1-16bit-16khz.wav", "rb") +//|wav = audiocore.WaveFile(f) //| -//| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) +//|a = audiobusio.I2SOut(board.D1, board.D0, board.D9) //| -//| print("playing") -//| a.play(wav) -//| while a.playing: -//| pass -//| print("stopped")""" -//| ... +//|print("playing") +//|a.play(wav) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_bit_clock, ARG_word_select, ARG_data, ARG_left_justified }; static const mp_arg_t allowed_args[] = { @@ -115,9 +115,9 @@ STATIC mp_obj_t audiobusio_i2sout_make_new(const mp_obj_type_t *type, size_t n_a return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the I2SOut and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the I2SOut and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiobusio_i2sout_deinit(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_i2sout_deinit(self); @@ -130,15 +130,15 @@ STATIC void check_for_deinit(audiobusio_i2sout_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """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 audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_i2sout_deinit(args[0]); @@ -147,14 +147,14 @@ STATIC mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *ar STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__); -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample itself should consist of 8 bit or 16 bit samples.""" -//| ... +//|The sample itself should consist of 8 bit or 16 bit samples.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -173,9 +173,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_play(size_t n_args, const mp_obj_t *pos_ar } MP_DEFINE_CONST_FUN_OBJ_KW(audiobusio_i2sout_play_obj, 1, audiobusio_i2sout_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -184,9 +184,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_stop_obj, audiobusio_i2sout_obj_stop); -//| playing: Any = -//| """True when the audio sample is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when the audio sample is being output. (read-only)""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_get_playing(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -201,9 +201,9 @@ const mp_obj_property_t audiobusio_i2sout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def pause(self, ) -> Any: -//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//| ... +//|def pause(self, ) -> Any: +//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -216,9 +216,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_pause_obj, audiobusio_i2sout_obj_pause); -//| def resume(self, ) -> Any: -//| """Resumes sample playback after :py:func:`pause`.""" -//| ... +//|def resume(self, ) -> Any: +//|"""Resumes sample playback after :py:func:`pause`.""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -231,9 +231,9 @@ STATIC mp_obj_t audiobusio_i2sout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audiobusio_i2sout_resume_obj, audiobusio_i2sout_obj_resume); -//| paused: Any = -//| """True when playback is paused. (read-only)""" -//| ... +//|paused: Any = +//|"""True when playback is paused. (read-only)""" +//|... STATIC mp_obj_t audiobusio_i2sout_obj_get_paused(mp_obj_t self_in) { audiobusio_i2sout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiobusio/PDMIn.c b/shared-bindings/audiobusio/PDMIn.c index b75545ba7b..28ff9a4818 100644 --- a/shared-bindings/audiobusio/PDMIn.c +++ b/shared-bindings/audiobusio/PDMIn.c @@ -36,63 +36,56 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" - - - - - - - //|class PDMIn: -//| """.. currentmodule:: audiobusio +//|""".. currentmodule:: audiobusio //| -//| :class:`PDMIn` -- Record an input PDM audio stream -//| ======================================================== +//|:class:`PDMIn` -- Record an input PDM audio stream +//|======================================================== //| -//| PDMIn can be used to record an input audio signal on a given set of pins.""" +//|PDMIn can be used to record an input audio signal on a given set of pins.""" //| -//| def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): -//| """Create a PDMIn object associated with the given pins. This allows you to -//| record audio signals from the given pins. Individual ports may put further -//| restrictions on the recording parameters. The overall sample rate is -//| determined by `sample_rate` x ``oversample``, and the total must be 1MHz or -//| higher, so `sample_rate` must be a minimum of 16000. +//|def __init__(self, clock_pin: microcontroller.Pin, data_pin: microcontroller.Pin, *, sample_rate: int = 16000, bit_depth: int = 8, mono: bool = True, oversample: int = 64, startup_delay: float = 0.11): +//|"""Create a PDMIn object associated with the given pins. This allows you to +//|record audio signals from the given pins. Individual ports may put further +//|restrictions on the recording parameters. The overall sample rate is +//|determined by `sample_rate` x ``oversample``, and the total must be 1MHz or +//|higher, so `sample_rate` must be a minimum of 16000. //| -//| :param ~microcontroller.Pin clock_pin: The pin to output the clock to -//| :param ~microcontroller.Pin data_pin: The pin to read the data from -//| :param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. -//| Minimum sample_rate is about 16000 Hz. -//| :param int bit_depth: Final number of bits per sample. Must be divisible by 8 -//| :param bool mono: True when capturing a single channel of audio, captures two channels otherwise -//| :param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 -//| :param float startup_delay: seconds to wait after starting microphone clock -//| to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. -//| Must be in range 0.0-1.0 seconds.""" -//| ... +//|:param ~microcontroller.Pin clock_pin: The pin to output the clock to +//|:param ~microcontroller.Pin data_pin: The pin to read the data from +//|:param int sample_rate: Target sample_rate of the resulting samples. Check `sample_rate` for actual value. +//|Minimum sample_rate is about 16000 Hz. +//|:param int bit_depth: Final number of bits per sample. Must be divisible by 8 +//|:param bool mono: True when capturing a single channel of audio, captures two channels otherwise +//|:param int oversample: Number of single bit samples to decimate into a final sample. Must be divisible by 8 +//|:param float startup_delay: seconds to wait after starting microphone clock +//|to allow microphone to turn on. Most require only 0.01s; some require 0.1s. Longer is safer. +//|Must be in range 0.0-1.0 seconds.""" +//|... -//| Record 8-bit unsigned samples to buffer:: +//|Record 8-bit unsigned samples to buffer:: //| -//| import audiobusio -//| import board +//|import audiobusio +//|import board //| -//| # Prep a buffer to record into -//| b = bytearray(200) -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: -//| mic.record(b, len(b)) +//|# Prep a buffer to record into +//|b = bytearray(200) +//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000) as mic: +//|mic.record(b, len(b)) //| -//| Record 16-bit unsigned samples to buffer:: +//|Record 16-bit unsigned samples to buffer:: //| -//| import audiobusio -//| import board +//|import audiobusio +//|import board //| -//| # Prep a buffer to record into. The array interface doesn't allow for -//| # constructing with a set size so we append to it until we have the size -//| # we want. -//| b = array.array("H") -//| for i in range(200): -//| b.append(0) -//| with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: -//| mic.record(b, len(b)) +//|# Prep a buffer to record into. The array interface doesn't allow for +//|# constructing with a set size so we append to it until we have the size +//|# we want. +//|b = array.array("H") +//|for i in range(200): +//|b.append(0) +//|with audiobusio.PDMIn(board.MICROPHONE_CLOCK, board.MICROPHONE_DATA, sample_rate=16000, bit_depth=16) as mic: +//|mic.record(b, len(b)) //| STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_clock_pin, ARG_data_pin, ARG_sample_rate, ARG_bit_depth, ARG_mono, ARG_oversample, ARG_startup_delay }; @@ -145,9 +138,9 @@ STATIC mp_obj_t audiobusio_pdmin_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the PDMIn and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the PDMIn and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiobusio_pdmin_deinit(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiobusio_pdmin_deinit(self); @@ -160,14 +153,14 @@ STATIC void check_for_deinit(audiobusio_pdmin_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """Automatically deinitializes the hardware when exiting a context.""" -//| ... +//|def __exit__(self, ) -> Any: +//|"""Automatically deinitializes the hardware when exiting a context.""" +//|... STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiobusio_pdmin_deinit(args[0]); @@ -176,17 +169,17 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__); -//| def record(self, destination: Any, destination_length: Any) -> Any: -//| """Records destination_length bytes of samples to destination. This is -//| blocking. +//|def record(self, destination: Any, destination_length: Any) -> Any: +//|"""Records destination_length bytes of samples to destination. This is +//|blocking. //| -//| An IOError may be raised when the destination is too slow to record the -//| audio at the given rate. For internal flash, writing all 1s to the file -//| before recording is recommended to speed up writes. +//|An IOError may be raised when the destination is too slow to record the +//|audio at the given rate. For internal flash, writing all 1s to the file +//|before recording is recommended to speed up writes. //| -//| :return: The number of samples recorded. If this is less than ``destination_length``, -//| some samples were missed due to processing time.""" -//| ... +//|:return: The number of samples recorded. If this is less than ``destination_length``, +//|some samples were missed due to processing time.""" +//|... STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destination, mp_obj_t destination_length) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_obj); check_for_deinit(self); @@ -217,10 +210,10 @@ STATIC mp_obj_t audiobusio_pdmin_obj_record(mp_obj_t self_obj, mp_obj_t destinat } MP_DEFINE_CONST_FUN_OBJ_3(audiobusio_pdmin_record_obj, audiobusio_pdmin_obj_record); -//| sample_rate: Any = -//| """The actual sample_rate of the recording. This may not match the constructed -//| sample rate due to internal clock limitations.""" -//| ... +//|sample_rate: Any = +//|"""The actual sample_rate of the recording. This may not match the constructed +//|sample rate due to internal clock limitations.""" +//|... STATIC mp_obj_t audiobusio_pdmin_obj_get_sample_rate(mp_obj_t self_in) { audiobusio_pdmin_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 8df923e6f1..28c345d168 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -37,63 +37,63 @@ #include "supervisor/shared/translate.h" //|class AudioOut: -//| """.. currentmodule:: audioio +//|""".. currentmodule:: audioio //| -//| :class:`AudioOut` -- Output an analog audio signal -//| ======================================================== +//|:class:`AudioOut` -- Output an analog audio signal +//|======================================================== //| -//| AudioOut can be used to output an analog audio signal on a given pin.""" +//|AudioOut can be used to output an analog audio signal on a given pin.""" //| -//| def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): -//| """Create a AudioOut object associated with the given pin(s). This allows you to -//| play audio signals out on the given pin(s). +//|def __init__(self, left_channel: microcontroller.Pin, *, right_channel: microcontroller.Pin = None, quiescent_value: int = 0x8000): +//|"""Create a AudioOut object associated with the given pin(s). This allows you to +//|play audio signals out on the given pin(s). //| -//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to -//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to -//| :param int quiescent_value: The output value when no signal is present. Samples should start -//| and end with this value to prevent audible popping. +//|:param ~microcontroller.Pin left_channel: The pin to output the left channel to +//|:param ~microcontroller.Pin right_channel: The pin to output the right channel to +//|:param int quiescent_value: The output value when no signal is present. Samples should start +//|and end with this value to prevent audible popping. //| -//| Simple 8ksps 440 Hz sin wave:: +//|Simple 8ksps 440 Hz sin wave:: //| -//| import audiocore -//| import audioio -//| import board -//| import array -//| import time -//| import math +//|import audiocore +//|import audioio +//|import board +//|import array +//|import time +//|import math //| -//| # Generate one period of sine wav. -//| length = 8000 // 440 -//| sine_wave = array.array("H", [0] * length) -//| for i in range(length): -//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//|# Generate one period of sine wav. +//|length = 8000 // 440 +//|sine_wave = array.array("H", [0] * length) +//|for i in range(length): +//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop() +//|dac = audioio.AudioOut(board.SPEAKER) +//|sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//|dac.play(sine_wave, loop=True) +//|time.sleep(1) +//|dac.stop() //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import digitalio +//|import board +//|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-5.1-16bit-16khz.wav", "rb") -//| wav = audiocore.WaveFile(data) -//| a = audioio.AudioOut(board.A0) +//|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")""" -//| ... +//|print("playing") +//|a.play(wav) +//|while a.playing: +//|pass +//|print("stopped")""" +//|... STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { @@ -115,9 +115,9 @@ STATIC mp_obj_t audioio_audioout_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the AudioOut and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the AudioOut and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audioio_audioout_deinit(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_audioout_deinit(self); @@ -130,15 +130,15 @@ STATIC void check_for_deinit(audioio_audioout_obj_t *self) { raise_deinited_error(); } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """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_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_audioout_deinit(args[0]); @@ -147,16 +147,16 @@ STATIC mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *arg STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__); -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output -//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit -//| DAC that ignores the lowest 6 bits when playing 16 bit samples.""" -//| ... +//|The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//|resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//|DAC that ignores the lowest 6 bits when playing 16 bit samples.""" +//|... STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -175,9 +175,9 @@ STATIC mp_obj_t audioio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audioio_audioout_play_obj, 1, audioio_audioout_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback and resets to the start of the sample.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback and resets to the start of the sample.""" +//|... STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -186,9 +186,9 @@ STATIC mp_obj_t audioio_audioout_obj_stop(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_stop_obj, audioio_audioout_obj_stop); -//| playing: Any = -//| """True when an audio sample is being output even if `paused`. (read-only)""" -//| ... +//|playing: Any = +//|"""True when an audio sample is being output even if `paused`. (read-only)""" +//|... STATIC mp_obj_t audioio_audioout_obj_get_playing(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -203,9 +203,9 @@ const mp_obj_property_t audioio_audioout_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def pause(self, ) -> Any: -//| """Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" -//| ... +//|def pause(self, ) -> Any: +//|"""Stops playback temporarily while remembering the position. Use `resume` to resume playback.""" +//|... STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -218,9 +218,9 @@ STATIC mp_obj_t audioio_audioout_obj_pause(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_pause_obj, audioio_audioout_obj_pause); -//| def resume(self, ) -> Any: -//| """Resumes sample playback after :py:func:`pause`.""" -//| ... +//|def resume(self, ) -> Any: +//|"""Resumes sample playback after :py:func:`pause`.""" +//|... STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -233,9 +233,9 @@ STATIC mp_obj_t audioio_audioout_obj_resume(mp_obj_t self_in) { } MP_DEFINE_CONST_FUN_OBJ_1(audioio_audioout_resume_obj, audioio_audioout_obj_resume); -//| paused: Any = -//| """True when playback is paused. (read-only)""" -//| ... +//|paused: Any = +//|"""True when playback is paused. (read-only)""" +//|... STATIC mp_obj_t audioio_audioout_obj_get_paused(mp_obj_t self_in) { audioio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiomixer/Mixer.c b/shared-bindings/audiomixer/Mixer.c index 1949f2addd..93b1d3635f 100644 --- a/shared-bindings/audiomixer/Mixer.c +++ b/shared-bindings/audiomixer/Mixer.c @@ -39,49 +39,49 @@ #include "supervisor/shared/translate.h" //|class Mixer: -//| """.. currentmodule:: audiomixer +//|""".. currentmodule:: audiomixer //| -//| :class:`Mixer` -- Mixes one or more audio samples together -//| =========================================================== +//|:class:`Mixer` -- Mixes one or more audio samples together +//|=========================================================== //| -//| Mixer mixes multiple samples into one sample.""" +//|Mixer mixes multiple samples into one sample.""" //| -//| def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): -//| """Create a Mixer object that can mix multiple channels with the same sample rate. -//| Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. +//|def __init__(self, voice_count: int = 2, buffer_size: int = 1024, channel_count: int = 2, bits_per_sample: int = 16, samples_signed: bool = True, sample_rate: int = 8000): +//|"""Create a Mixer object that can mix multiple channels with the same sample rate. +//|Samples are accessed and controlled with the mixer's `audiomixer.MixerVoice` objects. //| -//| :param int voice_count: The maximum number of voices to mix -//| :param int buffer_size: The total size in bytes of the buffers to mix into -//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. -//| :param int bits_per_sample: The bits per sample of the samples being played -//| :param bool samples_signed: Samples are signed (True) or unsigned (False) -//| :param int sample_rate: The sample rate to be used for all samples +//|:param int voice_count: The maximum number of voices to mix +//|:param int buffer_size: The total size in bytes of the buffers to mix into +//|:param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo. +//|:param int bits_per_sample: The bits per sample of the samples being played +//|:param bool samples_signed: Samples are signed (True) or unsigned (False) +//|:param int sample_rate: The sample rate to be used for all samples //| -//| Playing a wave file from flash:: +//|Playing a wave file from flash:: //| -//| import board -//| import audioio -//| import audiocore -//| import audiomixer -//| import digitalio +//|import board +//|import audioio +//|import audiocore +//|import audiomixer +//|import digitalio //| -//| a = audioio.AudioOut(board.A0) -//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) -//| drum = audiocore.WaveFile(open("drum.wav", "rb")) -//| mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, -//| bits_per_sample=16, samples_signed=True) +//|a = audioio.AudioOut(board.A0) +//|music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) +//|drum = audiocore.WaveFile(open("drum.wav", "rb")) +//|mixer = audiomixer.Mixer(voice_count=2, sample_rate=16000, channel_count=1, +//|bits_per_sample=16, samples_signed=True) //| -//| print("playing") -//| # Have AudioOut play our Mixer source -//| a.play(mixer) -//| # Play the first sample voice -//| mixer.voice[0].play(music) -//| while mixer.playing: -//| # Play the second sample voice -//| mixer.voice[1].play(drum) -//| time.sleep(1) -//| print("stopped")""" -//| ... +//|print("playing") +//|# Have AudioOut play our Mixer source +//|a.play(mixer) +//|# Play the first sample voice +//|mixer.voice[0].play(music) +//|while mixer.playing: +//|# Play the second sample voice +//|mixer.voice[1].play(drum) +//|time.sleep(1) +//|print("stopped")""" +//|... STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice_count, ARG_buffer_size, ARG_channel_count, ARG_bits_per_sample, ARG_samples_signed, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -125,9 +125,9 @@ STATIC mp_obj_t audiomixer_mixer_make_new(const mp_obj_type_t *type, size_t n_ar return MP_OBJ_FROM_PTR(self); } -//| def deinit(self, ) -> Any: -//| """Deinitialises the Mixer and releases any hardware resources for reuse.""" -//| ... +//|def deinit(self, ) -> Any: +//|"""Deinitialises the Mixer and releases any hardware resources for reuse.""" +//|... STATIC mp_obj_t audiomixer_mixer_deinit(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audiomixer_mixer_deinit(self); @@ -141,15 +141,15 @@ STATIC void check_for_deinit(audiomixer_mixer_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| """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 audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audiomixer_mixer_deinit(args[0]); @@ -157,9 +157,9 @@ STATIC mp_obj_t audiomixer_mixer_obj___exit__(size_t n_args, const mp_obj_t *arg } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomixer_mixer___exit___obj, 4, 4, audiomixer_mixer_obj___exit__); -//| playing: Any = -//| """True when any voice is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when any voice is being output. (read-only)""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_playing(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -174,9 +174,9 @@ const mp_obj_property_t audiomixer_mixer_playing_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second).""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_sample_rate(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -191,14 +191,14 @@ const mp_obj_property_t audiomixer_mixer_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| voice: Any = -//| """A tuple of the mixer's `audiomixer.MixerVoice` object(s). +//|voice: Any = +//|"""A tuple of the mixer's `audiomixer.MixerVoice` object(s). //| -//| .. code-block:: python +//|.. code-block:: python //| -//| >>> mixer.voice -//| (,)""" -//| ... +//|>>> mixer.voice +//|(,)""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_get_voice(mp_obj_t self_in) { audiomixer_mixer_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); @@ -213,14 +213,14 @@ const mp_obj_property_t audiomixer_mixer_voice_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: -//| """Plays the sample once when loop=False and continuously when loop=True. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, voice: Any = 0, loop: Any = False) -> Any: +//|"""Plays the sample once when loop=False and continuously when loop=True. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. +//|Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiomixer.Mixer`. //| -//| The sample must match the Mixer's encoding settings given in the constructor.""" -//| ... +//|The sample must match the Mixer's encoding settings given in the constructor.""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_voice, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -245,9 +245,9 @@ STATIC mp_obj_t audiomixer_mixer_obj_play(size_t n_args, const mp_obj_t *pos_arg } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixer_play_obj, 1, audiomixer_mixer_obj_play); -//| def stop_voice(self, voice: Any = 0) -> Any: -//| """Stops playback of the sample on the given voice.""" -//| ... +//|def stop_voice(self, voice: Any = 0) -> Any: +//|"""Stops playback of the sample on the given voice.""" +//|... STATIC mp_obj_t audiomixer_mixer_obj_stop_voice(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { diff --git a/shared-bindings/audiomixer/MixerVoice.c b/shared-bindings/audiomixer/MixerVoice.c index e6c750bafa..299600dd14 100644 --- a/shared-bindings/audiomixer/MixerVoice.c +++ b/shared-bindings/audiomixer/MixerVoice.c @@ -38,17 +38,17 @@ #include "supervisor/shared/translate.h" //|class MixerVoice: -//| """.. currentmodule:: audiomixer +//|""".. currentmodule:: audiomixer //| -//| :class:`MixerVoice` -- Voice objects used with Mixer -//| ===================================================== +//|:class:`MixerVoice` -- Voice objects used with Mixer +//|===================================================== //| -//| Used to access and control samples with `audiomixer.Mixer`.""" +//|Used to access and control samples with `audiomixer.Mixer`.""" //| -//| def __init__(self, ): +//|def __init__(self, ): //| -//| """MixerVoice instance object(s) created by `audiomixer.Mixer`.""" -//| ... +//|"""MixerVoice instance object(s) created by `audiomixer.Mixer`.""" +//|... // TODO: support mono or stereo voices STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { audiomixer_mixervoice_obj_t *self = m_new_obj(audiomixer_mixervoice_obj_t); @@ -59,14 +59,14 @@ STATIC mp_obj_t audiomixer_mixervoice_make_new(const mp_obj_type_t *type, size_t return MP_OBJ_FROM_PTR(self); } -//| def play(self, sample: Any, *, loop: Any = False) -> Any: -//| """Plays the sample once when ``loop=False``, and continuously when ``loop=True``. -//| Does not block. Use `playing` to block. +//|def play(self, sample: Any, *, loop: Any = False) -> Any: +//|"""Plays the sample once when ``loop=False``, and continuously when ``loop=True``. +//|Does not block. Use `playing` to block. //| -//| Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. +//|Sample must be an `audiocore.WaveFile`, `audiomixer.Mixer` or `audiocore.RawSample`. //| -//| The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" -//| ... +//|The sample must match the `audiomixer.Mixer`'s encoding settings given in the constructor.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { @@ -83,9 +83,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_play(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_play_obj, 1, audiomixer_mixervoice_obj_play); -//| def stop(self, ) -> Any: -//| """Stops playback of the sample on this voice.""" -//| ... +//|def stop(self, ) -> Any: +//|"""Stops playback of the sample on this voice.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_voice }; static const mp_arg_t allowed_args[] = { @@ -101,9 +101,9 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_stop(size_t n_args, const mp_obj_t *po } MP_DEFINE_CONST_FUN_OBJ_KW(audiomixer_mixervoice_stop_obj, 1, audiomixer_mixervoice_obj_stop); -//| level(): Any = -//| """The volume level of a voice, as a floating point number between 0 and 1.""" -//| ... +//|level(): Any = +//|"""The volume level of a voice, as a floating point number between 0 and 1.""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_get_level(mp_obj_t self_in) { return mp_obj_new_float(common_hal_audiomixer_mixervoice_get_level(self_in)); } @@ -137,9 +137,9 @@ const mp_obj_property_t audiomixer_mixervoice_level_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| playing: Any = -//| """True when this voice is being output. (read-only)""" -//| ... +//|playing: Any = +//|"""True when this voice is being output. (read-only)""" +//|... STATIC mp_obj_t audiomixer_mixervoice_obj_get_playing(mp_obj_t self_in) { audiomixer_mixervoice_obj_t *self = MP_OBJ_TO_PTR(self_in); diff --git a/shared-bindings/audiomp3/MP3Decoder.c b/shared-bindings/audiomp3/MP3Decoder.c index 0bb2c88292..7c011b65f3 100644 --- a/shared-bindings/audiomp3/MP3Decoder.c +++ b/shared-bindings/audiomp3/MP3Decoder.c @@ -35,41 +35,41 @@ #include "supervisor/shared/translate.h" //|class MP3: -//| """.. currentmodule:: audiomp3 +//|""".. 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.""" //| -//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//|def __init__(self, file: typing.BinaryIO, buffer: bytearray): +//|"""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) +//|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 +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); } -//| def deinit(self, ) -> Any: -//| """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); @@ -108,16 +108,15 @@ STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) { } } -//| def __enter__(self, ) -> Any: -//| """No-op used by Context Managers.""" -//| ... +//|def __enter__(self, ) -> Any: +//|"""No-op used by Context Managers.""" +//|... // Provided by context manager helper. -//| def __exit__(self, ) -> Any: -//| -//| """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]); @@ -125,9 +124,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__); -//| file: Any = -//| """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); @@ -155,11 +154,11 @@ const mp_obj_property_t audiomp3_mp3file_file_obj = { -//| 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.""" -//| ... +//|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); @@ -182,9 +181,9 @@ const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| bits_per_sample: Any = -//| """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); @@ -199,9 +198,9 @@ const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| channel_count: Any = -//| """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); @@ -216,9 +215,9 @@ const mp_obj_property_t audiomp3_mp3file_channel_count_obj = { (mp_obj_t)&mp_const_none_obj}, }; -//| rms_level: Any = -//| """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);