tonal-guitar

Guitar

Guitar fretboard, shapes, patterns, and sequences

import * as Guitar from "tonal-guitar";
 
const shape = Guitar.get("E Shape");
const scale = Guitar.buildFrettedScale(shape, "A");
const notes = Guitar.walkPattern(scale, Guitar.thirds(7));
console.log(Guitar.toAsciiTab(notes));

The tonal-guitar package provides pure functions for working with guitar fretboard geometry, scale/chord shapes, melodic patterns, and output formatting. It integrates deeply with Tonal's Scale, Chord, Mode, and Key modules.

Core Workflow

The typical workflow is:

  1. Choose a shape from the built-in registry (CAGED, 3NPS, pentatonic) or define your own
  2. Build a fretted scale by applying the shape to a root note and tuning
  3. Generate a pattern (thirds, fourths, groupings, custom sequences)
  4. Walk the pattern through the fretted scale to get concrete notes
  5. Output as ASCII tab or AlphaTeX notation
import {
  get,
  buildFrettedScale,
  walkPattern,
  thirds,
  applySequence,
  flattenSequence,
  toAlphaTeX,
  toAsciiTab,
  STANDARD,
  SEQ_1235,
} from "tonal-guitar";
 
// Build A major in E Shape
const scale = buildFrettedScale(get("E Shape"), "A");
 
// Walk ascending thirds
const thirdNotes = walkPattern(scale, thirds(7));
console.log(toAsciiTab(thirdNotes));
 
// Or apply an incremental sequence
const passes = applySequence(scale, SEQ_1235, { incremental: true });
const allNotes = flattenSequence(passes);
console.log(toAlphaTeX(allNotes, { tempo: 100, key: "A" }));

Built-in Shape Systems

The package ships with 32 shapes registered at import time:

SystemCountShapes
CAGED Scales5E, D, C, A, G shapes
Minor CAGED Scales5Dm, Cm, Am, Gm, Em shapes
CAGED Chords5E, D, C, A, G shapes (with fingerings and barres)
3NPS7Patterns 1-7 (one per mode)
Pentatonic5Boxes 1-5
Minor Pentatonic5Boxes 1-5 Minor

Package Sections

  • Fretboard -- Fretboard math and note lookups
  • Shapes -- Scale and chord shape registry
  • Patterns -- Melodic pattern generators and walker
  • Sequences -- Sequence engine for incremental exercises
  • Output -- AlphaTeX and ASCII tab formatters
  • Integration -- Tonal.js Scale, Chord, Mode, and Key integration
  • Arpeggios & Chord Detection -- Arpeggio derivation, shape inference, and voicing data

On this page