diff options
| author | dherrada <dylan.herrada@gmail.com> | 2020-04-28 18:56:19 -0400 |
|---|---|---|
| committer | dherrada <dylan.herrada@gmail.com> | 2020-04-28 18:56:19 -0400 |
| commit | aacca615988e29dd58b5083a0199f60f2f40a263 (patch) | |
| tree | 6d1da9177e3bee8517531df459eb5801b8a0daff /shared-bindings/audiocore | |
| parent | c3897d0add969e0280e445a80eff34c6a2681592 (diff) | |
Fixed whitespace on audiocore
Diffstat (limited to 'shared-bindings/audiocore')
| -rw-r--r-- | shared-bindings/audiocore/RawSample.c | 92 | ||||
| -rw-r--r-- | shared-bindings/audiocore/WaveFile.c | 96 |
2 files changed, 94 insertions, 94 deletions
diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index b879b1b97..fdedfe959 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -36,44 +36,44 @@ #include "supervisor/shared/translate.h" //|class RawSample: -//| """.. currentmodule:: audiocore +//|""".. currentmodule:: audiocore //| -//| :class:`RawSample` -- A raw audio sample buffer -//| ======================================================== +//|:class:`RawSample` -- A raw audio sample buffer +//|======================================================== //| -//| An in-memory sound sample""" +//|An in-memory sound sample""" //| -//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): -//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than -//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the -//| first sample will be for channel 1, the second sample will be for channel two, the third for -//| channel 1 and so on. +//|def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000): +//|"""Create a RawSample based on the given buffer of signed values. If channel_count is more than +//|1 then each channel's samples should alternate. In other words, for a two channel buffer, the +//|first sample will be for channel 1, the second sample will be for channel two, the third for +//|channel 1 and so on. //| -//| :param array.array buffer: An `array.array` with samples -//| :param int channel_count: The number of channels in the buffer -//| :param int sample_rate: The desired playback sample rate +//|:param array.array buffer: An `array.array` with samples +//|:param int channel_count: The number of channels in the buffer +//|:param int sample_rate: The desired playback sample rate //| -//| 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)) +//|# 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)) //| -//| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audiocore.RawSample(sine_wave) -//| dac.play(sine_wave, loop=True) -//| time.sleep(1) -//| dac.stop()""" -//| ... +//|dac = audioio.AudioOut(board.SPEAKER) +//|sine_wave = audiocore.RawSample(sine_wave) +//|dac.play(sine_wave, loop=True) +//|time.sleep(1) +//|dac.stop()""" +//|... STATIC mp_obj_t audioio_rawsample_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_buffer, ARG_channel_count, ARG_sample_rate }; static const mp_arg_t allowed_args[] = { @@ -105,9 +105,9 @@ STATIC mp_obj_t audioio_rawsample_make_new(const mp_obj_type_t *type, size_t n_a 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_rawsample_deinit(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); common_hal_audioio_rawsample_deinit(self); @@ -121,15 +121,15 @@ STATIC void check_for_deinit(audioio_rawsample_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 audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_rawsample_deinit(args[0]); @@ -137,12 +137,12 @@ STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *ar } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__); -//| sample_rate: Any = -//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second). -//| When the sample is looped, this can change the pitch output without changing the underlying -//| sample. This will not change the sample rate of any active playback. Call ``play`` again to -//| change it.""" -//| ... +//|sample_rate: Any = +//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second). +//|When the sample is looped, this can change the pitch output without changing the underlying +//|sample. This will not change the sample rate of any active playback. Call ``play`` again to +//|change it.""" +//|... STATIC mp_obj_t audioio_rawsample_obj_get_sample_rate(mp_obj_t self_in) { audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index f57e1f877..9116e71f0 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -34,42 +34,42 @@ #include "supervisor/shared/translate.h" //|class WaveFile: -//| """.. currentmodule:: audiocore +//|""".. 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.""" -//| def __init__(self, file: typing.BinaryIO, buffer: bytearray): -//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`. +//|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`. //| -//| :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. +//|: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:: +//|Playing a wave file from flash:: //| -//| import board -//| import audiocore -//| import audioio -//| import digitalio +//|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) +//|# 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_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); @@ -92,9 +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); } -//| def deinit(self, ) -> Any: -//| """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); @@ -108,15 +108,15 @@ STATIC void check_for_deinit(audioio_wavefile_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 audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; common_hal_audioio_wavefile_deinit(args[0]); @@ -124,11 +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__); -//| 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 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); @@ -151,9 +151,9 @@ const mp_obj_property_t audioio_wavefile_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 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); @@ -168,9 +168,9 @@ const mp_obj_property_t audioio_wavefile_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 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); |
