mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibWeb: Clamp AudioParam's value between min and max
The spec isn't _super_ clear on how this is meant to be done, but the way I understand this is that we should simply clamp the returned 'current value' between 'min' and 'max'. Firefox does not appear to do this clamping, but Chrome does.
This commit is contained in:
parent
e2b5ff2450
commit
94354ea7fb
Notes:
sideshowbarker
2024-07-17 02:39:10 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/94354ea7fb Pull-request: https://github.com/SerenityOS/serenity/pull/24195
@ -10,3 +10,5 @@ Error: 'InvalidStateError: Oscillator node type cannot be set to 'custom'', type
|
||||
oscillator node type: 'triangle'
|
||||
[object AudioParam] current: 440, default: 440, min: -22050, max: 22050, rate: a-rate
|
||||
[object AudioParam] current: -52, default: 440, min: -22050, max: 22050, rate: a-rate
|
||||
[object AudioParam] current: 22050, default: 440, min: -22050, max: 22050, rate: a-rate
|
||||
[object AudioParam] current: -22050, default: 440, min: -22050, max: 22050, rate: a-rate
|
||||
|
@ -42,5 +42,9 @@
|
||||
dumpAudioParam(frequency);
|
||||
frequency.value = -52;
|
||||
dumpAudioParam(frequency);
|
||||
frequency.value = 100_000;
|
||||
dumpAudioParam(frequency);
|
||||
frequency.value = -22051;
|
||||
dumpAudioParam(frequency);
|
||||
});
|
||||
</script>
|
||||
|
@ -31,9 +31,12 @@ JS::NonnullGCPtr<AudioParam> AudioParam::create(JS::Realm& realm, float default_
|
||||
AudioParam::~AudioParam() = default;
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioparam-value
|
||||
// https://webaudio.github.io/web-audio-api/#simple-nominal-range
|
||||
float AudioParam::value() const
|
||||
{
|
||||
return m_current_value;
|
||||
// Each AudioParam includes minValue and maxValue attributes that together form the simple nominal range
|
||||
// for the parameter. In effect, value of the parameter is clamped to the range [minValue, maxValue].
|
||||
return clamp(m_current_value, min_value(), max_value());
|
||||
}
|
||||
|
||||
// https://webaudio.github.io/web-audio-api/#dom-audioparam-value
|
||||
|
Loading…
Reference in New Issue
Block a user