Changing the pitch of an audio element without external libraries?
<p>I would like a way to change the pitch of an <code>Audio()</code> element through JavaScript. Something simple like:</p>

<pre><code>var audio = new Audio()
audio.src = "sound_effect.wav"
audio.pitch = 0.5 //Halving the frequency
audio.play()
</code></pre>

<p>EDIT: I now discovered <code>AudioContext()</code>, and I have the following code:</p>

<pre><code>//Import sounds
var SOUNDS = {};
window.AudioContext = window.AudioContext || window.webkitAudioContext;
var audioContext = new AudioContext();
function loadSound(name,success,err) {
    var request = new XMLHttpRequest();
    request.open('GET', 'sounds/'+name+'.wav')
    request.responseType = 'arraybuffer'
    request.onload = function() {
        audioContext.decodeAudioData(request.response, function(buffer) {
            SOUNDS[name] = buffer;
            (success || (function(){}))()
        }, err || function(msg) {console.error(msg)});
     }
     request.send();
 }
 function playSound(name,param) {
     param = param || {}
     var s = SOUNDS[name]
     var source = audioContext.createBufferSource()
     source.buffer = s
     if (param.loop) {
         source.loop = true
     }
     source.connect(audioContext.destination);
     source.start(0);
 }
 loadSound("laser",function() {
     //Onload
     playSound('laser')
 })
 loadSound("thump")
</code></pre>

<p>However I do not know how to change the pitch yet.</p>