Skip to content

Instantly share code, notes, and snippets.

@LewisGet
Created August 19, 2016 07:46
Show Gist options
  • Save LewisGet/3655597c46650c12d73a985ba8bfa6a4 to your computer and use it in GitHub Desktop.
Save LewisGet/3655597c46650c12d73a985ba8bfa6a4 to your computer and use it in GitHub Desktop.
<input type="file" id="file" />
<button onclick="window.fileLoad();">load</button>
<audio id="media" controls autoplay>
<source src="">
</audio>
<script>
window.getFileUrl = function () {
var url = URL.createObjectURL(window.file.files[0]);
return url;
};
window.fileLoad = function () {
window.media.src = window.getFileUrl();
window.media.load();
};
window.getSoundArray = function () {
var audioCtx = new AudioContext;
var source = audioCtx.createMediaElementSource(window.media);
var processor = audioCtx.createScriptProcessor(1024, 1, 1);
//view-source:http://www.oxxostudio.tw/demo/201512/web-audio-api-createmediaelementsource-demo2.html
// else
//http://www.oxxostudio.tw/articles/201509/web-audio-api-audioparam-gainnode.html
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment