Audio visualizer 2d
How do I make an audio visualizer 2d?
What is a audio visualizer 2d? How do you make a audio visualizer 2d? This script and codes were developed by Yoichi Kobayashi on 26 August 2022, Friday.
Audio visualizer 2d - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>audio visualizer 2d</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <h1>audio-visualizer-2d</h1>
<canvas id="canvas"></canvas> <script src="js/index.js"></script>
</body>
</html>
Audio visualizer 2d - Script Codes CSS Codes
* { margin: 0; padding: 0;
}
html { height: 100%;
}
body { height: 100%; overflow: hidden; font-family: 'source code pro'; background-color: rgba(0, 30, 40, 1);
}
h1 { position: absolute; right: 0; top: 10vh; left: 0; z-index: 2; color: rgba(0, 210, 200, 1); font-size: 4vw; text-align: center;
}
canvas { position: absolute; top: 0; right: 0; bottom: 0; left: 0;
}
p { line-height: 1.5; position: relative; z-index: 2; padding: 1em; color: #00ee00; word-wrap:break-word;
}
Audio visualizer 2d - Script Codes JS Codes
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = function(object, eventType, callback){ var timer; object.addEventListener(eventType, function(event) { clearTimeout(timer); timer = setTimeout(function(){ callback(event); }, 500); }, false);
};
},{}],2:[function(require,module,exports){
var Util = require('./util');
var debounce = require('./debounce');
var body = document.body;
var body_width = body.clientWidth * 2;
var body_height = body.clientHeight * 2;
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var audio_ctx = new (window.AudioContext || window.webkitAudioContext)();
var audio_analyser = audio_ctx.createAnalyser();
var audio_buffer = new XMLHttpRequest();
var audio_url = 'https://api.soundcloud.com/tracks/89297698/stream?client_id=0aaf73b4de24ee4e86313e01d458083d';
var fft_size = 512;
var init = function() { renderloop(); resizeCanvas(); initAudio(); debounce(window, 'resize', function(event){ resizeCanvas(); });
};
var initAudio = function() { audio_analyser.fft_size = fft_size; audio_analyser.connect(audio_ctx.destination); loadAudio();
};
var loadAudio = function() { var request = new XMLHttpRequest(); request.open('GET', audio_url, true); request.responseType = 'arraybuffer'; request.onload = function() { audio_ctx.decodeAudioData(request.response, function(buffer) { audio_buffer = buffer; playAudio(); }); }; request.send();
};
var playAudio = function() { var source = audio_ctx.createBufferSource(); source.buffer = audio_buffer; source.connect(audio_analyser); source.start(0);
};
var drawSpectrums = function() { var spectrums = new Uint8Array(audio_analyser.frequencyBinCount); var str = ''; var length = 0; audio_analyser.getByteTimeDomainData(spectrums); length = audio_analyser.frequencyBinCount; ctx.fillStyle = 'rgba(0, 210, 200, 1)'; ctx.lineWidth = 4; ctx.beginPath(); for (var i = 0; i < length; i++) { var x = i / fft_size * body_width; //var y = spectrums[i] / 256 * body_height; var y = (Math.log(256 - spectrums[i]) / Math.log(256)) * body_height * 0.9; if (i === 0) { ctx.moveTo(x, y); } else { ctx.lineTo(x, y); } } ctx.lineTo(body_width, body_height); ctx.lineTo(0, body_height); ctx.fill();
};
var render = function() { ctx.clearRect(0, 0, body_width, body_height); drawSpectrums();
};
var renderloop = function() { requestAnimationFrame(renderloop); render();
};
var resizeCanvas = function() { body_width = body.clientWidth * 2; body_height = body.clientHeight * 2; canvas.width = body_width; canvas.height = body_height; canvas.style.width = body_width / 2 + 'px'; canvas.style.height = body_height / 2 + 'px';
};
init();
},{"./debounce":1,"./util":3}],3:[function(require,module,exports){
var exports = { getRandomInt: function(min, max){ return Math.floor(Math.random() * (max - min)) + min; }, getDegree: function(radian) { return radian / Math.PI * 180; }, getRadian: function(degrees) { return degrees * Math.PI / 180; }, getSpherical: function(rad1, rad2, r) { var x = Math.cos(rad1) * Math.cos(rad2) * r; var z = Math.cos(rad1) * Math.sin(rad2) * r; var y = Math.sin(rad1) * r; return [x, y, z]; }
};
module.exports = exports;
},{}]},{},[2])
Developer | Yoichi Kobayashi |
Username | ykob |
Uploaded | August 26, 2022 |
Rating | 3.5 |
Size | 3,199 Kb |
Views | 44,528 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Three.js Points anti-gravity is applied | 4,102 Kb |
Glsl-dissolve | 9,379 Kb |
Red cloud | 3,260 Kb |
Three.js Points anti-gravity is applied ver2 | 4,471 Kb |
Butterfly | 9,235 Kb |
Glow | 4,824 Kb |
GLSL Hills | 6,991 Kb |
Set the sphere wriggle in background | 6,773 Kb |
Particles moving to the spherical | 3,834 Kb |
Float Particle | 2,623 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Background-blend-mode Test | 0x04 | 4,744 Kb |
CardMove | Thompsonemerson | 3,699 Kb |
Cars going | Netoguimaraes | 1,699 Kb |
Button fills | Zubfatal | 5,205 Kb |
CSS Link Icons with jQuery Titles | Nicwinn | 2,312 Kb |
A Pen by aleen42 | Aleen42 | 11,473 Kb |
CSS-Flexbox-Demo | Sstiglets | 1,709 Kb |
Slider css only | Armandobau | 2,161 Kb |
Custom checkbox example | Capelo | 3,495 Kb |
Multi column experiment. | Spylefkaditis | 2,805 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!