Add 3 files
Browse files- README.md +7 -5
- index.html +980 -19
- prompts.txt +0 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: simple-sound-visualizer
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: pink
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,980 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Sound Visualizer</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
|
| 9 |
+
<style>
|
| 10 |
+
.visualizer-container {
|
| 11 |
+
position: relative;
|
| 12 |
+
width: 100%;
|
| 13 |
+
height: 400px;
|
| 14 |
+
overflow: hidden;
|
| 15 |
+
background: linear-gradient(to bottom, #0f172a, #1e293b);
|
| 16 |
+
border-radius: 12px;
|
| 17 |
+
justify-content: center;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.bar {
|
| 21 |
+
width: 2%;
|
| 22 |
+
height: 100%;
|
| 23 |
+
display: inline-block;
|
| 24 |
+
margin: 0 1%;
|
| 25 |
+
background: linear-gradient(to top, #3b82f6, #9333ea);
|
| 26 |
+
transform-origin: bottom;
|
| 27 |
+
border-radius: 5px;
|
| 28 |
+
transition: transform 0.1s ease-out;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
.circle {
|
| 32 |
+
position: absolute;
|
| 33 |
+
border-radius: 50%;
|
| 34 |
+
background: radial-gradient(circle, rgba(59,130,246,0.8) 0%, rgba(147,51,234,0.4) 70%);
|
| 35 |
+
transform-origin: center;
|
| 36 |
+
transition: all 0.2s ease-out;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.wave {
|
| 40 |
+
position: absolute;
|
| 41 |
+
top: 40%;
|
| 42 |
+
left: 0;
|
| 43 |
+
width: 100%;
|
| 44 |
+
height: 100%;
|
| 45 |
+
fill: none;
|
| 46 |
+
stroke: url(#waveGradient);
|
| 47 |
+
stroke-width: 15px;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
.particle {
|
| 51 |
+
position: absolute;
|
| 52 |
+
border-radius: 50%;
|
| 53 |
+
background: linear-gradient(45deg, #3b82f6, #9333ea);
|
| 54 |
+
transform-origin: center;
|
| 55 |
+
transition: all 0.3s ease-out;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.spectrum-line {
|
| 59 |
+
position: absolute;
|
| 60 |
+
bottom: 0;
|
| 61 |
+
width: 2px;
|
| 62 |
+
background: linear-gradient(to top, #3b82f6, #9333ea);
|
| 63 |
+
transform-origin: bottom;
|
| 64 |
+
transition: height 0.1s ease-out;
|
| 65 |
+
}
|
| 66 |
+
|
| 67 |
+
.radial-bar {
|
| 68 |
+
position: absolute;
|
| 69 |
+
width: 15px;
|
| 70 |
+
background: linear-gradient(to top, #3b82f6, #9333ea);
|
| 71 |
+
transform-origin: bottom;
|
| 72 |
+
border-radius: 2px;
|
| 73 |
+
transition: height 0.1s ease-out;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
.rounded-wave-container {
|
| 77 |
+
position: relative;
|
| 78 |
+
width: 100%;
|
| 79 |
+
max-width: 400px;
|
| 80 |
+
height: 400px;
|
| 81 |
+
margin: auto;
|
| 82 |
+
display: flex;
|
| 83 |
+
justify-content: center;
|
| 84 |
+
align-items: center;
|
| 85 |
+
overflow: hidden;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.rounded-wave {
|
| 89 |
+
position: absolute;
|
| 90 |
+
border-radius: 50%;
|
| 91 |
+
border: 2px solid rgba(59, 130, 246, 0.4);
|
| 92 |
+
opacity: 0.7;
|
| 93 |
+
animation: pulse 3s infinite;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
.wave-1 {
|
| 97 |
+
width: 180px;
|
| 98 |
+
height: 180px;
|
| 99 |
+
z-index: 1;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.wave-2 {
|
| 103 |
+
width: 240px;
|
| 104 |
+
height: 240px;
|
| 105 |
+
z-index: 0;
|
| 106 |
+
animation-delay: 0.5s;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.wave-3 {
|
| 110 |
+
width: 300px;
|
| 111 |
+
height: 300px;
|
| 112 |
+
z-index: -1;
|
| 113 |
+
animation-delay: 1s;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.center-image {
|
| 117 |
+
position: relative;
|
| 118 |
+
width: 120px;
|
| 119 |
+
height: 120px;
|
| 120 |
+
border-radius: 50%;
|
| 121 |
+
background-size: cover;
|
| 122 |
+
background-position: center;
|
| 123 |
+
z-index: 10;
|
| 124 |
+
box-shadow: 0 0 30px rgba(59, 130, 246, 0.7);
|
| 125 |
+
border: 2px solid rgba(59, 130, 246, 0.5);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
@keyframes pulse {
|
| 129 |
+
0% {
|
| 130 |
+
transform: scale(1);
|
| 131 |
+
opacity: 0.7;
|
| 132 |
+
}
|
| 133 |
+
50% {
|
| 134 |
+
transform: scale(1.1);
|
| 135 |
+
opacity: 0.3;
|
| 136 |
+
}
|
| 137 |
+
100% {
|
| 138 |
+
transform: scale(1);
|
| 139 |
+
opacity: 0.7;
|
| 140 |
+
}
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.fade-in {
|
| 144 |
+
animation: fadeIn 0.5s ease-in;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
@keyframes fadeIn {
|
| 148 |
+
from { opacity: 0; }
|
| 149 |
+
to { opacity: 1; }
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
.gradient-bg {
|
| 153 |
+
background: linear-gradient(135deg, #1e293b, #0f172a);
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
.glow {
|
| 157 |
+
box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.visualizer-style-btn.active {
|
| 161 |
+
transform: scale(1.05);
|
| 162 |
+
box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
|
| 163 |
+
}
|
| 164 |
+
|
| 165 |
+
.bidirectional-wave {
|
| 166 |
+
position: absolute;
|
| 167 |
+
width: 100%;
|
| 168 |
+
height: 100%;
|
| 169 |
+
top: 0;
|
| 170 |
+
left: 0;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.bidirectional-wave path {
|
| 174 |
+
fill: url(#bidirectionalWaveGradient);
|
| 175 |
+
opacity: 0.8;
|
| 176 |
+
transition: all 0.1s ease-out;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
.rounded-wave path {
|
| 180 |
+
fill: url(#roundedWaveGradient);
|
| 181 |
+
opacity: 0.8;
|
| 182 |
+
transition: all 0.1s ease-out;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.image-upload-container {
|
| 186 |
+
display: none;
|
| 187 |
+
position: absolute;
|
| 188 |
+
top: 50%;
|
| 189 |
+
left: 50%;
|
| 190 |
+
transform: translate(-50%, -50%);
|
| 191 |
+
background: rgba(30, 41, 59, 0.95);
|
| 192 |
+
padding: 20px;
|
| 193 |
+
border-radius: 10px;
|
| 194 |
+
z-index: 100;
|
| 195 |
+
box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
|
| 196 |
+
border: 1px solid rgba(59, 130, 246, 0.3);
|
| 197 |
+
width: 90%;
|
| 198 |
+
max-width: 400px;
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
.image-upload-container.active {
|
| 202 |
+
display: block;
|
| 203 |
+
animation: fadeIn 0.3s ease-out;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.slider-container {
|
| 207 |
+
width: 100%;
|
| 208 |
+
max-width: 300px;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.slider-label {
|
| 212 |
+
display: flex;
|
| 213 |
+
justify-content: space-between;
|
| 214 |
+
margin-bottom: 0.5rem;
|
| 215 |
+
font-size: 0.875rem;
|
| 216 |
+
color: #94a3b8;
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
.slider-value {
|
| 220 |
+
color: #e2e8f0;
|
| 221 |
+
font-weight: 500;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
input[type="range"] {
|
| 225 |
+
-webkit-appearance: none;
|
| 226 |
+
width: 100%;
|
| 227 |
+
height: 8px;
|
| 228 |
+
border-radius: 4px;
|
| 229 |
+
background: #334155;
|
| 230 |
+
outline: none;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
input[type="range"]::-webkit-slider-thumb {
|
| 234 |
+
-webkit-appearance: none;
|
| 235 |
+
appearance: none;
|
| 236 |
+
width: 18px;
|
| 237 |
+
height: 18px;
|
| 238 |
+
border-radius: 50%;
|
| 239 |
+
background: #3b82f6;
|
| 240 |
+
cursor: pointer;
|
| 241 |
+
transition: all 0.2s;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
input[type="range"]::-webkit-slider-thumb:hover {
|
| 245 |
+
background: #2563eb;
|
| 246 |
+
transform: scale(1.1);
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.upload-btn {
|
| 250 |
+
position: absolute;
|
| 251 |
+
bottom: 50px;
|
| 252 |
+
right: 50px;
|
| 253 |
+
background: rgba(59, 130, 246, 0.9);
|
| 254 |
+
color: white;
|
| 255 |
+
border: none;
|
| 256 |
+
border-radius: 50%;
|
| 257 |
+
width: 10px;
|
| 258 |
+
height: 10px;
|
| 259 |
+
display: flex;
|
| 260 |
+
align-items: center;
|
| 261 |
+
justify-content: center;
|
| 262 |
+
cursor: pointer;
|
| 263 |
+
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
|
| 264 |
+
transition: all 0.3s ease;
|
| 265 |
+
z-index: 20;
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
.upload-btn:hover {
|
| 269 |
+
background: rgba(37, 99, 235, 0.9);
|
| 270 |
+
transform: scale(1.1);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.upload-btn i {
|
| 274 |
+
font-size: 1.2rem;
|
| 275 |
+
}
|
| 276 |
+
</style>
|
| 277 |
+
</head>
|
| 278 |
+
<body class="gradient-bg text-white min-h-screen">
|
| 279 |
+
<div class="container mx-auto px-4 py-8">
|
| 280 |
+
<header class="text-center mb-8 fade-in">
|
| 281 |
+
<h1 class="text-5xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-purple-600 mb-2">
|
| 282 |
+
Sound Visualizer
|
| 283 |
+
</h1>
|
| 284 |
+
<p class="text-gray-400 text-lg">Transform your voice into stunning visual art</p>
|
| 285 |
+
</header>
|
| 286 |
+
|
| 287 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-xl mb-8 glow">
|
| 288 |
+
<div class="flex flex-wrap justify-between items-center mb-6">
|
| 289 |
+
<div class="mb-4 md:mb-0">
|
| 290 |
+
<button id="startBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-6 py-3 rounded-full font-medium transition-all transform hover:scale-105 active:scale-95">
|
| 291 |
+
<i class="fas fa-microphone mr-2"></i> Start Microphone
|
| 292 |
+
</button>
|
| 293 |
+
<button id="stopBtn" disabled class="bg-gray-600 hover:bg-gray-700 text-white px-6 py-3 rounded-full font-medium transition-all transform hover:scale-105 active:scale-95 ml-2">
|
| 294 |
+
<i class="fas fa-stop mr-2"></i> Stop
|
| 295 |
+
</button>
|
| 296 |
+
</div>
|
| 297 |
+
|
| 298 |
+
<div class="flex items-center">
|
| 299 |
+
<div id="status" class="text-gray-400 flex items-center mr-4">
|
| 300 |
+
<i class="fas fa-info-circle mr-2"></i> Mic inactive ❗
|
| 301 |
+
</div>
|
| 302 |
+
</div>
|
| 303 |
+
</div>
|
| 304 |
+
|
| 305 |
+
<div class="visualizer-container" id="visualizer">
|
| 306 |
+
<!-- Bars Visualizer -->
|
| 307 |
+
<div id="barsContainer" class="h-full flex items-end justify-center"></div>
|
| 308 |
+
|
| 309 |
+
<!-- Circles Visualizer -->
|
| 310 |
+
<div id="circlesContainer" class="h-full w-full relative" style="display: none;"></div>
|
| 311 |
+
|
| 312 |
+
<!-- Wave Visualizer -->
|
| 313 |
+
<svg id="waveContainer" class="wave" viewBox="0 0 1000 200" preserveAspectRatio="none" style="display: none;">
|
| 314 |
+
<defs>
|
| 315 |
+
<linearGradient id="waveGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 316 |
+
<stop offset="0%" stop-color="#3b82f6" />
|
| 317 |
+
<stop offset="100%" stop-color="#9333ea" />
|
| 318 |
+
</linearGradient>
|
| 319 |
+
</defs>
|
| 320 |
+
<path id="wavePath" d=""></path>
|
| 321 |
+
</svg>
|
| 322 |
+
|
| 323 |
+
<!-- Bidirectional Wave Visualizer -->
|
| 324 |
+
<svg id="bidirectionalWaveContainer" class="bidirectional-wave" viewBox="0 0 1000 200" preserveAspectRatio="none" style="display: none;">
|
| 325 |
+
<defs>
|
| 326 |
+
<linearGradient id="bidirectionalWaveGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
| 327 |
+
<stop offset="0%" stop-color="#3b82f6" />
|
| 328 |
+
<stop offset="100%" stop-color="#9333ea" />
|
| 329 |
+
</linearGradient>
|
| 330 |
+
</defs>
|
| 331 |
+
<path id="bidirectionalWavePathTop" d=""></path>
|
| 332 |
+
<path id="bidirectionalWavePathBottom" d=""></path>
|
| 333 |
+
</svg>
|
| 334 |
+
|
| 335 |
+
<!-- Rounded Wave Visualizer -->
|
| 336 |
+
<div id="roundedWaveContainer" class="rounded-wave-container" style="display: none;">
|
| 337 |
+
<div id="centerImage" class="center-image pulse"></div>
|
| 338 |
+
<svg id="roundedWave" class="rounded-wave" viewBox="0 0 1000 1000" preserveAspectRatio="none">
|
| 339 |
+
<defs>
|
| 340 |
+
<radialGradient id="roundedWaveGradient" cx="50%" cy="50%" r="50%" fx="50%" fy="50%">
|
| 341 |
+
<stop offset="0%" stop-color="#3b82f6" />
|
| 342 |
+
<stop offset="100%" stop-color="#9333ea" />
|
| 343 |
+
</radialGradient>
|
| 344 |
+
</defs>
|
| 345 |
+
<path id="roundedWavePath" d=""></path>
|
| 346 |
+
</svg>
|
| 347 |
+
<button id="changeImageBtn" class="upload-btn">
|
| 348 |
+
<i class="fas fa-camera"></i>
|
| 349 |
+
</button>
|
| 350 |
+
</div>
|
| 351 |
+
|
| 352 |
+
<!-- Image Upload Modal -->
|
| 353 |
+
<div id="imageUploadContainer" class="image-upload-container">
|
| 354 |
+
<h3 class="text-xl font-semibold mb-4 text-center">Change Center Image</h3>
|
| 355 |
+
<div class="mb-4">
|
| 356 |
+
<input type="file" id="imageUpload" accept="image/*" class="hidden">
|
| 357 |
+
<label for="imageUpload" class="block w-full bg-blue-600 hover:bg-blue-700 text-white px-4 py-3 rounded-lg cursor-pointer text-center transition-all mb-3">
|
| 358 |
+
<i class="fas fa-upload mr-2"></i> Upload Image
|
| 359 |
+
</label>
|
| 360 |
+
<p class="text-gray-400 text-sm mb-2 text-center">Or use a URL:</p>
|
| 361 |
+
<input type="text" id="imageUrl" placeholder="Enter image URL" class="w-full px-4 py-2 bg-gray-700 rounded-lg text-white border border-gray-600 focus:border-blue-500 focus:outline-none">
|
| 362 |
+
</div>
|
| 363 |
+
<div class="flex justify-between">
|
| 364 |
+
<button id="cancelImageBtn" class="bg-gray-600 hover:bg-gray-700 text-white px-4 py-2 rounded-lg transition-all flex-1 mr-2">
|
| 365 |
+
Cancel
|
| 366 |
+
</button>
|
| 367 |
+
<button id="applyImageBtn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition-all flex-1 ml-2">
|
| 368 |
+
Apply
|
| 369 |
+
</button>
|
| 370 |
+
</div>
|
| 371 |
+
</div>
|
| 372 |
+
|
| 373 |
+
<!-- Particles Visualizer -->
|
| 374 |
+
<div id="particlesContainer" class="h-full w-full relative" style="display: none;"></div>
|
| 375 |
+
|
| 376 |
+
<!-- Spectrum Visualizer -->
|
| 377 |
+
<div id="spectrumContainer" class="h-full w-full relative" style="display: none;"></div>
|
| 378 |
+
|
| 379 |
+
<!-- Radial Visualizer -->
|
| 380 |
+
<div id="radialContainer" class="h-full w-full relative" style="display: none;"></div>
|
| 381 |
+
</div>
|
| 382 |
+
<br/>
|
| 383 |
+
<div class="mt-6 flex space-x-4 w-full">
|
| 384 |
+
<!-- Sensitivity -->
|
| 385 |
+
<div class="w-[30%]">
|
| 386 |
+
<div class="flex justify-between text-sm mb-1">
|
| 387 |
+
<span>Sensitivity:</span>
|
| 388 |
+
<span id="sensitivityValue">100%</span>
|
| 389 |
+
</div>
|
| 390 |
+
<input type="range" id="sensitivity" min="10" max="300" value="100" class="w-full">
|
| 391 |
+
</div>
|
| 392 |
+
|
| 393 |
+
<!-- Smoothness -->
|
| 394 |
+
<div class="w-[20%]">
|
| 395 |
+
<div class="flex justify-between text-sm mb-1">
|
| 396 |
+
<span>Smoothness:</span>
|
| 397 |
+
<span id="smoothnessValue">5</span>
|
| 398 |
+
</div>
|
| 399 |
+
<input type="range" id="smoothness" min="1" max="30" value="5" class="w-full">
|
| 400 |
+
</div>
|
| 401 |
+
</div>
|
| 402 |
+
<div class="mt-6">
|
| 403 |
+
<span class="text-gray-400 mr-3">Visual Style:</span>
|
| 404 |
+
<div class="flex flex-wrap gap-2 mt-2">
|
| 405 |
+
<button data-style="bars" class="visualizer-style-btn bg-blue-600 text-white px-4 py-2 rounded-full text-sm transition-all active">Bars</button>
|
| 406 |
+
<button data-style="circles" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Circles</button>
|
| 407 |
+
<button data-style="wave" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Wave</button>
|
| 408 |
+
<button data-style="bidirectional" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Bidirectional</button>
|
| 409 |
+
<button data-style="rounded" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Rounded</button>
|
| 410 |
+
<button data-style="particles" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Particles</button>
|
| 411 |
+
<button data-style="spectrum" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Spectrum</button>
|
| 412 |
+
<button data-style="radial" class="visualizer-style-btn bg-gray-700 hover:bg-gray-600 text-white px-4 py-2 rounded-full text-sm transition-all">Radial</button>
|
| 413 |
+
</div>
|
| 414 |
+
</div>
|
| 415 |
+
</div>
|
| 416 |
+
|
| 417 |
+
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
|
| 418 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 419 |
+
<div class="flex items-center mb-4">
|
| 420 |
+
<div class="bg-blue-600 p-3 rounded-full mr-3">
|
| 421 |
+
<i class="fas fa-chart-bar text-white"></i>
|
| 422 |
+
</div>
|
| 423 |
+
<h3 class="text-lg font-semibold">Bar Visualizer</h3>
|
| 424 |
+
</div>
|
| 425 |
+
<p class="text-gray-400">Classic frequency bars that rise and fall with your voice. Perfect for seeing the different frequencies in your sound.</p>
|
| 426 |
+
</div>
|
| 427 |
+
|
| 428 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 429 |
+
<div class="flex items-center mb-4">
|
| 430 |
+
<div class="bg-purple-600 p-3 rounded-full mr-3">
|
| 431 |
+
<i class="fas fa-circle-notch text-white"></i>
|
| 432 |
+
</div>
|
| 433 |
+
<h3 class="text-lg font-semibold">Circle Visualizer</h3>
|
| 434 |
+
</div>
|
| 435 |
+
<p class="text-gray-400">Pulsing circles that respond to volume. The more intense your voice, the more circles appear and grow.</p>
|
| 436 |
+
</div>
|
| 437 |
+
|
| 438 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 439 |
+
<div class="flex items-center mb-4">
|
| 440 |
+
<div class="bg-indigo-600 p-3 rounded-full mr-3">
|
| 441 |
+
<i class="fas fa-wave-square text-white"></i>
|
| 442 |
+
</div>
|
| 443 |
+
<h3 class="text-lg font-semibold">Wave Visualizer</h3>
|
| 444 |
+
</div>
|
| 445 |
+
<p class="text-gray-400">Smooth waveform that undulates with your voice. Creates beautiful flowing patterns from your sound.</p>
|
| 446 |
+
</div>
|
| 447 |
+
|
| 448 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 449 |
+
<div class="flex items-center mb-4">
|
| 450 |
+
<div class="bg-pink-600 p-3 rounded-full mr-3">
|
| 451 |
+
<i class="fas fa-exchange-alt text-white"></i>
|
| 452 |
+
</div>
|
| 453 |
+
<h3 class="text-lg font-semibold">Bidirectional Wave</h3>
|
| 454 |
+
</div>
|
| 455 |
+
<p class="text-gray-400">Waveform that expands both upwards and downwards with a beautiful gradient, creating a symmetrical visualization of your sound.</p>
|
| 456 |
+
</div>
|
| 457 |
+
|
| 458 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 459 |
+
<div class="flex items-center mb-4">
|
| 460 |
+
<div class="bg-teal-600 p-3 rounded-full mr-3">
|
| 461 |
+
<i class="fas fa-circle text-white"></i>
|
| 462 |
+
</div>
|
| 463 |
+
<h3 class="text-lg font-semibold">Rounded Wave</h3>
|
| 464 |
+
</div>
|
| 465 |
+
<p class="text-gray-400">Circular waveform with a central image that pulses with your voice, creating a hypnotic radial effect with a vibrant gradient.</p>
|
| 466 |
+
</div>
|
| 467 |
+
|
| 468 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 469 |
+
<div class="flex items-center mb-4">
|
| 470 |
+
<div class="bg-orange-600 p-3 rounded-full mr-3">
|
| 471 |
+
<i class="fas fa-atom text-white"></i>
|
| 472 |
+
</div>
|
| 473 |
+
<h3 class="text-lg font-semibold">Particle Visualizer</h3>
|
| 474 |
+
</div>
|
| 475 |
+
<p class="text-gray-400">Dynamic particles that dance with your voice. Each particle responds to different frequency ranges.</p>
|
| 476 |
+
</div>
|
| 477 |
+
|
| 478 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 479 |
+
<div class="flex items-center mb-4">
|
| 480 |
+
<div class="bg-yellow-600 p-3 rounded-full mr-3">
|
| 481 |
+
<i class="fas fa-sliders-h text-white"></i>
|
| 482 |
+
</div>
|
| 483 |
+
<h3 class="text-lg font-semibold">Spectrum Visualizer</h3>
|
| 484 |
+
</div>
|
| 485 |
+
<p class="text-gray-400">Vertical lines representing the full frequency spectrum. See the complete range of your sound.</p>
|
| 486 |
+
</div>
|
| 487 |
+
|
| 488 |
+
<div class="bg-gray-800 rounded-xl p-6 shadow-lg hover:transform hover:scale-105 transition-all duration-300">
|
| 489 |
+
<div class="flex items-center mb-4">
|
| 490 |
+
<div class="bg-red-600 p-3 rounded-full mr-3">
|
| 491 |
+
<i class="fas fa-bullseye text-white"></i>
|
| 492 |
+
</div>
|
| 493 |
+
<h3 class="text-lg font-semibold">Radial Visualizer</h3>
|
| 494 |
+
</div>
|
| 495 |
+
<p class="text-gray-400">Circular bars radiating from the center. Creates a hypnotic pattern that responds to your voice.</p>
|
| 496 |
+
</div>
|
| 497 |
+
</div>
|
| 498 |
+
|
| 499 |
+
<footer class="text-center text-gray-500 text-sm mt-8">
|
| 500 |
+
<p>Sound Visualizer App | Created by <a href="https://github.com/almahmudbd/sound-visualizer" target"_blank">almahmud</a></p>
|
| 501 |
+
</footer>
|
| 502 |
+
</div>
|
| 503 |
+
|
| 504 |
+
<script>
|
| 505 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 506 |
+
// DOM elements
|
| 507 |
+
const startBtn = document.getElementById('startBtn');
|
| 508 |
+
const stopBtn = document.getElementById('stopBtn');
|
| 509 |
+
const statusEl = document.getElementById('status');
|
| 510 |
+
const visualizer = document.getElementById('visualizer');
|
| 511 |
+
const barsContainer = document.getElementById('barsContainer');
|
| 512 |
+
const circlesContainer = document.getElementById('circlesContainer');
|
| 513 |
+
const waveContainer = document.getElementById('waveContainer');
|
| 514 |
+
const wavePath = document.getElementById('wavePath');
|
| 515 |
+
const bidirectionalWaveContainer = document.getElementById('bidirectionalWaveContainer');
|
| 516 |
+
const bidirectionalWavePathTop = document.getElementById('bidirectionalWavePathTop');
|
| 517 |
+
const bidirectionalWavePathBottom = document.getElementById('bidirectionalWavePathBottom');
|
| 518 |
+
const roundedWaveContainer = document.getElementById('roundedWaveContainer');
|
| 519 |
+
const centerImage = document.getElementById('centerImage');
|
| 520 |
+
const roundedWave = document.getElementById('roundedWave');
|
| 521 |
+
const roundedWavePath = document.getElementById('roundedWavePath');
|
| 522 |
+
const particlesContainer = document.getElementById('particlesContainer');
|
| 523 |
+
const spectrumContainer = document.getElementById('spectrumContainer');
|
| 524 |
+
const radialContainer = document.getElementById('radialContainer');
|
| 525 |
+
const styleBtns = document.querySelectorAll('.visualizer-style-btn');
|
| 526 |
+
const sensitivitySlider = document.getElementById('sensitivity');
|
| 527 |
+
const smoothnessSlider = document.getElementById('smoothness');
|
| 528 |
+
const sensitivityValue = document.getElementById('sensitivityValue');
|
| 529 |
+
const smoothnessValue = document.getElementById('smoothnessValue');
|
| 530 |
+
const changeImageBtn = document.getElementById('changeImageBtn');
|
| 531 |
+
const imageUploadContainer = document.getElementById('imageUploadContainer');
|
| 532 |
+
const imageUpload = document.getElementById('imageUpload');
|
| 533 |
+
const imageUrl = document.getElementById('imageUrl');
|
| 534 |
+
const cancelImageBtn = document.getElementById('cancelImageBtn');
|
| 535 |
+
const applyImageBtn = document.getElementById('applyImageBtn');
|
| 536 |
+
|
| 537 |
+
// Set default image
|
| 538 |
+
centerImage.style.backgroundImage = 'url("https://i.ibb.co.com/kVvn0mqM/Sukkar-Shop-mini-logo.png")';
|
| 539 |
+
|
| 540 |
+
// Audio context variables
|
| 541 |
+
let audioContext;
|
| 542 |
+
let analyser;
|
| 543 |
+
let microphone;
|
| 544 |
+
let dataArray;
|
| 545 |
+
let animationId;
|
| 546 |
+
let isActive = false;
|
| 547 |
+
let currentStyle = 'bars';
|
| 548 |
+
let sensitivity = 100;
|
| 549 |
+
let smoothness = 5;
|
| 550 |
+
let lastValues = [];
|
| 551 |
+
|
| 552 |
+
// Initialize visualizers
|
| 553 |
+
initializeBars();
|
| 554 |
+
initializeSpectrum();
|
| 555 |
+
initializeRadial();
|
| 556 |
+
|
| 557 |
+
// Update slider values display
|
| 558 |
+
sensitivitySlider.addEventListener('input', function() {
|
| 559 |
+
sensitivity = parseInt(this.value);
|
| 560 |
+
sensitivityValue.textContent = `${sensitivity}%`;
|
| 561 |
+
});
|
| 562 |
+
|
| 563 |
+
smoothnessSlider.addEventListener('input', function() {
|
| 564 |
+
smoothness = parseInt(this.value);
|
| 565 |
+
smoothnessValue.textContent = smoothness;
|
| 566 |
+
});
|
| 567 |
+
|
| 568 |
+
function initializeBars() {
|
| 569 |
+
// Create 30 bars for the bar visualizer
|
| 570 |
+
for (let i = 0; i < 30; i++) {
|
| 571 |
+
const bar = document.createElement('div');
|
| 572 |
+
bar.className = 'bar';
|
| 573 |
+
barsContainer.appendChild(bar);
|
| 574 |
+
}
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
function initializeSpectrum() {
|
| 578 |
+
// Create 128 lines for the spectrum visualizer
|
| 579 |
+
for (let i = 0; i < 128; i++) {
|
| 580 |
+
const line = document.createElement('div');
|
| 581 |
+
line.className = 'spectrum-line';
|
| 582 |
+
line.style.left = `${(i / 128) * 100}%`;
|
| 583 |
+
spectrumContainer.appendChild(line);
|
| 584 |
+
|
| 585 |
+
// Initialize last values array
|
| 586 |
+
lastValues[i] = 0;
|
| 587 |
+
}
|
| 588 |
+
}
|
| 589 |
+
|
| 590 |
+
function initializeRadial() {
|
| 591 |
+
// Create 60 radial bars (6 groups of 10)
|
| 592 |
+
const centerX = 50;
|
| 593 |
+
const centerY = 50;
|
| 594 |
+
const radius = 40;
|
| 595 |
+
|
| 596 |
+
for (let group = 0; group < 6; group++) {
|
| 597 |
+
for (let i = 0; i < 10; i++) {
|
| 598 |
+
const angle = (group * 60 + i * 6) * (Math.PI / 180);
|
| 599 |
+
const x = centerX + radius * Math.cos(angle);
|
| 600 |
+
const y = centerY + radius * Math.sin(angle);
|
| 601 |
+
|
| 602 |
+
const bar = document.createElement('div');
|
| 603 |
+
bar.className = 'radial-bar';
|
| 604 |
+
bar.style.left = `${x}%`;
|
| 605 |
+
bar.style.top = `${y}%`;
|
| 606 |
+
bar.style.transform = `rotate(${group * 60 + i * 6}deg)`;
|
| 607 |
+
radialContainer.appendChild(bar);
|
| 608 |
+
}
|
| 609 |
+
}
|
| 610 |
+
}
|
| 611 |
+
|
| 612 |
+
// Style buttons event listeners
|
| 613 |
+
styleBtns.forEach(btn => {
|
| 614 |
+
btn.addEventListener('click', function() {
|
| 615 |
+
// Update active button
|
| 616 |
+
styleBtns.forEach(b => {
|
| 617 |
+
b.classList.remove('bg-blue-600', 'hover:bg-gray-600', 'active');
|
| 618 |
+
b.classList.add('bg-gray-700', 'hover:bg-gray-600');
|
| 619 |
+
});
|
| 620 |
+
this.classList.remove('bg-gray-700', 'hover:bg-gray-600');
|
| 621 |
+
this.classList.add('bg-blue-600', 'active');
|
| 622 |
+
|
| 623 |
+
// Set current style
|
| 624 |
+
currentStyle = this.dataset.style;
|
| 625 |
+
|
| 626 |
+
// Hide all containers
|
| 627 |
+
barsContainer.style.display = 'none';
|
| 628 |
+
circlesContainer.style.display = 'none';
|
| 629 |
+
waveContainer.style.display = 'none';
|
| 630 |
+
bidirectionalWaveContainer.style.display = 'none';
|
| 631 |
+
roundedWaveContainer.style.display = 'none';
|
| 632 |
+
particlesContainer.style.display = 'none';
|
| 633 |
+
spectrumContainer.style.display = 'none';
|
| 634 |
+
radialContainer.style.display = 'none';
|
| 635 |
+
|
| 636 |
+
// Show selected container
|
| 637 |
+
if (currentStyle === 'bars') {
|
| 638 |
+
barsContainer.style.display = 'flex';
|
| 639 |
+
} else if (currentStyle === 'circles') {
|
| 640 |
+
circlesContainer.style.display = 'block';
|
| 641 |
+
} else if (currentStyle === 'wave') {
|
| 642 |
+
waveContainer.style.display = 'block';
|
| 643 |
+
} else if (currentStyle === 'bidirectional') {
|
| 644 |
+
bidirectionalWaveContainer.style.display = 'block';
|
| 645 |
+
} else if (currentStyle === 'rounded') {
|
| 646 |
+
roundedWaveContainer.style.display = 'flex';
|
| 647 |
+
} else if (currentStyle === 'particles') {
|
| 648 |
+
particlesContainer.style.display = 'block';
|
| 649 |
+
} else if (currentStyle === 'spectrum') {
|
| 650 |
+
spectrumContainer.style.display = 'block';
|
| 651 |
+
} else if (currentStyle === 'radial') {
|
| 652 |
+
radialContainer.style.display = 'block';
|
| 653 |
+
}
|
| 654 |
+
});
|
| 655 |
+
});
|
| 656 |
+
|
| 657 |
+
// Set bars as default
|
| 658 |
+
document.querySelector('[data-style="bars"]').click();
|
| 659 |
+
|
| 660 |
+
// Image upload functionality
|
| 661 |
+
changeImageBtn.addEventListener('click', function() {
|
| 662 |
+
imageUploadContainer.classList.add('active');
|
| 663 |
+
});
|
| 664 |
+
|
| 665 |
+
cancelImageBtn.addEventListener('click', function() {
|
| 666 |
+
imageUploadContainer.classList.remove('active');
|
| 667 |
+
imageUrl.value = '';
|
| 668 |
+
imageUpload.value = '';
|
| 669 |
+
});
|
| 670 |
+
|
| 671 |
+
applyImageBtn.addEventListener('click', function() {
|
| 672 |
+
if (imageUrl.value) {
|
| 673 |
+
// Use URL if provided
|
| 674 |
+
centerImage.style.backgroundImage = `url("${imageUrl.value}")`;
|
| 675 |
+
imageUploadContainer.classList.remove('active');
|
| 676 |
+
imageUrl.value = '';
|
| 677 |
+
} else if (imageUpload.files && imageUpload.files[0]) {
|
| 678 |
+
// Use uploaded file if provided
|
| 679 |
+
const reader = new FileReader();
|
| 680 |
+
reader.onload = function(e) {
|
| 681 |
+
centerImage.style.backgroundImage = `url("${e.target.result}")`;
|
| 682 |
+
imageUploadContainer.classList.remove('active');
|
| 683 |
+
imageUpload.value = '';
|
| 684 |
+
};
|
| 685 |
+
reader.readAsDataURL(imageUpload.files[0]);
|
| 686 |
+
}
|
| 687 |
+
});
|
| 688 |
+
|
| 689 |
+
// Start microphone
|
| 690 |
+
startBtn.addEventListener('click', async function() {
|
| 691 |
+
try {
|
| 692 |
+
const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
| 693 |
+
|
| 694 |
+
// Create audio context
|
| 695 |
+
audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
| 696 |
+
analyser = audioContext.createAnalyser();
|
| 697 |
+
analyser.fftSize = 256;
|
| 698 |
+
|
| 699 |
+
const source = audioContext.createMediaStreamSource(stream);
|
| 700 |
+
source.connect(analyser);
|
| 701 |
+
|
| 702 |
+
dataArray = new Uint8Array(analyser.frequencyBinCount);
|
| 703 |
+
|
| 704 |
+
isActive = true;
|
| 705 |
+
startBtn.disabled = true;
|
| 706 |
+
stopBtn.disabled = false;
|
| 707 |
+
statusEl.innerHTML = '<i class="fas fa-check-circle mr-2 text-green-400"></i> Microphone active';
|
| 708 |
+
|
| 709 |
+
// Start visualization
|
| 710 |
+
visualize();
|
| 711 |
+
} catch (err) {
|
| 712 |
+
console.error('Error accessing microphone:', err);
|
| 713 |
+
statusEl.innerHTML = '<i class="fas fa-exclamation-circle mr-2 text-red-400"></i> Microphone access denied';
|
| 714 |
+
}
|
| 715 |
+
});
|
| 716 |
+
|
| 717 |
+
// Stop microphone
|
| 718 |
+
stopBtn.addEventListener('click', function() {
|
| 719 |
+
if (audioContext) {
|
| 720 |
+
if (audioContext.state !== 'closed') {
|
| 721 |
+
audioContext.close();
|
| 722 |
+
}
|
| 723 |
+
}
|
| 724 |
+
|
| 725 |
+
if (microphone) {
|
| 726 |
+
microphone.getTracks().forEach(track => track.stop());
|
| 727 |
+
}
|
| 728 |
+
|
| 729 |
+
isActive = false;
|
| 730 |
+
cancelAnimationFrame(animationId);
|
| 731 |
+
|
| 732 |
+
startBtn.disabled = false;
|
| 733 |
+
stopBtn.disabled = true;
|
| 734 |
+
statusEl.innerHTML = '<i class="fas fa-info-circle mr-2"></i> Mic inactive ❗';
|
| 735 |
+
|
| 736 |
+
// Reset visualizations
|
| 737 |
+
resetVisualizers();
|
| 738 |
+
});
|
| 739 |
+
|
| 740 |
+
function resetVisualizers() {
|
| 741 |
+
// Reset bars
|
| 742 |
+
const bars = document.querySelectorAll('.bar');
|
| 743 |
+
bars.forEach(bar => {
|
| 744 |
+
bar.style.transform = 'scaleY(0)';
|
| 745 |
+
});
|
| 746 |
+
|
| 747 |
+
// Reset circles
|
| 748 |
+
circlesContainer.innerHTML = '';
|
| 749 |
+
|
| 750 |
+
// Reset wave
|
| 751 |
+
wavePath.setAttribute('d', '');
|
| 752 |
+
|
| 753 |
+
// Reset bidirectional wave
|
| 754 |
+
bidirectionalWavePathTop.setAttribute('d', '');
|
| 755 |
+
bidirectionalWavePathBottom.setAttribute('d', '');
|
| 756 |
+
|
| 757 |
+
// Reset rounded wave
|
| 758 |
+
roundedWavePath.setAttribute('d', '');
|
| 759 |
+
|
| 760 |
+
// Reset particles
|
| 761 |
+
particlesContainer.innerHTML = '';
|
| 762 |
+
|
| 763 |
+
// Reset spectrum
|
| 764 |
+
const spectrumLines = document.querySelectorAll('.spectrum-line');
|
| 765 |
+
spectrumLines.forEach(line => {
|
| 766 |
+
line.style.height = '0';
|
| 767 |
+
});
|
| 768 |
+
|
| 769 |
+
// Reset radial
|
| 770 |
+
const radialBars = document.querySelectorAll('.radial-bar');
|
| 771 |
+
radialBars.forEach(bar => {
|
| 772 |
+
bar.style.height = '0';
|
| 773 |
+
});
|
| 774 |
+
}
|
| 775 |
+
|
| 776 |
+
// Visualization function
|
| 777 |
+
function visualize() {
|
| 778 |
+
if (!isActive) return;
|
| 779 |
+
|
| 780 |
+
analyser.getByteFrequencyData(dataArray);
|
| 781 |
+
|
| 782 |
+
if (currentStyle === 'bars') {
|
| 783 |
+
// Update bars
|
| 784 |
+
const bars = document.querySelectorAll('.bar');
|
| 785 |
+
for (let i = 0; i < bars.length; i++) {
|
| 786 |
+
const index = Math.floor(i * (dataArray.length / bars.length));
|
| 787 |
+
const rawValue = dataArray[index] / 255;
|
| 788 |
+
const value = applySmoothing(rawValue * (sensitivity / 100), i);
|
| 789 |
+
bars[i].style.transform = `scaleY(${value})`;
|
| 790 |
+
}
|
| 791 |
+
}
|
| 792 |
+
else if (currentStyle === 'circles') {
|
| 793 |
+
// Clear old circles
|
| 794 |
+
circlesContainer.innerHTML = '';
|
| 795 |
+
|
| 796 |
+
// Create new circles based on frequency data
|
| 797 |
+
for (let i = 0; i < dataArray.length; i += 5) {
|
| 798 |
+
const value = dataArray[i] / 255;
|
| 799 |
+
if (value > 0.2) { // Only show significant frequencies
|
| 800 |
+
const circle = document.createElement('div');
|
| 801 |
+
circle.className = 'circle pulse';
|
| 802 |
+
|
| 803 |
+
// Random position
|
| 804 |
+
const x = Math.random() * 100;
|
| 805 |
+
const y = Math.random() * 100;
|
| 806 |
+
|
| 807 |
+
// Size based on frequency value
|
| 808 |
+
const size = 5 + (value * 100 * (sensitivity / 100));
|
| 809 |
+
|
| 810 |
+
circle.style.width = `${size}px`;
|
| 811 |
+
circle.style.height = `${size}px`;
|
| 812 |
+
circle.style.left = `${x}%`;
|
| 813 |
+
circle.style.top = `${y}%`;
|
| 814 |
+
circle.style.opacity = value;
|
| 815 |
+
circle.style.animationDelay = `${Math.random() * 0.5}s`;
|
| 816 |
+
|
| 817 |
+
circlesContainer.appendChild(circle);
|
| 818 |
+
}
|
| 819 |
+
}
|
| 820 |
+
}
|
| 821 |
+
else if (currentStyle === 'wave') {
|
| 822 |
+
// Create wave path
|
| 823 |
+
let pathData = 'M 0 100';
|
| 824 |
+
const segmentWidth = 1000 / (dataArray.length - 1);
|
| 825 |
+
|
| 826 |
+
for (let i = 0; i < dataArray.length; i++) {
|
| 827 |
+
const rawValue = dataArray[i] / 255;
|
| 828 |
+
const value = applySmoothing(rawValue, i);
|
| 829 |
+
const y = 100 - (value * 100 * (sensitivity / 100));
|
| 830 |
+
pathData += ` L ${i * segmentWidth} ${y}`;
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
pathData += ' L 1000 100 Z';
|
| 834 |
+
wavePath.setAttribute('d', pathData);
|
| 835 |
+
}
|
| 836 |
+
else if (currentStyle === 'bidirectional') {
|
| 837 |
+
// Create bidirectional wave path
|
| 838 |
+
let pathDataTop = 'M 0 100';
|
| 839 |
+
let pathDataBottom = 'M 0 100';
|
| 840 |
+
const segmentWidth = 1000 / (dataArray.length - 1);
|
| 841 |
+
|
| 842 |
+
for (let i = 0; i < dataArray.length; i++) {
|
| 843 |
+
const rawValue = dataArray[i] / 255;
|
| 844 |
+
const value = applySmoothing(rawValue, i);
|
| 845 |
+
const yTop = 100 - (value * 100 * (sensitivity / 100));
|
| 846 |
+
const yBottom = 100 + (value * 100 * (sensitivity / 100));
|
| 847 |
+
|
| 848 |
+
pathDataTop += ` L ${i * segmentWidth} ${yTop}`;
|
| 849 |
+
pathDataBottom += ` L ${i * segmentWidth} ${yBottom}`;
|
| 850 |
+
}
|
| 851 |
+
|
| 852 |
+
pathDataTop += ' L 1000 100 Z';
|
| 853 |
+
pathDataBottom += ' L 1000 100 Z';
|
| 854 |
+
|
| 855 |
+
bidirectionalWavePathTop.setAttribute('d', pathDataTop);
|
| 856 |
+
bidirectionalWavePathBottom.setAttribute('d', pathDataBottom);
|
| 857 |
+
}
|
| 858 |
+
else if (currentStyle === 'rounded') {
|
| 859 |
+
// Create rounded wave path
|
| 860 |
+
const centerX = 500;
|
| 861 |
+
const centerY = 500;
|
| 862 |
+
const radius = 400;
|
| 863 |
+
const numPoints = dataArray.length;
|
| 864 |
+
let pathData = '';
|
| 865 |
+
|
| 866 |
+
for (let i = 0; i <= numPoints; i++) {
|
| 867 |
+
const index = i % numPoints;
|
| 868 |
+
const rawValue = dataArray[index] / 255;
|
| 869 |
+
const value = applySmoothing(rawValue, index);
|
| 870 |
+
const angle = (i / numPoints) * Math.PI * 2;
|
| 871 |
+
const pointRadius = radius + (value * 200 * (sensitivity / 100));
|
| 872 |
+
|
| 873 |
+
const x = centerX + pointRadius * Math.cos(angle);
|
| 874 |
+
const y = centerY + pointRadius * Math.sin(angle);
|
| 875 |
+
|
| 876 |
+
if (i === 0) {
|
| 877 |
+
pathData = `M ${x} ${y}`;
|
| 878 |
+
} else {
|
| 879 |
+
pathData += ` L ${x} ${y}`;
|
| 880 |
+
}
|
| 881 |
+
}
|
| 882 |
+
|
| 883 |
+
pathData += ' Z';
|
| 884 |
+
roundedWavePath.setAttribute('d', pathData);
|
| 885 |
+
|
| 886 |
+
// Pulse the center image based on average volume
|
| 887 |
+
const avgValue = dataArray.reduce((sum, val) => sum + val, 0) / dataArray.length / 255;
|
| 888 |
+
centerImage.style.transform = `scale(${1 + avgValue * 0.2})`;
|
| 889 |
+
}
|
| 890 |
+
else if (currentStyle === 'particles') {
|
| 891 |
+
// Clear old particles
|
| 892 |
+
particlesContainer.innerHTML = '';
|
| 893 |
+
|
| 894 |
+
// Create particles based on frequency data
|
| 895 |
+
for (let i = 0; i < dataArray.length; i += 3) {
|
| 896 |
+
const value = dataArray[i] / 255;
|
| 897 |
+
if (value > 0.1) {
|
| 898 |
+
const particle = document.createElement('div');
|
| 899 |
+
particle.className = 'particle';
|
| 900 |
+
|
| 901 |
+
// Position based on frequency index
|
| 902 |
+
const x = (i / dataArray.length) * 100;
|
| 903 |
+
const y = 50 + (Math.random() * 40 - 20);
|
| 904 |
+
|
| 905 |
+
// Size and opacity based on value
|
| 906 |
+
const size = 5 + (value * 20 * (sensitivity / 100));
|
| 907 |
+
const opacity = 0.3 + (value * 0.7);
|
| 908 |
+
|
| 909 |
+
// Color variation based on frequency
|
| 910 |
+
const hue = 240 + (i / dataArray.length * 60);
|
| 911 |
+
|
| 912 |
+
particle.style.width = `${size}px`;
|
| 913 |
+
particle.style.height = `${size}px`;
|
| 914 |
+
particle.style.left = `${x}%`;
|
| 915 |
+
particle.style.top = `${y}%`;
|
| 916 |
+
particle.style.opacity = opacity;
|
| 917 |
+
particle.style.background = `linear-gradient(45deg, hsl(${hue}, 80%, 60%), hsl(${hue + 30}, 80%, 60%))`;
|
| 918 |
+
particle.style.transform = `translate(-50%, -50%) scale(${1 + value})`;
|
| 919 |
+
|
| 920 |
+
particlesContainer.appendChild(particle);
|
| 921 |
+
}
|
| 922 |
+
}
|
| 923 |
+
}
|
| 924 |
+
else if (currentStyle === 'spectrum') {
|
| 925 |
+
// Update spectrum lines
|
| 926 |
+
const spectrumLines = document.querySelectorAll('.spectrum-line');
|
| 927 |
+
|
| 928 |
+
for (let i = 0; i < spectrumLines.length; i++) {
|
| 929 |
+
const index = Math.floor(i * (dataArray.length / spectrumLines.length));
|
| 930 |
+
const rawValue = dataArray[index] / 255;
|
| 931 |
+
const value = applySmoothing(rawValue * (sensitivity / 100), i);
|
| 932 |
+
|
| 933 |
+
spectrumLines[i].style.height = `${value * 100}%`;
|
| 934 |
+
spectrumLines[i].style.opacity = 0.5 + (value * 0.5);
|
| 935 |
+
|
| 936 |
+
// Color variation based on frequency
|
| 937 |
+
const hue = 200 + (i / spectrumLines.length * 160);
|
| 938 |
+
spectrumLines[i].style.background = `linear-gradient(to top, hsl(${hue}, 80%, 60%), hsl(${hue + 20}, 80%, 60%))`;
|
| 939 |
+
}
|
| 940 |
+
}
|
| 941 |
+
else if (currentStyle === 'radial') {
|
| 942 |
+
// Update radial bars
|
| 943 |
+
const radialBars = document.querySelectorAll('.radial-bar');
|
| 944 |
+
|
| 945 |
+
for (let i = 0; i < radialBars.length; i++) {
|
| 946 |
+
const index = Math.floor(i * (dataArray.length / radialBars.length));
|
| 947 |
+
const rawValue = dataArray[index] / 255;
|
| 948 |
+
const value = applySmoothing(rawValue * (sensitivity / 100), i);
|
| 949 |
+
|
| 950 |
+
radialBars[i].style.height = `${value * 50}px`;
|
| 951 |
+
radialBars[i].style.opacity = 0.5 + (value * 0.5);
|
| 952 |
+
|
| 953 |
+
// Color variation based on position
|
| 954 |
+
const hue = 240 + (i / radialBars.length * 120);
|
| 955 |
+
radialBars[i].style.background = `linear-gradient(to top, hsl(${hue}, 80%, 60%), hsl(${hue + 30}, 80%, 60%))`;
|
| 956 |
+
}
|
| 957 |
+
}
|
| 958 |
+
|
| 959 |
+
animationId = requestAnimationFrame(visualize);
|
| 960 |
+
}
|
| 961 |
+
|
| 962 |
+
// Apply smoothing to values for less jittery animations
|
| 963 |
+
function applySmoothing(newValue, index) {
|
| 964 |
+
if (!lastValues[index]) {
|
| 965 |
+
lastValues[index] = newValue;
|
| 966 |
+
return newValue;
|
| 967 |
+
}
|
| 968 |
+
|
| 969 |
+
// Apply smoothing based on the smoothness setting
|
| 970 |
+
const smoothedValue = lastValues[index] + (newValue - lastValues[index]) / smoothness;
|
| 971 |
+
lastValues[index] = smoothedValue;
|
| 972 |
+
return smoothedValue;
|
| 973 |
+
}
|
| 974 |
+
|
| 975 |
+
// Instructions for the user
|
| 976 |
+
console.log('Click "Start Microphone" to begin visualizing your voice. Choose between different visualization styles.');
|
| 977 |
+
});
|
| 978 |
+
</script>
|
| 979 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=almahmud/simple-sound-visualizer" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
| 980 |
+
</html>
|
prompts.txt
ADDED
|
File without changes
|