Skip to content

Instantly share code, notes, and snippets.

@padenot
Created December 5, 2014 23:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save padenot/440de66cab3fedf3e4cc to your computer and use it in GitHub Desktop.
Save padenot/440de66cab3fedf3e4cc to your computer and use it in GitHub Desktop.
Start of a test for setValueCurveAtTime
<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