Skip to content

Commit 03abc62

Browse files
committed
synthio: note: fix assigning bend & tremolo coefficients dynamically
1 parent 522c5a9 commit 03abc62

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

shared-module/synthio/Note.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mp_float_t common_hal_synthio_note_get_tremolo_depth(synthio_note_obj_t *self) {
8585
void common_hal_synthio_note_set_tremolo_depth(synthio_note_obj_t *self, mp_float_t value_in) {
8686
mp_float_t val = mp_arg_validate_float_range(value_in, 0, 1, MP_QSTR_tremolo_depth);
8787
self->tremolo_descr.amplitude = val;
88-
self->tremolo_state.amplitude_scaled = round_float_to_int(val * 32767);
88+
self->tremolo_state.amplitude_scaled = round_float_to_int(val * 32768);
8989
}
9090

9191
mp_float_t common_hal_synthio_note_get_tremolo_rate(synthio_note_obj_t *self) {
@@ -96,7 +96,7 @@ void common_hal_synthio_note_set_tremolo_rate(synthio_note_obj_t *self, mp_float
9696
mp_float_t val = mp_arg_validate_float_range(value_in, 0, 60, MP_QSTR_tremolo_rate);
9797
self->tremolo_descr.frequency = val;
9898
if (self->sample_rate != 0) {
99-
self->tremolo_state.dds = synthio_frequency_convert_float_to_dds(val, self->sample_rate);
99+
self->tremolo_state.dds = synthio_frequency_convert_float_to_dds(val * 65536, self->sample_rate);
100100
}
101101
}
102102

@@ -107,7 +107,7 @@ mp_float_t common_hal_synthio_note_get_bend_depth(synthio_note_obj_t *self) {
107107
void common_hal_synthio_note_set_bend_depth(synthio_note_obj_t *self, mp_float_t value_in) {
108108
mp_float_t val = mp_arg_validate_float_range(value_in, -1, 1, MP_QSTR_bend_depth);
109109
self->bend_descr.amplitude = val;
110-
self->bend_state.amplitude_scaled = round_float_to_int(val * 32767);
110+
self->bend_state.amplitude_scaled = round_float_to_int(val * 32768);
111111
}
112112

113113
mp_float_t common_hal_synthio_note_get_bend_rate(synthio_note_obj_t *self) {
@@ -127,7 +127,7 @@ void common_hal_synthio_note_set_bend_rate(synthio_note_obj_t *self, mp_float_t
127127
mp_float_t val = mp_arg_validate_float_range(value_in, 0, 60, MP_QSTR_bend_rate);
128128
self->bend_descr.frequency = val;
129129
if (self->sample_rate != 0) {
130-
self->bend_state.dds = synthio_frequency_convert_float_to_dds(val, self->sample_rate);
130+
self->bend_state.dds = synthio_frequency_convert_float_to_dds(val * 65536, self->sample_rate);
131131
}
132132
}
133133

0 commit comments

Comments
 (0)