Skip to content

Typing a value with its unit ("-6 dB", "500 ms", "50%") into a host's parameter field resets the parameter to its default #17

Open

Description

@matt-edmondson

What's wrong

EffectAudioParameter.FromString accepts only a bare invariant-culture number. Any other text returns the parameter's default:

/// <inheritdoc/>
public override double FromString(string plainValueAsString) =>
StepCount == 1
? base.FromString(plainValueAsString)
: double.TryParse(plainValueAsString, NumberStyles.Float, CultureInfo.InvariantCulture, out double plainValue)
? ToNormalized(plainValue)
: DefaultNormalizedValue;

Hosts call this when a user types into a generic editor or an automation-lane value box. Users naturally type the unit the host displays next to the value, and a typo lands here too.

Observed

On the Gain parameter, whose default is 0 dB:

FromString("-6")    -> -6.00 dB
FromString("-6 dB") ->  0.00 dB   (reset to default)
FromString("-6dB")  ->  0.00 dB   (reset to default)
FromString("abc")   ->  0.00 dB   (reset to default)

Delay Time behaves the same way: "500 ms" jumps to the 250 ms default. So does Mix: "50%" jumps to its default. The user's current setting is silently thrown away, and automation can be written with the wrong value.

Suggested fix

  • Before parsing, trim whitespace and strip the descriptor's Units suffix (and a trailing %), ignoring case.
  • On a parse failure, return the parameter's current normalized value instead of DefaultNormalizedValue, so bad input leaves the value unchanged.

Acceptance criteria

  • Unit tests: "-6 dB", "-6dB" and " -6 " all give -6 dB on Gain. "500 ms" gives 500 ms on Delay Time. "50%" and "50 %" give 50 on Mix.
  • Unparseable input leaves the value where it was.

Activity

  1. matt-edmondson commented on Oct 5, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Bug
    • Priority: Medium. Typing a value with its unit silently resets the parameter to its default, which can write wrong automation. The workaround is to type a bare number.
    • Area: EffectsHost.Plugin/EffectAudioParameter.FromString
    • Duplicates / in progress: No duplicate or open PR.
    • Next step: Trim the input and strip the descriptor's Units suffix and % case-insensitively. On a parse failure, return the current normalized value rather than the default. Add the listed unit-test rows.

    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions