Repository navigation
Home
Arty Belanger edited this page Oct 17, 2026
·
1 revision
Welcome to the official Bragi documentation wiki. Named after the Norse god of poetry and music, Bragi is a cross-platform desktop application designed for real-time guitar pitch detection, chord verification, chromatic tuning, and adaptive fretboard training.
Bragi combines real-time Digital Signal Processing (DSP) with responsive UI rendering to deliver zero-latency feedback for fretted instrument players. Powered by Python, Aubio, SoundDevice, and Flet, Bragi captures live audio input, isolates pitch frequencies, matches harmonic structures, and provides feedback on fretboard position, pitch accuracy, and chord execution.
Bragi's Core Philosophy: Audio-first performance with uncompromised threading isolation. Audio capture never drops frames, and UI rendering never locks the audio buffer stream.
-
YIN Pitch Extraction: Leverages the Aubio library's YIN algorithm with customizable buffer sizes (
$2048$ frames) and hop sizes ($1024$ frames) at$44.1\text{ kHz}$ sample rates.
-
Relaxed Resonance Thresholds: Optimized silence floor (
$-65.0\text{ dBFS}$ ) and lowered Aubio pitch confidence requirements ($0.30$ ) to accurately capture natural guitar body resonance, decaying notes, and light fingerpicking.
-
Hardware Hardware Isolation: Centralized singleton
AudioManagerowns thesounddevice.InputStream, eliminating hardware stream contention across views and OS-level PortAudio locks.
-
High-Precision Pitch Tracking: Displays exact detected pitch classes (
$C, C\sharp, D, \dots, B$ ), octave designations, and frequency in Hertz ($0.1\text{ Hz}$ resolution).
-
Cents Deviation Gauge: Visual gauge indicating cents offset from
$-50\text{ cents}$ (Flat) to$+50\text{ cents}$ (Sharp) with color-coded status badges ($in\text{ }tune \le \pm 5\text{ cents}$ ).
-
Standard Reference Row: Quick-reference pitch benchmarks for standard guitar tuning (
$E2, A2, D3, G3, B3, E4$ ).
-
Chromatic Key Support: Generates random flashcards across all 12 chromatic root keys (
$C$ through$B$ ) and major/minor qualities.
-
Arpeggio Accumulator Mode: Solves monophonic microphone limitations during strummed chords by capturing note pitch classes sequentially into a rolling
$1.8\text{-second}$ memory buffer.
-
Instantaneous Match Evaluation: Zero-hold validation (
$0.0\text{s}$ ) triggers target completion the exact millisecond all required pitch classes are detected in memory, clearing the buffer for seamless transition to the next chord card.
-
Native Device Enumeration: Filters out MME/DirectSound virtual duplicates and displays active physical inputs based on system primary host APIs (WASAPI on Windows, CoreAudio on macOS).
-
Auto-Fallback Safeguard: Automatically falls back to the system default microphone if a persisted device index becomes offline or invalid.
+-----------------------+
| Hardware Audio In |
+-----------+-----------+
|
v
+-----------------------+
| sounddevice Stream |
+-----------+-----------+
|
v
+-----------------------+
| PitchDetector |
| (Aubio YIN / dBFS) |
+-----------+-----------+
|
v
+-----------------------+
| AudioManager Thread |
| (~40 FPS Queue Drain)|
+-----+-----------+-----+
| |
+------------------+ +------------------+
| |
v v
+-------------------------+ +-------------------------+
| AudioWorker Engine | | Flet Main Thread Loop |
| (Evaluators & Buffers) | | (~25 FPS UI Render) |
+-------------------------+ +-------------------------+
Bragi is currently in Phase 1 Complete (Core Engine & Stability).
-
Queue Contention Resolution: Eliminated dual-queue stealing by designating
AudioManageras the sole consumer ofPitchDetectorqueue frames.
-
Main-Thread UI Loop: Integrated
asyncio.create_taskrendering loops bound to view mount lifecycles, bypassing background thread WebSocket buffering issues in Flet.
-
Optimized Chord Accumulation: Transitioned default chord verification to an
$1.8\text{-second}$ Arpeggio Accumulator with zero-hold triggers, making chord detection fast and reliable during natural strums.
-
Full Chromatic Flashcards: Unlocked the random practice generator across all 12 musical keys and qualities.
Phase 1: Core Engine & Tuning (Completed)
├── Singleton Audio Pipeline
├── Chromatic Tuner Subview
└── Arpeggio Accumulator Engine
Phase 2: Extended Practice Modes (In Progress)
├── CAGED Position Challenge
├── Custom Scale & Arpeggio Generators
└── Adaptive Speed Flashcards (BPM/Timer-based)
Phase 3: Deep DSP & Tuning Presets (Planned)
├── Alternate Tunings (Drop D, DADGAD, Open G)
├── Harmonic Overstone Spectrum Visualizer
└── Polyphonic Chord Fingerprinting
Phase 4: Analytics & Customization (Future)
├── Practice Session Analytics & Streak Metrics
├── Pitch Accuracy Heatmaps
└── Custom Instrument Profiles (Bass, Ukulele, Mandolin)
-
CAGED Position Filtering: Restrict chord practice cards to specific neck regions (Position 1 through 5) or CAGED shapes.
-
Adaptive Flashcards: Dynamic auto-advancing cards that decrease display timer intervals as player accuracy increases.
-
Ear Training Drills: Play a random reference pitch/chord and evaluate the user's ability to locate and repeat it on the fretboard.
-
Custom Instrument Tuning Profiles: Support for alternate guitar tunings (
$Drop\text{ }D, DADGAD, Open\text{ }G$ ) with adjusted pitch reference targets and fretboard map translation.
-
Spectrum Analysis Integration: Visual FFT frequency waterfall display for analyzing string timbre and overtone distribution.
-
Local SQLite Progress Database: Log daily practice duration, note accuracy rates, and chord transition speeds.
-
Custom Theme Engine: Personalizable visual accents and dark/light UI modes built on top of
ThemeManager.
-
Python:
3.10+
- Dependencies:
flet,sounddevice,aubio,numpy,pydantic
Bash
# Clone the repository
git clone https://github.com/your-username/Bragi.git
cd Bragi
# Install dependencies
pip install -r requirements.txt
# Launch the application
python main.py