mirror of
https://github.com/zyqunix/tools.git
synced 2025-07-05 22:10:31 +02:00
Merge branch 'main' of https://github.com/zyqunix/tools
This commit is contained in:
commit
6e7169a1c0
5 changed files with 117 additions and 1 deletions
|
@ -1,4 +1,9 @@
|
|||
const songs = [
|
||||
{
|
||||
song: "Julia - Between the Bars",
|
||||
src: "https://atums.world/raw/between%20the%20bars%20-%20julia%20(1080p,%20h264).mp4",
|
||||
duration: 201
|
||||
},
|
||||
{
|
||||
song: "PinkPantheress - Mosquito",
|
||||
src: "https://easyfiles.cc/2024/12/895c8869-5a2e-4458-b70a-5b91a3d99b64/PinkPantheress%20-%20Mosquito%20(Official%20Video)%20-%20Pinkpantheress%20(1080p,%20av1).mp4",
|
||||
|
|
19
microphone/index.html
Normal file
19
microphone/index.html
Normal file
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Mic Test</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<link rel="shortcut icon" href="https://rimgo.pussthecat.org/RFbdMMB.png" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
<h1>Microphone Test</h1>
|
||||
<div class="shadow card">
|
||||
<canvas id="visualizer"></canvas>
|
||||
<button id="btn">Start Listening</button>
|
||||
</div>
|
||||
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
67
microphone/index.js
Normal file
67
microphone/index.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
const btn = document.getElementById('btn');
|
||||
const canvas = document.getElementById('visualizer');
|
||||
const ctx = canvas.getContext('2d');
|
||||
|
||||
let audioContext;
|
||||
let analyser;
|
||||
let dataArray;
|
||||
let micStream;
|
||||
let animationId;
|
||||
let isListening = false;
|
||||
|
||||
async function startMic() {
|
||||
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
||||
micStream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
||||
const source = audioContext.createMediaStreamSource(micStream);
|
||||
|
||||
analyser = audioContext.createAnalyser();
|
||||
analyser.fftSize = 512;
|
||||
|
||||
const bufferLength = analyser.fftSize;
|
||||
dataArray = new Uint8Array(bufferLength);
|
||||
|
||||
source.connect(analyser);
|
||||
draw();
|
||||
}
|
||||
|
||||
function stopMic() {
|
||||
micStream.getTracks().forEach(track => track.stop());
|
||||
audioContext.close();
|
||||
cancelAnimationFrame(animationId);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
animationId = requestAnimationFrame(draw);
|
||||
|
||||
analyser.getByteTimeDomainData(dataArray);
|
||||
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
ctx.lineWidth = 2;
|
||||
ctx.strokeStyle = '#000';
|
||||
ctx.beginPath();
|
||||
|
||||
const sliceWidth = canvas.width / dataArray.length;
|
||||
let x = 0;
|
||||
|
||||
for (let i = 0; i < dataArray.length; i++) {
|
||||
const v = dataArray[i] / 128.0;
|
||||
const y = v * canvas.height / 2;
|
||||
|
||||
i === 0 ? ctx.moveTo(x, y) : ctx.lineTo(x, y);
|
||||
x += sliceWidth;
|
||||
}
|
||||
|
||||
ctx.lineTo(canvas.width, canvas.height / 2);
|
||||
ctx.stroke();
|
||||
}
|
||||
|
||||
btn.addEventListener('click', async () => {
|
||||
if (!isListening) {
|
||||
await startMic();
|
||||
} else {
|
||||
stopMic();
|
||||
}
|
||||
isListening = !isListening;
|
||||
});
|
25
microphone/style.css
Normal file
25
microphone/style.css
Normal file
|
@ -0,0 +1,25 @@
|
|||
@import url(/global.css);
|
||||
|
||||
canvas {
|
||||
width: 100%;
|
||||
background-color: #fff;
|
||||
border-radius: 10px;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
button {
|
||||
cursor: pointer;
|
||||
background-color: #2a2a2a;
|
||||
padding: 7px;
|
||||
color: #c0c0c0;
|
||||
border: #2c2c2c solid 2px;
|
||||
border-radius: 4px;
|
||||
margin-top: 10px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #2c2c2c;
|
||||
color: #d0d0d0;
|
||||
border: #2e2e2e solid 2px;
|
||||
}
|
|
@ -71,7 +71,7 @@
|
|||
<img class="image" src="https://upload.wikimedia.org/wikipedia/commons/0/07/Neovim-mark-flat.svg">
|
||||
<span class="software-name">Neovim</span>
|
||||
</a>
|
||||
<a class="software-item tooltip" data-tooltip="I have contributed in making a plugin" href="https://equicord.org" target="_blank">
|
||||
<a class="software-item tooltip" data-tooltip="I have contributed in making 2 plugins" href="https://equicord.org" target="_blank">
|
||||
<img class="image" src="data:image/svg+xml,%3csvg%20width='443'%20height='443'%20viewBox='0%200%20443%20443'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_44_30)'%3e%3cpath%20d='M443%20221.5C443%20343.831%20343.831%20443%20221.5%20443C99.1691%20443%200%20343.831%200%20221.5C0%2099.1691%2099.1691%200%20221.5%200C343.831%200%20443%2099.1691%20443%20221.5ZM88.0751%20221.5C88.0751%20295.188%20147.811%20354.925%20221.5%20354.925C295.189%20354.925%20354.925%20295.188%20354.925%20221.5C354.925%20147.811%20295.189%2088.075%20221.5%2088.075C147.811%2088.075%2088.0751%20147.811%2088.0751%20221.5Z'%20fill='%23828282'/%3e%3cpath%20d='M292.475%20221.738C292.475%20260.805%20260.805%20292.475%20221.738%20292.475C206.464%20292.475%20192.321%20287.634%20180.759%20279.403L99.204%20328.406C213.071%20259.189%20140.312%20237.528%2065.4865%20281.979L151.513%20230.289C151.175%20227.486%20151.001%20224.632%20151.001%20221.738C151.001%20182.671%20182.671%20151.001%20221.738%20151.001C236.81%20151.001%20250.781%20155.714%20262.257%20163.748L318.541%20129.929C308.425%20119.209%20296.562%20110.196%20283.404%20103.305C262.883%2092.5569%20239.917%2087.3371%20216.767%2088.1588C193.616%2088.981%20171.078%2095.816%20151.371%20107.992C131.664%20120.168%20115.466%20137.264%20104.372%20157.6C100.352%20164.97%2097.0514%20172.673%2094.4977%20180.602C87.043%20203.753%2068.385%20224.336%2044.0682%20224.786C19.7508%20225.237%20-0.771072%20205.707%203.59034%20181.78C7.80789%20158.642%2015.7009%20136.23%2027.0546%20115.419C45.4719%2081.6595%2072.362%2053.2771%20105.078%2033.0639C137.794%2012.8507%20175.21%201.5037%20213.642%200.139448C252.074%20-1.2248%20290.2%207.44037%20324.267%2025.2823C358.334%2043.1247%20387.169%2069.5294%20407.934%20101.898C428.699%20134.267%20440.679%20171.484%20442.696%20209.888C444.712%20248.291%20436.694%20286.558%20419.433%20320.923C408.791%20342.107%20394.864%20361.358%20378.246%20378.002C361.062%20395.213%20333.322%20389.466%20319.844%20369.221C306.366%20348.976%20312.66%20321.917%20327.444%20302.605C332.508%20295.991%20336.96%20288.891%20340.729%20281.389C351.127%20260.689%20355.956%20237.638%20354.742%20214.505C354.103%20202.346%20351.807%20190.385%20347.956%20178.941L291.894%20212.626C292.278%20215.609%20292.475%20218.65%20292.475%20221.738ZM99.204%20328.406C97.8064%20329.256%2096.3807%20330.113%2094.9269%20330.976L99.204%20328.406Z'%20fill='url(%23paint0_linear_44_30)'/%3e%3cpath%20d='M224.615%20186.365C238.145%20178.236%20255.704%20182.613%20263.834%20196.143C271.963%20209.673%20267.586%20227.232%20254.055%20235.362L94.9268%20330.976L65.4863%20281.98L224.615%20186.365Z'%20fill='%23828282'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_44_30'%20x1='223.001'%20y1='0'%20x2='223.001'%20y2='388.178'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%235C5C5C'/%3e%3cstop%20offset='1'%20stop-color='%23333333'/%3e%3c/linearGradient%3e%3cclipPath%20id='clip0_44_30'%3e%3crect%20width='443'%20height='443'%20fill='white'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e">
|
||||
<span class="software-name">Equicord</span>
|
||||
</a>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue