Skip to content

High5Apps/chordabra

Repository files navigation

Chordabra iOS App

Like magic, Chordabra shows you which chords are playing around you right now! Play a chord on your piano, synth, guitar, or other musical instrument and Chordabra will show you what it's called. Chordabra is perfect for playing along with your favorite songs or keeping up with your friends during impromptu jam sessions.

Get it free on the iOS App Store.

How It Works

Chordabra's implementation is heavily influenced by Adam Stark's 2009 research paper, Real-Time Chord Recognition For Live Performance. It also relies on AudioKit for processing and analyzing the microphone input stream and CQTKit for its fast C++ implementation of the Constant Q Transform.

Chromagram Creation

Input is captured from the microphone by installing a KeyboardRangeNoteTap on AudioKit's AKMicrophone. Then KeyboardRangeNoteTap and its subclasses aggregate a buffer of 8192 samples at a sample rate of 44100 samples per second. After that, a Constant Q Transform is performed with a quality of 3 bins per semitone. Finally, a chromagram is created by finding the center bin with the maximum power across the octaves from a bass guitar's low E to a double high C for each of the 12 semitones.

Chord Guessing

ChordGuesser finds the closest chord to a given chromagram from a set of enabled chord types using the distance function defined in Chord. The theory behind the distance function is explained thoroughly in the research paper mentioned above. Briefly, it defines distance as the power of noise present in the chromagram when the power from the chord's expected tones are ignored, normalized by the number of expected tones in the chord.

User Interface Updating

ChordAnalyzer is used by the MainViewController to update the UI whenever a stable chord change is detected. To reduce the influence of noise, a chord change is considered stable if the same chord is guessed twice in a row.

Enabling and Disabling Chord Types

Chord Types such as Major Triad, Diminished Triad, Minor Seventh, etc. can be enabled or disabled by the user through a settings menu managed by SettingsViewController. Settings are persisted using iOS's standard UserDefaults key-value store. New chord types must be registered in AppDelegate. Default settings are also defined in AppDelegate. Only Major Triad and Minor Triad are enabled by default.

Potential Improvements

These types of chords are tricky to label because it is hard to determine their root note. For example, the tones in an augmented C chord are C, E and G#; the tones in the augmented E chord are E, G# and C; and the tones in the augmented G# chord are G#, C, and E. Similar issues occur between Sus 2 and Sus 4 chords. A method for identifying the root is described in the research paper mentioned above, but I couldn't get it to work as described. Furthermore, it's not implemented in the paper's associated repo, so there's not much evidence that the method actually works.

Tuning the Input

Notes played by real-world instruments are unlikely to be tuned to the perfect, evenly tempered 12 note scale centered on A4 at exactly 440Hz. To correct for this, it's possible to automatically tune the input before creating the chromagram. One tuning method is described in section 2.2 of Phase-Change Based Tuning for Automatic Chord Recognition

Improved Handling of Harmonics

The timbre of a note played by real-world instruments is influenced by the power of the harmonics produced as a result of playing the note. This harmonic power reduces the signal to noise ratio and makes chord detection more difficult. Currently, KeyboardRangeNoteTap crudely attempts to reduce the harmonic power by assuming that the second harmonic contains half the power of the main note, the third harmonic contains one third the power of the main note, the fourth harmonic contains one quarter the power of the main note, and no higher harmonics exist. More robust models have been created that more accurately reflect the timbres of real-world instruments. One method for this uses the non-negative least squares problem solving algorithm as described in Approximate Note Transcription for the Improved Identification of Difficult Chords.

Add Other Improvements Developed for MIREX

Since 2004, the annual Music Information Retrieval Evaluation eXchange (MIREX) competition has challenged competitors to create the best algorithm for extracting harmonic information from a corpus of labeled pop songs. While it doesn't require submissions to run in real time, there are still many improvements developed for MIREX that may be applicable to real-time detection scenarios.

About

Like magic, Chordabra shows you which chords are playing around you right now!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published