Commits

catseye  committed a1ceb2f

Add really, really simple Mozilla audio demo.

  • Participants
  • Parent commits 5aee050

Comments (0)

Files changed (1)

File javascript/moz-audio.html

+<!DOCTYPE html>
+<head>
+  <meta charset="utf-8">
+  <title>Mozilla Audio Demo</title>
+</head>
+<body>
+
+<h1>Mozilla Audio Demo</h1>
+
+</body>
+<script>
+  var audio = new Audio();
+  audio.mozSetup(1, 44100);
+  var samples = 20000;
+  var data = new Float32Array(samples);
+  for (var i = 0; i < samples; i++) {
+      var amplitude = 1.0 - (i / samples);
+      //data[i] = (Math.random() * 2.0 * amplitude) - 1.0;
+      data[i] = (Math.sin(i / 50) * 2.0 * amplitude) - 1.0;
+  }
+  var w = audio.mozWriteAudio(data);
+  // if samples === 80000, this goes "35900 samples not written" for me
+  if (w < samples) { alert((samples - w) + " samples not written"); }
+</script>