X:
Y:
Z:
Y:
Z:
Description:
Set position of 3D Effect.
Result:
Sound change with value of x, y and z input.
Code:
var source = null; var effect = null; var pos = { x: 0, y: 0, z: 0 }; function onload() { var engine = new jWebAudio.SoundEngine(); source = engine.addSoundSource({ 'url': '../../examples/resource/a.ogg', 'preLoad': true, 'callback': function() { source.sound.play(); var id = source.sound.addEffect('3d'); effect = source.sound.getEffect(id); // enable UI var input = document.getElementsByTagName('input'); for (var i in input) { input[i].disabled = false; } } }); } function xChange() { var x = document.getElementById('xInput').value; document.getElementById('xLabel').innerHTML = x; pos.x = parseInt(x); effect.soundObject.setPosition(pos.x, pos.y, pos.z); } function yChange() { var y = document.getElementById('yInput').value; document.getElementById('yLabel').innerHTML = y; pos.y = parseInt(y); effect.soundObject.setPosition(pos.x, pos.y, pos.z); } function zChange() { var z = document.getElementById('zInput').value; document.getElementById('zLabel').innerHTML = z; pos.z = parseInt(z); effect.soundObject.setPosition(pos.x, pos.y, pos.z); }