Skip to content

Developer Guide

Kell Win edited this page Jan 22, 2026 · 1 revision

Developer Guide

GlassSync is a Single-Page Application (SPA) built with Vanilla JavaScript, HTML5, and CSS3. It requires no build tools, npm, or backend servers.

Core Technologies

  • Web Audio API: Used for decoding audio data to generate the visualization.
  • HTML5 Canvas: Renders the waveform visualization efficiently.
  • requestAnimationFrame: Handles the smooth scrolling of the Karaoke Preview and scrubber updates (60fps).
  • CSS Variables: Manages the glassmorphism theme (--glass-bg, --accent-color).

Code Structure

The logic is contained within the <script> tag in index.html.

Key State Variables

  • audio: The HTML5 Audio object.
  • lyrics: An array of objects containing { id, text, start, end }.
  • waveformData: The normalized array of audio peaks used for drawing the canvas.

Important Functions

  1. generateWaveform(buffer): Decodes the MP3 array buffer, downsamples the PCM data to ~1200 bars, and normalizes the height for the canvas.
  2. previewLoop(): The recursive animation loop that handles the Preview Mode scrolling and highlighting.
  3. renderSyncUI(): Dynamically rebuilds the DOM elements for the lyric list based on the lyrics array (used after loading or deleting lines).

Customization

To change the color scheme, look for the :root variables at the top of the <style> block:

:root {
    --accent-color: #0a84ff;  /* Main Action Color */
    --active-line-bg: rgba(10, 132, 255, 0.6); /* Highlight Color */
}

Clone this wiki locally