Skip to content

Commit 17df238

Browse files
committed
synthio: doc fixes, rename BendType to BendMode
1 parent 23baf02 commit 17df238

File tree

5 files changed

+17
-12
lines changed

5 files changed

+17
-12
lines changed

shared-bindings/synthio/Note.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const mp_arg_t note_properties[] = {
5959
//| tremolo_rate: float = 0.0,
6060
//| bend_depth: float = 0.0,
6161
//| bend_rate: float = 0.0,
62-
//| bend_mode: BendMode = BendMode.VIBRATO,
62+
//| bend_mode: "BendMode" = BendMode.VIBRATO,
6363
//| ) -> None:
6464
//| """Construct a Note object, with a frequency in Hz, and optional panning, waveform, envelope, tremolo (volume change) and bend (frequency change).
6565
//|
@@ -270,7 +270,7 @@ MP_PROPERTY_GETSET(synthio_note_envelope_obj,
270270
//| ring_frequency: float
271271
//| """The ring frequency of the note, in Hz. Zero disables.
272272
//|
273-
//| For ring to take effect, both ring_frequency and ring_wavefor must be set."""
273+
//| For ring to take effect, both ``ring_frequency`` and ``ring_waveform`` must be set."""
274274
STATIC mp_obj_t synthio_note_get_ring_frequency(mp_obj_t self_in) {
275275
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);
276276
return mp_obj_new_float(common_hal_synthio_note_get_ring_frequency(self));
@@ -290,7 +290,7 @@ MP_PROPERTY_GETSET(synthio_note_ring_frequency_obj,
290290
//| ring_waveform: Optional[ReadableBuffer]
291291
//| """The ring waveform of this note. Setting the ring_waveform to a buffer of a different size resets the note's phase.
292292
//|
293-
//| For ring to take effect, both ring_frequency and ring_wavefor must be set."""
293+
//| For ring to take effect, both ``ring_frequency`` and ``ring_waveform`` must be set."""
294294
//|
295295
STATIC mp_obj_t synthio_note_get_ring_waveform(mp_obj_t self_in) {
296296
synthio_note_obj_t *self = MP_OBJ_TO_PTR(self_in);

shared-bindings/synthio/__init__.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,36 +289,41 @@ MP_DEFINE_CONST_FUN_OBJ_1(synthio_onevo_to_hz_obj, onevo_to_hz);
289289
MAKE_ENUM_VALUE(synthio_bend_mode_type, bend_mode, STATIC, SYNTHIO_BEND_MODE_STATIC);
290290
MAKE_ENUM_VALUE(synthio_bend_mode_type, bend_mode, VIBRATO, SYNTHIO_BEND_MODE_VIBRATO);
291291
MAKE_ENUM_VALUE(synthio_bend_mode_type, bend_mode, SWEEP, SYNTHIO_BEND_MODE_SWEEP);
292+
MAKE_ENUM_VALUE(synthio_bend_mode_type, bend_mode, SWEEP_IN, SYNTHIO_BEND_MODE_SWEEP_IN);
292293

293294
//|
294-
//| class BendType:
295+
//| class BendMode:
295296
//| """Controls the way the ``Note.pitch_bend_depth`` and ``Note.pitch_bend_rate`` properties are interpreted."""
296297
//|
297298
//| STATIC: object
298299
//| """The Note's pitch is modified by its ``pitch_bend_depth``. ``pitch_bend_rate`` is ignored."""
299300
//|
300301
//| VIBRATO: object
301-
//| """The Note's pitch varies by ``±pitch_bend_depth` at a rate of ``pitch_bend_rate``Hz."""
302+
//| """The Note's pitch varies by ``±pitch_bend_depth`` at a rate of ``pitch_bend_rate`` Hz."""
302303
//|
303304
//| SWEEP: object
304305
//| """The Note's pitch starts at ``Note.frequency`` then sweeps up or down by ``pitch_bend_depth`` over ``1/pitch_bend_rate`` seconds."""
305306
//|
307+
//| SWEEP_IN: object
308+
//| """The Note's pitch sweep is the reverse of ``SWEEP`` mode, starting at the bent pitch and arriving at the tuned pitch."""
309+
//|
306310
MAKE_ENUM_MAP(synthio_bend_mode) {
307311
MAKE_ENUM_MAP_ENTRY(bend_mode, STATIC),
308312
MAKE_ENUM_MAP_ENTRY(bend_mode, VIBRATO),
309313
MAKE_ENUM_MAP_ENTRY(bend_mode, SWEEP),
314+
MAKE_ENUM_MAP_ENTRY(bend_mode, SWEEP_IN),
310315
};
311316

312317
STATIC MP_DEFINE_CONST_DICT(synthio_bend_mode_locals_dict, synthio_bend_mode_locals_table);
313318

314319
MAKE_PRINTER(synthio, synthio_bend_mode);
315320

316-
MAKE_ENUM_TYPE(synthio, BendType, synthio_bend_mode);
321+
MAKE_ENUM_TYPE(synthio, BendMode, synthio_bend_mode);
317322

318323

319324
STATIC const mp_rom_map_elem_t synthio_module_globals_table[] = {
320325
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_synthio) },
321-
{ MP_ROM_QSTR(MP_QSTR_BendType), MP_ROM_PTR(&synthio_bend_mode_type) },
326+
{ MP_ROM_QSTR(MP_QSTR_BendMode), MP_ROM_PTR(&synthio_bend_mode_type) },
322327
{ MP_ROM_QSTR(MP_QSTR_MidiTrack), MP_ROM_PTR(&synthio_miditrack_type) },
323328
{ MP_ROM_QSTR(MP_QSTR_Note), MP_ROM_PTR(&synthio_note_type) },
324329
{ MP_ROM_QSTR(MP_QSTR_Synthesizer), MP_ROM_PTR(&synthio_synthesizer_type) },

tests/circuitpython-manual/synthio/note/code.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def synthesize6(synth):
116116
tremolo_rate=1.5,
117117
bend_depth=-5 / 12,
118118
bend_rate=1 / 2,
119-
bend_mode=synthio.BendType.SWEEP,
119+
bend_mode=synthio.BendMode.SWEEP,
120120
waveform=sine,
121121
envelope=envelope,
122122
)

tests/circuitpython-manual/synthio/note/noise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def synthesize(synth):
3737
frequency=synthio.midi_to_hz(1 + i),
3838
waveform=noise,
3939
envelope=envelope,
40-
bend_mode=synthio.BendType.SWEEP,
40+
bend_mode=synthio.BendMode.SWEEP,
4141
bend_depth=random.choice((-1, 1)),
4242
bend_rate=randf(4, 12),
4343
)

tests/circuitpython/synthesizer_note.py.exp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
()
22
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
3-
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendType.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None),)
3+
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendMode.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None),)
44
[-16383, -16383, -16383, -16383, 16383, 16383, 16383, 16383, 16383, -16383, -16383, -16383, -16383, -16383, 16383, 16383, 16383, 16383, 16383, -16383, -16383, -16383, -16383, -16383]
5-
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendType.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None), Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendType.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None))
5+
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendMode.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None), Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendMode.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None))
66
[0, 0, 0, 0, 0, 0, 0, 0, 28045, 0, 0, 0, 0, -28046, 0, 0, 0, 0, 28045, 0, 0, 0, 0, -28046]
7-
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendType.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None),)
7+
(Note(frequency=830.6076004423605, panning=0.0, tremolo_rate=0.0, tremolo_depth=0.0, bend_rate=0.0, bend_depth=0.0, bend_mode=synthio.BendMode.VIBRATO, waveform=None, envelope=None, ring_frequency=0.0, ring_waveform=None),)
88
[0, 0, 0, 28045, 0, 0, 0, 0, 0, 0, 0, 0, 28045, 0, 0, 0, 0, -28046, 0, 0, 0, 0, 28045, 0]
99
(-5242, 5242)
1010
(-10485, 10484)

0 commit comments

Comments
 (0)