Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title></title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
- <script src="//ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
- <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <script>
- var audio = new Audio();
- audio.src = 'music.mp3';
- audio.autoplay = true;
- var context, analyser, source;
- $(document).ready(function(){
- context = new AudioContext(); // AudioContext object instance
- analyser = context.createAnalyser(); // AnalyserNode method
- source = context.createMediaElementSource(audio);
- source.connect(analyser);
- analyser.connect(context.destination);
- loop();
- });
- function loop(){
- window.requestAnimationFrame(loop);
- fbc_array = new Uint8Array(analyser.frequencyBinCount);
- analyser.getByteFrequencyData(fbc_array);
- var output = fbc_array.toString().replace(new RegExp(',', 'g'),"<br>");
- $("#output").html(output);
- }
- </script>
- </head>
- <body>
- <div class="container">
- <h2>Audio Levels</h2>
- <div id="output"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement