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.
This commit is contained in:
Jeff Epler 2023-05-11 10:19:48 -05:00
parent 095e020809
commit 89080564b4
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
2 changed files with 2 additions and 2 deletions

View File

@ -80,7 +80,7 @@ static const mp_arg_t envelope_properties[] = {
//|
//| :param float attack_time: The time in seconds it takes to ramp from 0 volume to attack_volume
//| :param float decay_time: The time in seconds it takes to ramp from attack_volume to sustain_volume
//| :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``
//| :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.
//| :param float attack_level: The level, in the range ``0.0`` to ``1.0`` of the peak volume of the attack phase
//| :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
//| """

View File

@ -89,7 +89,7 @@ void synthio_envelope_definition_set(synthio_envelope_definition_t *envelope, mp
envelope->release_step = -convert_time_to_rate(
sample_rate, fields[2],
envelope->decay_step
envelope->sustain_level
? envelope->sustain_level
: envelope->attack_level);
}