Skip to content

Commit aacca61

Browse files
committed
Fixed whitespace on audiocore
1 parent c3897d0 commit aacca61

File tree

2 files changed

+94
-94
lines changed

2 files changed

+94
-94
lines changed

shared-bindings/audiocore/RawSample.c

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -36,44 +36,44 @@
3636
#include "supervisor/shared/translate.h"
3737

3838
//|class RawSample:
39-
//| """.. currentmodule:: audiocore
39+
//|""".. currentmodule:: audiocore
4040
//|
41-
//| :class:`RawSample` -- A raw audio sample buffer
42-
//| ========================================================
41+
//|:class:`RawSample` -- A raw audio sample buffer
42+
//|========================================================
4343
//|
44-
//| An in-memory sound sample"""
44+
//|An in-memory sound sample"""
4545
//|
46-
//| def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000):
47-
//| """Create a RawSample based on the given buffer of signed values. If channel_count is more than
48-
//| 1 then each channel's samples should alternate. In other words, for a two channel buffer, the
49-
//| first sample will be for channel 1, the second sample will be for channel two, the third for
50-
//| channel 1 and so on.
46+
//|def __init__(self, buffer: array.array, *, channel_count: int = 1, sample_rate: int = 8000):
47+
//|"""Create a RawSample based on the given buffer of signed values. If channel_count is more than
48+
//|1 then each channel's samples should alternate. In other words, for a two channel buffer, the
49+
//|first sample will be for channel 1, the second sample will be for channel two, the third for
50+
//|channel 1 and so on.
5151
//|
52-
//| :param array.array buffer: An `array.array` with samples
53-
//| :param int channel_count: The number of channels in the buffer
54-
//| :param int sample_rate: The desired playback sample rate
52+
//|:param array.array buffer: An `array.array` with samples
53+
//|:param int channel_count: The number of channels in the buffer
54+
//|:param int sample_rate: The desired playback sample rate
5555
//|
56-
//| Simple 8ksps 440 Hz sin wave::
56+
//|Simple 8ksps 440 Hz sin wave::
5757
//|
58-
//| import audiocore
59-
//| import audioio
60-
//| import board
61-
//| import array
62-
//| import time
63-
//| import math
58+
//|import audiocore
59+
//|import audioio
60+
//|import board
61+
//|import array
62+
//|import time
63+
//|import math
6464
//|
65-
//| # Generate one period of sine wav.
66-
//| length = 8000 // 440
67-
//| sine_wave = array.array("h", [0] * length)
68-
//| for i in range(length):
69-
//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15))
65+
//|# Generate one period of sine wav.
66+
//|length = 8000 // 440
67+
//|sine_wave = array.array("h", [0] * length)
68+
//|for i in range(length):
69+
//|sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15))
7070
//|
71-
//| dac = audioio.AudioOut(board.SPEAKER)
72-
//| sine_wave = audiocore.RawSample(sine_wave)
73-
//| dac.play(sine_wave, loop=True)
74-
//| time.sleep(1)
75-
//| dac.stop()"""
76-
//| ...
71+
//|dac = audioio.AudioOut(board.SPEAKER)
72+
//|sine_wave = audiocore.RawSample(sine_wave)
73+
//|dac.play(sine_wave, loop=True)
74+
//|time.sleep(1)
75+
//|dac.stop()"""
76+
//|...
7777
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) {
7878
enum { ARG_buffer, ARG_channel_count, ARG_sample_rate };
7979
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
105105
return MP_OBJ_FROM_PTR(self);
106106
}
107107

108-
//| def deinit(self, ) -> Any:
109-
//| """Deinitialises the AudioOut and releases any hardware resources for reuse."""
110-
//| ...
108+
//|def deinit(self, ) -> Any:
109+
//|"""Deinitialises the AudioOut and releases any hardware resources for reuse."""
110+
//|...
111111
STATIC mp_obj_t audioio_rawsample_deinit(mp_obj_t self_in) {
112112
audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in);
113113
common_hal_audioio_rawsample_deinit(self);
@@ -121,28 +121,28 @@ STATIC void check_for_deinit(audioio_rawsample_obj_t *self) {
121121
}
122122
}
123123

124-
//| def __enter__(self, ) -> Any:
125-
//| """No-op used by Context Managers."""
126-
//| ...
124+
//|def __enter__(self, ) -> Any:
125+
//|"""No-op used by Context Managers."""
126+
//|...
127127
// Provided by context manager helper.
128128

129-
//| def __exit__(self, ) -> Any:
130-
//| """Automatically deinitializes the hardware when exiting a context. See
131-
//| :ref:`lifetime-and-contextmanagers` for more info."""
132-
//| ...
129+
//|def __exit__(self, ) -> Any:
130+
//|"""Automatically deinitializes the hardware when exiting a context. See
131+
//|:ref:`lifetime-and-contextmanagers` for more info."""
132+
//|...
133133
STATIC mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) {
134134
(void)n_args;
135135
common_hal_audioio_rawsample_deinit(args[0]);
136136
return mp_const_none;
137137
}
138138
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__);
139139

140-
//| sample_rate: Any =
141-
//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).
142-
//| When the sample is looped, this can change the pitch output without changing the underlying
143-
//| sample. This will not change the sample rate of any active playback. Call ``play`` again to
144-
//| change it."""
145-
//| ...
140+
//|sample_rate: Any =
141+
//|"""32 bit value that dictates how quickly samples are played in Hertz (cycles per second).
142+
//|When the sample is looped, this can change the pitch output without changing the underlying
143+
//|sample. This will not change the sample rate of any active playback. Call ``play`` again to
144+
//|change it."""
145+
//|...
146146
STATIC mp_obj_t audioio_rawsample_obj_get_sample_rate(mp_obj_t self_in) {
147147
audioio_rawsample_obj_t *self = MP_OBJ_TO_PTR(self_in);
148148
check_for_deinit(self);

shared-bindings/audiocore/WaveFile.c

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,42 @@
3434
#include "supervisor/shared/translate.h"
3535

3636
//|class WaveFile:
37-
//| """.. currentmodule:: audiocore
37+
//|""".. currentmodule:: audiocore
3838
//|
39-
//| :class:`WaveFile` -- Load a wave file for audio playback
40-
//| ========================================================
39+
//|:class:`WaveFile` -- Load a wave file for audio playback
40+
//|========================================================
4141
//|
42-
//| A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must
43-
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
44-
//| an internal buffer."""
45-
//| def __init__(self, file: typing.BinaryIO, buffer: bytearray):
46-
//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
42+
//|A .wav file prepped for audio playback. Only mono and stereo files are supported. Samples must
43+
//|be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
44+
//|an internal buffer."""
45+
//|def __init__(self, file: typing.BinaryIO, buffer: bytearray):
46+
//|"""Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
4747
//|
48-
//| :param typing.BinaryIO file: Already opened wave file
49-
//| :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.
48+
//|:param typing.BinaryIO file: Already opened wave file
49+
//|: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.
5050
//|
5151
//|
52-
//| Playing a wave file from flash::
52+
//|Playing a wave file from flash::
5353
//|
54-
//| import board
55-
//| import audiocore
56-
//| import audioio
57-
//| import digitalio
54+
//|import board
55+
//|import audiocore
56+
//|import audioio
57+
//|import digitalio
5858
//|
59-
//| # Required for CircuitPlayground Express
60-
//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
61-
//| speaker_enable.switch_to_output(value=True)
59+
//|# Required for CircuitPlayground Express
60+
//|speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
61+
//|speaker_enable.switch_to_output(value=True)
6262
//|
63-
//| data = open("cplay-5.1-16bit-16khz.wav", "rb")
64-
//| wav = audiocore.WaveFile(data)
65-
//| a = audioio.AudioOut(board.A0)
63+
//|data = open("cplay-5.1-16bit-16khz.wav", "rb")
64+
//|wav = audiocore.WaveFile(data)
65+
//|a = audioio.AudioOut(board.A0)
6666
//|
67-
//| print("playing")
68-
//| a.play(wav)
69-
//| while a.playing:
70-
//| pass
71-
//| print("stopped")"""
72-
//| ...
67+
//|print("playing")
68+
//|a.play(wav)
69+
//|while a.playing:
70+
//|pass
71+
//|print("stopped")"""
72+
//|...
7373
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) {
7474
mp_arg_check_num(n_args, kw_args, 1, 2, false);
7575

@@ -92,9 +92,9 @@ STATIC mp_obj_t audioio_wavefile_make_new(const mp_obj_type_t *type, size_t n_ar
9292
return MP_OBJ_FROM_PTR(self);
9393
}
9494

95-
//| def deinit(self, ) -> Any:
96-
//| """Deinitialises the WaveFile and releases all memory resources for reuse."""
97-
//| ...
95+
//|def deinit(self, ) -> Any:
96+
//|"""Deinitialises the WaveFile and releases all memory resources for reuse."""
97+
//|...
9898
STATIC mp_obj_t audioio_wavefile_deinit(mp_obj_t self_in) {
9999
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
100100
common_hal_audioio_wavefile_deinit(self);
@@ -108,27 +108,27 @@ STATIC void check_for_deinit(audioio_wavefile_obj_t *self) {
108108
}
109109
}
110110

111-
//| def __enter__(self, ) -> Any:
112-
//| """No-op used by Context Managers."""
113-
//| ...
111+
//|def __enter__(self, ) -> Any:
112+
//|"""No-op used by Context Managers."""
113+
//|...
114114
// Provided by context manager helper.
115115

116-
//| def __exit__(self, ) -> Any:
117-
//| """Automatically deinitializes the hardware when exiting a context. See
118-
//| :ref:`lifetime-and-contextmanagers` for more info."""
119-
//| ...
116+
//|def __exit__(self, ) -> Any:
117+
//|"""Automatically deinitializes the hardware when exiting a context. See
118+
//|:ref:`lifetime-and-contextmanagers` for more info."""
119+
//|...
120120
STATIC mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) {
121121
(void)n_args;
122122
common_hal_audioio_wavefile_deinit(args[0]);
123123
return mp_const_none;
124124
}
125125
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__);
126126

127-
//| sample_rate: Any =
128-
//| """32 bit value that dictates how quickly samples are loaded into the DAC
129-
//| in Hertz (cycles per second). When the sample is looped, this can change
130-
//| the pitch output without changing the underlying sample."""
131-
//| ...
127+
//|sample_rate: Any =
128+
//|"""32 bit value that dictates how quickly samples are loaded into the DAC
129+
//|in Hertz (cycles per second). When the sample is looped, this can change
130+
//|the pitch output without changing the underlying sample."""
131+
//|...
132132
STATIC mp_obj_t audioio_wavefile_obj_get_sample_rate(mp_obj_t self_in) {
133133
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
134134
check_for_deinit(self);
@@ -151,9 +151,9 @@ const mp_obj_property_t audioio_wavefile_sample_rate_obj = {
151151
(mp_obj_t)&mp_const_none_obj},
152152
};
153153

154-
//| bits_per_sample: Any =
155-
//| """Bits per sample. (read only)"""
156-
//| ...
154+
//|bits_per_sample: Any =
155+
//|"""Bits per sample. (read only)"""
156+
//|...
157157
STATIC mp_obj_t audioio_wavefile_obj_get_bits_per_sample(mp_obj_t self_in) {
158158
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
159159
check_for_deinit(self);
@@ -168,9 +168,9 @@ const mp_obj_property_t audioio_wavefile_bits_per_sample_obj = {
168168
(mp_obj_t)&mp_const_none_obj},
169169
};
170170

171-
//| channel_count: Any =
172-
//| """Number of audio channels. (read only)"""
173-
//| ...
171+
//|channel_count: Any =
172+
//|"""Number of audio channels. (read only)"""
173+
//|...
174174
STATIC mp_obj_t audioio_wavefile_obj_get_channel_count(mp_obj_t self_in) {
175175
audioio_wavefile_obj_t *self = MP_OBJ_TO_PTR(self_in);
176176
check_for_deinit(self);

0 commit comments

Comments
 (0)