Unlocking Songwriting Harmonies: Behind the MIDI Scale Analyser
Songwriting often begins with a single melody. You hum a phrase, record a quick voice memo, or draw a sequence of notes into your digital audio workstation (DAW). But translating that initial spark into a full arrangement requires harmony—chords, basslines, and voice leading. For many self-taught musicians and composers, identifying the exact key and matching chords can be a creative bottleneck.
At Kennebec, we love building lightweight utility tools that help creatives solve concrete problems. Our latest web application, the MIDI Scale Analyser, is designed to bridge the gap between melody and harmony. By uploading a standard MIDI file, songwriters can instantly detect the musical scale, receive complementary chord suggestions, and view custom guitar tabs in standard and alternate tunings.

The Concept: Reverse-Engineering Melodic DNA
Musicians think in keys and scales because they provide a vocabulary of emotion. A song in C Major feels bright and open; a melody in D Dorian feels mysterious and cinematic.
The MIDI Scale Analyser extracts this “melodic DNA” from the notes you’ve played. Standard MIDI files represent music as data: note numbers, start times, durations, and velocities. By examining the distribution and frequency of note numbers, our application builds a statistical profile of the melody and compares it against known scale structures in music theory.
Core Features
We built the MIDI Scale Analyser to be fast, responsive, and immediately actionable:
- Seamless MIDI Upload: Simply drag and drop your
.midor.midifile directly onto the interface. - Instant Scale Detection: The tool displays the detected musical scale along with a confidence rating indicating how closely your notes fit that scale.
- Suggested Chords: Based on the detected scale, the tool suggests a list of diatonic triads. Each chord is labeled with its musical function (Tonic, Subdominant, or Dominant) and Roman numeral analysis (e.g., I, ii, iii).
- Interactive Guitar Tabs: Songwriters playing stringed instruments can view fret positions and chord shapes. It supports multiple tunings, including Standard, Drop D, and CGDGBE.
- Chord Progression Export: You can export the recommended chords as a new MIDI file, letting you immediately drop a rich, multi-voice chord pad back into your DAW.

Under the Hood: Lightweight & Resilient Architecture
Like many of our interactive tools, we designed the MIDI Scale Analyser to run entirely client-side. The files you upload are parsed directly inside your browser—ensuring instant results and absolute privacy.
Here are some key technical decisions behind the build:
1. Robust Dual-Parsing System
MIDI is a binary protocol, and file headers can vary. To ensure maximum compatibility, we implemented a dual-parsing strategy. The application first attempts to parse the MIDI file using the popular midi-parser-js library. If it encounters a non-standard header or an encoding quirk, it seamlessly switches to our custom SimpleMIDIParser, which skips metadata chunks and focuses purely on extracting Note On/Off commands from the raw track bytes.
2. The Scale-Matching Scoring Algorithm
To detect the scale, the app tests the unique pitches present in your MIDI file against 108 combinations (12 potential root notes multiplied by 9 supported scales, including Major, Natural Minor, Dorian, Phrygian, Lydian, Mixolydian, Locrian, Harmonic Minor, and Melodic Minor).
The algorithm calculates a confidence score using the following logic:
- Positive Weight: Notes that belong to the test scale add to the score.
- Negative Penalty: Notes that fall outside the test scale subtract from the score.
- Duration Factor: Notes that are held longer (duration) or played more frequently carry more weight than short, transient notes.
The scale with the highest overall score is presented to the user.
3. Dynamic Guitar Chord Voicing Database
For guitarists, chord shapes change completely depending on tuning. We wrote a custom guitar voicing database that stores fret diagrams for every common triad in multiple tunings. Rather than using generic transposition rules, we hand-curated three distinct voicings per chord (such as open position, barre chord, and alternative positions) for:
- Standard Tuning (E-A-D-G-B-E)
- Drop D Tuning (D-A-D-G-B-E)
- CGDGBE Tuning (popularized by songwriters like Nick Drake)
The tab engine dynamically renders ASCII-style fretboards representing strings from high E to low E, making it easy to practice and learn new chord variations.

4. Premium Aesthetic and Glassmorphic Styling
The web app features a dark, modern interface built with Vanilla CSS. A triad of blurred, glowing gradient spheres floats behind the container, creating depth and a premium “hardware synthesizer” vibe. Interactive states use clean transition timings, and responsive flex layouts ensure a seamless experience on smartphones, tablets, and wide monitors alike.
Writing Your Next Song
Whether you are a seasoned composer looking to experiment with modal interchange, a bedroom producer trying to match a vocal sample, or a guitarist exploring CGDGBE tuning, the MIDI Scale Analyser is free and runs instantly.
Try it out here: MIDI Scale Analyser.
Do you have an idea for a custom web tool, audio application, or interactive data dashboard? The team at Kennebec specializes in crafting premium, high-performance client-side applications. Get in touch with us at Kennebec.