Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- Manifest: dom/media/webaudio/test/mochitest.toml
<!DOCTYPE HTML>
<html>
<head>
<title>Test PannerNode outputs silence when the distance is greater than maxDist</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="webaudio.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<pre id="test">
<script class="testbody" type="text/javascript">
// BUF_SIZE must be greater than HRTF delay.
const BUF_SIZE = 1024;
const sampleRate = 44100;
var types = [
"equalpower",
"HRTF"
]
async function test(panningModel) {
var ac = new OfflineAudioContext(1, 1024, sampleRate);
var osc = ac.createOscillator();
var panner = new PannerNode(ac, {
panningModel,
distanceModel: "linear",
maxDistance: 100,
positionY: 200,
});
ac.listener.setPosition(0, 0, 0);
osc.connect(panner);
panner.connect(ac.destination);
osc.start();
const buffer = await ac.startRendering()
var silence = true;
var array = buffer.getChannelData(0);
for (var i = 0; i < buffer.length; i++) {
if (array[i] != 0) {
ok(false, "Found noise in the buffer.");
silence = false;
}
}
ok(silence, "The buffer is silent.");
}
add_task(async function() {
await promiseHRTFReady(sampleRate);
for (const panningModel of types) {
await test(panningModel);
}
});
</script>
</pre>
</body>
</html>