Offline-First PWA

Guitar Theory

Fretboard drills and theory for guitarists — installable, dependency-free, and usable with no signal.

PHP JavaScript Tailwind CSS Web Audio API PWA
01

Overview

A practice site for guitarists: thirteen tools covering scales, triads, chords, intervals, ear training, progression analysis, a tuner and a metronome. It installs to the home screen as a progressive web app and keeps working when the connection does not — which is usually where a guitar actually gets played.

02

The Problem

03

The Solution

Every note the site prints is generated from letter-and-interval rules rather than looked up in a table. A note is a letter plus an accidental, so a triad is spelled on every other letter name — which is why A♯ major comes out A♯ C♯♯ E♯ and G♭ diminished comes out G♭ B♭♭ D♭♭, instead of the tidy-looking enharmonics a table would return. Because the theory is generated, it can be audited by walking the entire space rather than sampling it.

assets/theory.js
// The note `letterSteps` letters above the root, `semitones` semitones up.
function spellAbove(root, letterSteps, semitones) {
  var letter  = LETTERS[(LETTERS.indexOf(root.letter) + letterSteps) % 7];
  var desired = (pitchClass(root) + semitones) % 12;

  // How far the plain letter sits from the pitch we need — that gap
  // is the accidental, up to a double sharp or double flat.
  var diff = ((desired - LETTER_PC[letter]) % 12 + 12) % 12;
  if (diff > 6) diff -= 12;

  for (var acc in ACC_OFFSET) {
    if (ACC_OFFSET[acc] === diff) return { letter: letter, acc: acc };
  }
  return null;
}

// A triad is the root plus a third and a fifth — two letters up, then four.
// A# major -> A# C## E#, never A# Db F.
function buildTriad(rootText, intervals) {
  var root = parseNote(rootText);
  return [root, spellAbove(root, 2, intervals[0]), spellAbove(root, 4, intervals[1])];
}

The same primitive spells triads, seven-note scales and chord tones, so one rule keeps every page in agreement.

04

Capabilities

01

Fretboard Mapping

Scales, triads and chord shapes drawn on the neck across positions, CAGED and three-notes-per-string, in five tunings.

02

Progression Analyser

Chords in, key and Roman numerals out — including which chords were borrowed and where from.

03

Reverse Lookup

Notes in, chord and scale names out, for working out what a shape under the fingers actually is.

04

Ear & Fretboard Drills

Interval and chord-quality listening drills and a note trainer, graded per answer with a scored review at the end.

05

Tuner & Metronome

Pitch detection through the Web Audio API across eleven tunings, plus a metronome — no native app required.

06

Offline by Default

A service worker precaches every page and asset, so the whole site loads from the device with no network at all.

05

Before / After

before
  • Theory looked up in tables that mis-spell awkward roots
  • A different site, and a different model, for every tool
  • Nothing usable once the practice room loses signal
after
  • Spellings derived from rules, correct at every root
  • Thirteen tools sharing one set of theory primitives
  • Installs to the home screen and runs entirely offline
06

Impact

9,371 Spellings, chords, voicings and keys audited
13 Tools sharing one theory engine
Zero Runtime dependencies — no CDN, no framework
100% Of the site available offline
NORMAL ~/projects/guitar-theory.php guitar-theory utf-8 php Kuala Lumpur 0%
Copied [email protected]