diff --git a/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt b/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt index 46b512cb366..2a088b22e0b 100644 --- a/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt +++ b/Tests/LibWeb/Text/expected/WebAudio/OscillatorNode.txt @@ -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 diff --git a/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html b/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html index 0c66f2f9efc..408c7b92155 100644 --- a/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html +++ b/Tests/LibWeb/Text/input/WebAudio/OscillatorNode.html @@ -42,5 +42,9 @@ dumpAudioParam(frequency); frequency.value = -52; dumpAudioParam(frequency); + frequency.value = 100_000; + dumpAudioParam(frequency); + frequency.value = -22051; + dumpAudioParam(frequency); }); diff --git a/Userland/Libraries/LibWeb/WebAudio/AudioParam.cpp b/Userland/Libraries/LibWeb/WebAudio/AudioParam.cpp index fc5a7568a73..5a8f0eaabd7 100644 --- a/Userland/Libraries/LibWeb/WebAudio/AudioParam.cpp +++ b/Userland/Libraries/LibWeb/WebAudio/AudioParam.cpp @@ -31,9 +31,12 @@ JS::NonnullGCPtr 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