Created
December 5, 2014 23:32
-
-
Save padenot/440de66cab3fedf3e4cc to your computer and use it in GitHub Desktop.
Start of a test for setValueCurveAtTime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function lalaj() { | |
var out = document.querySelector("pre"); | |
var a = new OfflineAudioContext(1, 44100, 44100); | |
var b = a.createBuffer(1, 44100, 44100); | |
var g = a.createGain(); | |
var bb = b.getChannelData(0); | |
for (var i = 0; i < bb.length; i++) { | |
bb[i] = 1.0; | |
} | |
g.gain.setValueAtTime(0.0, 0.0); | |
var curve = new Float32Array([-1, 0, 1]); | |
g.gain.setValueCurveAtTime(curve, 0.7, 0.3); | |
var source = a.createBufferSource(); | |
source.buffer = b; | |
source.start(0); | |
source.connect(g); | |
g.connect(a.destination); | |
a.oncomplete = function(e) { | |
var buf = e.renderedBuffer.getChannelData(0); | |
var endindex = Math.floor(0.95 * 44100); | |
var startindex = Math.floor(0.65 * 44100); | |
alert(endindex - startindex); | |
var lala = ""; | |
for (var i = startindex; i < endindex; i++) { | |
lala += (i / 44100) + ": " + buf[i] + "<br>"; | |
} | |
out.innerHTML = lala; | |
} | |
a.startRendering() | |
} | |
window.onload = lalaj; | |
</script> | |
<pre> | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment