Skip to content

Commit 8908056

Browse files
committed
synthio: Fix release time of zero-sustain envelopes
When there's no sustain, the release step needs to be calculated from the attack level, not the sustain level. Otherwise, contrary to intent, this leads to the actual release taking a loooonnngg time.
1 parent 095e020 commit 8908056

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

shared-bindings/synthio/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static const mp_arg_t envelope_properties[] = {
8080
//|
8181
//| :param float attack_time: The time in seconds it takes to ramp from 0 volume to attack_volume
8282
//| :param float decay_time: The time in seconds it takes to ramp from attack_volume to sustain_volume
83-
//| :param float release_time: The time in seconds it takes to ramp from sustain_volume to release_volume. When a note is released before it has reached the sustain phase, the release is done with the same slope indicated by ``release_time`` and ``sustain_level``
83+
//| :param float release_time: The time in seconds it takes to ramp from sustain_volume to release_volume. When a note is released before it has reached the sustain phase, the release is done with the same slope indicated by ``release_time`` and ``sustain_level``. If the ``sustain_level`` is ``0.0`` then the release slope calculations use the ``attack_level`` instead.
8484
//| :param float attack_level: The level, in the range ``0.0`` to ``1.0`` of the peak volume of the attack phase
8585
//| :param float sustain_level: The level, in the range ``0.0`` to ``1.0`` of the volume of the sustain phase relative to the attack level
8686
//| """

shared-module/synthio/__init__.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void synthio_envelope_definition_set(synthio_envelope_definition_t *envelope, mp
8989

9090
envelope->release_step = -convert_time_to_rate(
9191
sample_rate, fields[2],
92-
envelope->decay_step
92+
envelope->sustain_level
9393
? envelope->sustain_level
9494
: envelope->attack_level);
9595
}

0 commit comments

Comments
 (0)