Skip to content

A visual representation of a fretboard and string that can have notes overlayed on them and bent strings.

License

Notifications You must be signed in to change notification settings

AudioKit/Fretboard

Repository files navigation

Fretboard

Swift Platforms License

A SwiftUI view for guitar and bass fretboard visualization, built on Tonic for music theory. Part of the AudioKit ecosystem.

Demo

Installation

Add Fretboard via Swift Package Manager:

dependencies: [
    .package(url: "https://github.com/AudioKit/Fretboard.git", from: "1.0.0")
]

Quick Start

import Fretboard
import SwiftUI

struct ContentView: View {
    var body: some View {
        Fretboard(
            playedFrets: [nil, 5, 7, 7, 5, nil],
            displayedFretRange: 0...12
        )
    }
}

Features

  • Canvas-based rendering — smooth, efficient drawing using SwiftUI Canvas
  • String bending — visual bend displacement via bends array
  • Velocity-based opacity — note circles reflect MIDI velocity
  • Bass mode — 4-string layout centered on a 6-string fretboard
  • Note spelling — configurable sharp/flat preference via noteKey parameter
  • Pitch-based coloring — each pitch class gets a distinct color (Helmholtz palette from Tonic)
  • Accurate fret spacing — uses real guitar physics for fret positions
  • Fret inlays — single dots (3, 5, 7, 9) and double dots (12, 24)
  • Pickup visualization — decorative neck and bridge pickups
  • Equatable — efficient SwiftUI diffing for state-driven updates

Demo

Included with the package is a demo project and a playground.

xcodebuild build -project Demo/FretboardDemo.xcodeproj \
    -scheme FretboardDemo -destination "name=My Mac"

Build & Test

swift build    # Build the library
swift test     # Run tests

Documentation

The docs are hosted on the AudioKit.io website

License

MIT. See LICENSE for details.

About

A visual representation of a fretboard and string that can have notes overlayed on them and bent strings.

Resources

License

Code of conduct

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages