Skip to content

Commit cca8d00

Browse files
committed
Doc and error messaging changes
1 parent f5a8e3d commit cca8d00

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

locale/circuitpython.pot

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,19 +1957,7 @@ msgid "The length of rgb_pins must be 6, 12, 18, 24, or 30"
19571957
msgstr ""
19581958

19591959
#: shared-module/audiodelays/Echo.c shared-module/audiomixer/MixerVoice.c
1960-
msgid "The sample's bits_per_sample does not match"
1961-
msgstr ""
1962-
1963-
#: shared-module/audiodelays/Echo.c shared-module/audiomixer/MixerVoice.c
1964-
msgid "The sample's channel count does not match"
1965-
msgstr ""
1966-
1967-
#: shared-module/audiodelays/Echo.c shared-module/audiomixer/MixerVoice.c
1968-
msgid "The sample's sample rate does not match"
1969-
msgstr ""
1970-
1971-
#: shared-module/audiodelays/Echo.c shared-module/audiomixer/MixerVoice.c
1972-
msgid "The sample's signedness does not match"
1960+
msgid "The sample's %q does not match"
19731961
msgstr ""
19741962

19751963
#: supervisor/shared/safe_mode.c

shared-bindings/audiodelays/Echo.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "py/objproperty.h"
1515
#include "py/runtime.h"
1616
#include "shared-bindings/util.h"
17+
#include "shared-module/synthio/block.h"
1718

1819
#define DECAY_DEFAULT 0.7f
1920
#define MIX_DEFAULT 0.5f
@@ -39,7 +40,7 @@
3940
//| :param BlockInput delay_ms: The current echo delay
4041
//| :param BlockInput decay: The rate the echo fades. 0.0 = instant; 1.0 = never.
4142
//| :param BlockInput mix: The mix as a ratio of the sample (0.0) to the effect (1.0).
42-
//| :param int buffer_size: The total size in bytes of the buffers to use
43+
//| :param int buffer_size: The total size in bytes of each of the two playback buffers to use
4344
//| :param int sample_rate: The sample rate to be used
4445
//| :param int channel_count: The number of channels the source samples contain. 1 = mono; 2 = stereo.
4546
//| :param int bits_per_sample: The bits per sample of the effect
@@ -225,9 +226,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(audiodelays_echo_get_playing_obj, audiodelays_echo_obj
225226
MP_PROPERTY_GETTER(audiodelays_echo_playing_obj,
226227
(mp_obj_t)&audiodelays_echo_get_playing_obj);
227228

228-
//| def play(
229-
//| self, sample: circuitpython_typing.AudioSample, *, voice: int = 0, loop: bool = False
230-
//| ) -> None:
229+
//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None:
231230
//| """Plays the sample once when loop=False and continuously when loop=True.
232231
//| Does not block. Use `playing` to block.
233232
//|

shared-module/audiodelays/Echo.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,21 @@ void common_hal_audiodelays_echo_play(audiodelays_echo_obj_t *self, mp_obj_t sam
187187
// The get_buffer function will actually process that data
188188

189189
if (audiosample_sample_rate(sample) != self->sample_rate) {
190-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's sample rate does not match"));
190+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_sample_rate);
191191
}
192192
if (audiosample_channel_count(sample) != self->channel_count) {
193-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's channel count does not match"));
193+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_channel_count);
194194
}
195195
if (audiosample_bits_per_sample(sample) != self->bits_per_sample) {
196-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's bits_per_sample does not match"));
196+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_bits_per_sample);
197197
}
198198
bool single_buffer;
199199
bool samples_signed;
200200
uint32_t max_buffer_length;
201201
uint8_t spacing;
202202
audiosample_get_buffer_structure(sample, false, &single_buffer, &samples_signed, &max_buffer_length, &spacing);
203203
if (samples_signed != self->samples_signed) {
204-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's signedness does not match"));
204+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_signedness);
205205
}
206206

207207
self->sample = sample;

shared-module/audiomixer/MixerVoice.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *sel
3232

3333
void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop) {
3434
if (audiosample_sample_rate(sample) != self->parent->sample_rate) {
35-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's sample rate does not match"));
35+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_sample_rate);
3636
}
3737
if (audiosample_channel_count(sample) != self->parent->channel_count) {
38-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's channel count does not match"));
38+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_channel_count);
3939
}
4040
if (audiosample_bits_per_sample(sample) != self->parent->bits_per_sample) {
41-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's bits_per_sample does not match"));
41+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_bits_per_sample);
4242
}
4343
bool single_buffer;
4444
bool samples_signed;
@@ -47,7 +47,7 @@ void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp
4747
audiosample_get_buffer_structure(sample, false, &single_buffer, &samples_signed,
4848
&max_buffer_length, &spacing);
4949
if (samples_signed != self->parent->samples_signed) {
50-
mp_raise_ValueError(MP_ERROR_TEXT("The sample's signedness does not match"));
50+
mp_raise_ValueError_varg(MP_ERROR_TEXT("The sample's %q does not match"), MP_QSTR_signedness);
5151
}
5252
self->sample = sample;
5353
self->loop = loop;

0 commit comments

Comments
 (0)