queric commited on
Commit
fd508cf
Β·
verified Β·
1 Parent(s): 4b25a86

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +150 -32
index.html CHANGED
@@ -187,11 +187,90 @@
187
  margin: 0 1.5rem 2rem;
188
  }
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  /* ─── Drop Zone ─── */
191
  .drop-zone {
192
  border: 2px dashed var(--gray-200);
193
  border-radius: var(--radius);
194
- padding: 2.5rem 1.5rem;
195
  text-align: center;
196
  background: var(--gray-50);
197
  cursor: pointer;
@@ -209,40 +288,27 @@
209
  display: none;
210
  }
211
 
212
- .drop-icon {
213
- width: 48px;
214
- height: 48px;
215
- background: var(--blue-50);
216
- border: 1px solid var(--blue-100);
217
- border-radius: 12px;
218
- display: flex;
219
- align-items: center;
220
- justify-content: center;
221
- font-size: 22px;
222
- margin: 0 auto 0.85rem;
223
- }
224
-
225
  .drop-zone h3 {
226
- font-size: 0.95rem;
227
  font-weight: 600;
228
  color: var(--gray-800);
229
  margin-bottom: 0.25rem;
230
  }
231
 
232
  .drop-zone p {
233
- font-size: 0.82rem;
234
  color: var(--gray-400);
235
  }
236
 
237
  .btn-upload {
238
  display: inline-block;
239
- margin-top: 1rem;
240
- padding: 0.5rem 1.25rem;
241
  background: var(--blue-600);
242
  color: #fff;
243
  border: none;
244
  border-radius: var(--radius-sm);
245
- font-size: 0.85rem;
246
  font-weight: 600;
247
  cursor: pointer;
248
  transition: background 0.2s, box-shadow 0.2s;
@@ -505,12 +571,39 @@
505
  <!-- Main Demo Card -->
506
  <div class="card">
507
 
508
- <!-- Drop Zone -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
509
  <div class="drop-zone" id="dropZone">
510
- <div class="drop-icon">🎡</div>
511
- <h3>Drop your audio file here</h3>
512
  <p>MP3, WAV, FLAC, OGG β€” processed locally on your device</p>
513
- <button class="btn-upload" onclick="document.getElementById('fileInput').click()">Browse File</button>
514
  <input type="file" id="fileInput" accept="audio/*" />
515
  </div>
516
 
@@ -526,7 +619,7 @@
526
  <div class="visualizer-section">
527
  <div class="visualizer-wrap">
528
  <canvas id="canvas"></canvas>
529
- <div class="vis-idle" id="visIdle">Load a file to see live waveform</div>
530
  </div>
531
  </div>
532
 
@@ -603,6 +696,33 @@
603
  const muteBtn = document.getElementById("muteBtn");
604
  const canvasCtx = canvas.getContext("2d");
605
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
606
  dropZone.addEventListener("dragover", (e) => {
607
  e.preventDefault();
608
  dropZone.classList.add("dragover");
@@ -611,13 +731,14 @@
611
  dropZone.addEventListener("drop", (e) => {
612
  e.preventDefault();
613
  dropZone.classList.remove("dragover");
614
- if (e.dataTransfer.files.length) loadFile(e.dataTransfer.files[0]);
615
  });
616
  fileInput.addEventListener("change", (e) => {
617
- if (e.target.files.length) loadFile(e.target.files[0]);
618
  });
619
 
620
- function loadFile(file) {
 
621
  currentFile = file;
622
  const reader = new FileReader();
623
  reader.onload = (e) => {
@@ -632,6 +753,7 @@
632
  visIdle.style.display = "none";
633
  }
634
 
 
635
  function initAudioGraph() {
636
  if (isInitialized) return;
637
  ctx = new (window.AudioContext || window.webkitAudioContext)();
@@ -798,19 +920,16 @@
798
  const now = ctx.currentTime;
799
 
800
  if (mode === "original") {
801
- // Full Original Track
802
  vocalDryGain.gain.linearRampToValueAtTime(1.0, now + 0.12);
803
  vocalWetGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
804
  vocalBassGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
805
  vocalTrebleGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
806
  } else if (mode === "remove") {
807
- // Remove Vocals (Instrumental)
808
  vocalDryGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
809
  vocalWetGain.gain.linearRampToValueAtTime(0.95, now + 0.12);
810
  vocalBassGain.gain.linearRampToValueAtTime(0.35, now + 0.12);
811
  vocalTrebleGain.gain.linearRampToValueAtTime(0.30, now + 0.12);
812
  } else if (mode === "vocalOnly") {
813
- // Vocal Only (Acapella = Original - Instrumental)
814
  vocalDryGain.gain.linearRampToValueAtTime(1.0, now + 0.12);
815
  vocalWetGain.gain.linearRampToValueAtTime(-0.95, now + 0.12);
816
  vocalBassGain.gain.linearRampToValueAtTime(-0.35, now + 0.12);
@@ -855,7 +974,7 @@
855
  document.getElementById("trebleVal").innerText = (e.target.value > 0 ? "+" : "") + e.target.value + " dB";
856
  });
857
 
858
- // ─── High-Speed Offline Exporter & Downloader ────────────────────
859
  async function downloadProcessedAudio() {
860
  if (!rawAudioArrayBuffer) return;
861
  downloadBtn.innerText = "⏳ Rendering Audio...";
@@ -886,7 +1005,6 @@
886
  offTreble.type = "highshelf"; offTreble.frequency.value = 10000;
887
  offTreble.gain.value = trebleFilter ? trebleFilter.gain.value : 0;
888
 
889
- // Mode Gains for offline render
890
  let dryVal = 1.0, wetVal = 0.0, bassVal = 0.0, trebVal = 0.0;
891
  if (currentMode === "remove") {
892
  dryVal = 0.0; wetVal = 0.95; bassVal = 0.35; trebVal = 0.30;
 
187
  margin: 0 1.5rem 2rem;
188
  }
189
 
190
+ /* ─── Demo Tracks Cards ─── */
191
+ .demo-section {
192
+ margin-bottom: 1.75rem;
193
+ }
194
+
195
+ .demo-grid {
196
+ display: grid;
197
+ grid-template-columns: repeat(2, 1fr);
198
+ gap: 1rem;
199
+ }
200
+
201
+ @media (max-width: 500px) {
202
+ .demo-grid { grid-template-columns: 1fr; }
203
+ }
204
+
205
+ .demo-card {
206
+ background: var(--blue-50);
207
+ border: 1px solid var(--blue-100);
208
+ border-radius: var(--radius);
209
+ padding: 1rem 1.25rem;
210
+ display: flex;
211
+ align-items: center;
212
+ justify-content: space-between;
213
+ cursor: pointer;
214
+ transition: all 0.2s ease;
215
+ }
216
+
217
+ .demo-card:hover {
218
+ border-color: var(--blue-400);
219
+ background: #e0f2fe;
220
+ transform: translateY(-2px);
221
+ box-shadow: var(--shadow);
222
+ }
223
+
224
+ .demo-card.active {
225
+ border-color: var(--blue-600);
226
+ background: #dbeafe;
227
+ box-shadow: 0 0 0 2px var(--blue-500);
228
+ }
229
+
230
+ .demo-left {
231
+ display: flex;
232
+ align-items: center;
233
+ gap: 0.85rem;
234
+ }
235
+
236
+ .demo-icon {
237
+ width: 38px;
238
+ height: 38px;
239
+ background: var(--white);
240
+ border: 1px solid var(--blue-100);
241
+ border-radius: 10px;
242
+ display: flex;
243
+ align-items: center;
244
+ justify-content: center;
245
+ font-size: 18px;
246
+ }
247
+
248
+ .demo-title {
249
+ font-size: 0.9rem;
250
+ font-weight: 700;
251
+ color: var(--gray-900);
252
+ }
253
+
254
+ .demo-sub {
255
+ font-size: 0.75rem;
256
+ color: var(--gray-600);
257
+ }
258
+
259
+ .demo-play-badge {
260
+ font-size: 0.75rem;
261
+ font-weight: 700;
262
+ color: var(--blue-600);
263
+ background: var(--white);
264
+ padding: 0.3rem 0.75rem;
265
+ border-radius: 9999px;
266
+ border: 1px solid var(--blue-100);
267
+ }
268
+
269
  /* ─── Drop Zone ─── */
270
  .drop-zone {
271
  border: 2px dashed var(--gray-200);
272
  border-radius: var(--radius);
273
+ padding: 1.75rem 1.5rem;
274
  text-align: center;
275
  background: var(--gray-50);
276
  cursor: pointer;
 
288
  display: none;
289
  }
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  .drop-zone h3 {
292
+ font-size: 0.9rem;
293
  font-weight: 600;
294
  color: var(--gray-800);
295
  margin-bottom: 0.25rem;
296
  }
297
 
298
  .drop-zone p {
299
+ font-size: 0.8rem;
300
  color: var(--gray-400);
301
  }
302
 
303
  .btn-upload {
304
  display: inline-block;
305
+ margin-top: 0.75rem;
306
+ padding: 0.45rem 1.1rem;
307
  background: var(--blue-600);
308
  color: #fff;
309
  border: none;
310
  border-radius: var(--radius-sm);
311
+ font-size: 0.82rem;
312
  font-weight: 600;
313
  cursor: pointer;
314
  transition: background 0.2s, box-shadow 0.2s;
 
571
  <!-- Main Demo Card -->
572
  <div class="card">
573
 
574
+ <!-- Demo Songs Quick Load Section -->
575
+ <div class="demo-section">
576
+ <div class="section-label">⚑ Click to Play Demo Tracks</div>
577
+ <div class="demo-grid">
578
+ <div class="demo-card" id="demo1Card" onclick="loadDemoTrack('1.mp3', 'Demo Song 1')">
579
+ <div class="demo-left">
580
+ <div class="demo-icon">🎡</div>
581
+ <div>
582
+ <div class="demo-title">Demo Song 1</div>
583
+ <div class="demo-sub">1.mp3</div>
584
+ </div>
585
+ </div>
586
+ <span class="demo-play-badge">β–Ά Play</span>
587
+ </div>
588
+
589
+ <div class="demo-card" id="demo2Card" onclick="loadDemoTrack('2.mp3', 'Demo Song 2')">
590
+ <div class="demo-left">
591
+ <div class="demo-icon">🎢</div>
592
+ <div>
593
+ <div class="demo-title">Demo Song 2</div>
594
+ <div class="demo-sub">2.mp3</div>
595
+ </div>
596
+ </div>
597
+ <span class="demo-play-badge">β–Ά Play</span>
598
+ </div>
599
+ </div>
600
+ </div>
601
+
602
+ <!-- Or Drop Custom File -->
603
  <div class="drop-zone" id="dropZone">
604
+ <h3>Or upload your own audio file</h3>
 
605
  <p>MP3, WAV, FLAC, OGG β€” processed locally on your device</p>
606
+ <button class="btn-upload" onclick="document.getElementById('fileInput').click()">Browse Custom File</button>
607
  <input type="file" id="fileInput" accept="audio/*" />
608
  </div>
609
 
 
619
  <div class="visualizer-section">
620
  <div class="visualizer-wrap">
621
  <canvas id="canvas"></canvas>
622
+ <div class="vis-idle" id="visIdle">Load or click a demo song to view live waveform</div>
623
  </div>
624
  </div>
625
 
 
696
  const muteBtn = document.getElementById("muteBtn");
697
  const canvasCtx = canvas.getContext("2d");
698
 
699
+ // ─── Demo Song Loader (1.mp3 / 2.mp3) ─────────────────────────────
700
+ async function loadDemoTrack(fileName, title) {
701
+ document.querySelectorAll(".demo-card").forEach(c => c.classList.remove("active"));
702
+ if (fileName === "1.mp3") document.getElementById("demo1Card").classList.add("active");
703
+ if (fileName === "2.mp3") document.getElementById("demo2Card").classList.add("active");
704
+
705
+ currentFile = { name: title };
706
+ audio.src = fileName;
707
+ audio.play();
708
+ initAudioGraph();
709
+ visIdle.style.display = "none";
710
+
711
+ downloadBtn.disabled = true;
712
+ downloadBtn.innerText = "⏳ Loading Track...";
713
+
714
+ try {
715
+ const res = await fetch(fileName);
716
+ rawAudioArrayBuffer = await res.arrayBuffer();
717
+ downloadBtn.disabled = false;
718
+ downloadBtn.innerText = "πŸ“₯ Download Processed Audio";
719
+ } catch (err) {
720
+ console.error("Could not load ArrayBuffer for download", err);
721
+ downloadBtn.innerText = "πŸ“₯ Download Processed Audio";
722
+ }
723
+ }
724
+
725
+ // ─── Custom File Drop & Upload ─────────────────────────────────────
726
  dropZone.addEventListener("dragover", (e) => {
727
  e.preventDefault();
728
  dropZone.classList.add("dragover");
 
731
  dropZone.addEventListener("drop", (e) => {
732
  e.preventDefault();
733
  dropZone.classList.remove("dragover");
734
+ if (e.dataTransfer.files.length) loadCustomFile(e.dataTransfer.files[0]);
735
  });
736
  fileInput.addEventListener("change", (e) => {
737
+ if (e.target.files.length) loadCustomFile(e.target.files[0]);
738
  });
739
 
740
+ function loadCustomFile(file) {
741
+ document.querySelectorAll(".demo-card").forEach(c => c.classList.remove("active"));
742
  currentFile = file;
743
  const reader = new FileReader();
744
  reader.onload = (e) => {
 
753
  visIdle.style.display = "none";
754
  }
755
 
756
+ // ─── Web Audio API Graph Setup ─────────────────────────────────────
757
  function initAudioGraph() {
758
  if (isInitialized) return;
759
  ctx = new (window.AudioContext || window.webkitAudioContext)();
 
920
  const now = ctx.currentTime;
921
 
922
  if (mode === "original") {
 
923
  vocalDryGain.gain.linearRampToValueAtTime(1.0, now + 0.12);
924
  vocalWetGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
925
  vocalBassGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
926
  vocalTrebleGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
927
  } else if (mode === "remove") {
 
928
  vocalDryGain.gain.linearRampToValueAtTime(0.0, now + 0.12);
929
  vocalWetGain.gain.linearRampToValueAtTime(0.95, now + 0.12);
930
  vocalBassGain.gain.linearRampToValueAtTime(0.35, now + 0.12);
931
  vocalTrebleGain.gain.linearRampToValueAtTime(0.30, now + 0.12);
932
  } else if (mode === "vocalOnly") {
 
933
  vocalDryGain.gain.linearRampToValueAtTime(1.0, now + 0.12);
934
  vocalWetGain.gain.linearRampToValueAtTime(-0.95, now + 0.12);
935
  vocalBassGain.gain.linearRampToValueAtTime(-0.35, now + 0.12);
 
974
  document.getElementById("trebleVal").innerText = (e.target.value > 0 ? "+" : "") + e.target.value + " dB";
975
  });
976
 
977
+ // ─── Offline Exporter & Downloader ────────────────────────────────
978
  async function downloadProcessedAudio() {
979
  if (!rawAudioArrayBuffer) return;
980
  downloadBtn.innerText = "⏳ Rendering Audio...";
 
1005
  offTreble.type = "highshelf"; offTreble.frequency.value = 10000;
1006
  offTreble.gain.value = trebleFilter ? trebleFilter.gain.value : 0;
1007
 
 
1008
  let dryVal = 1.0, wetVal = 0.0, bassVal = 0.0, trebVal = 0.0;
1009
  if (currentMode === "remove") {
1010
  dryVal = 0.0; wetVal = 0.95; bassVal = 0.35; trebVal = 0.30;