Go models of Note, Scale, Chord and Key

Overview

Build Status GoDoc Go Report Card codebeat badge Awesome

gopkg.in/music-theory.v0

Music theory models in Go

There's an example command-line utility music-theory.go to demo the libraries, with a bin/ wrapper.

To build and install music-theory to your machine:

make install

Then, to calculate the note pitch classes for a specified Chord:

$ music-theory chord "Cm nondominant -5 679"

root: C
tones:
  3: D#
  6: A
  7: A#
  9: D

To list the names of all the known chord-building rules:

$ music-theory chords

- Basic
- Nondominant
- Major Triad
- Minor Triad
- Augmented Triad
- Diminished Triad
- Suspended Triad
- Omit Fifth
- Flat Fifth
- Add Sixth
- Augmented Sixth
- Omit Sixth
- Add Seventh
- Dominant Seventh
- Major Seventh
- Minor Seventh
- Diminished Seventh
- Half Diminished Seventh
- Diminished Major Seventh
- Augmented Major Seventh
- Augmented Minor Seventh
- Harmonic Seventh
- Omit Seventh
- Add Ninth
- Dominant Ninth
- Major Ninth
- Minor Ninth
- Sharp Ninth
- Omit Ninth
- Add Eleventh
- Dominant Eleventh
- Major Eleventh
- Minor Eleventh
- Omit Eleventh
- Add Thirteenth
- Dominant Thirteenth
- Major Thirteenth
- Minor Thirteenth

To calculate the note pitch classes for a specified Scale:

$ music-theory scale "C aug"

root: C
tones:
  1: C
  2: D#
  3: E
  4: G
  5: G#
  6: B

To list the names of all the known scale-building rules:

$ music-theory scales

- Default (Major)
- Minor
- Major
- Natural Minor
- Diminished
- Augmented
- Melodic Minor Ascend
- Melodic Minor Descend
- Harmonic Minor
- Ionian
- Dorian
- Phrygian
- Lydian
- Mixolydian
- Aeolian
- Locrian

To determine a key:

$ music-theory key Db

root: Db
mode: Major
relative:
  root: Bb
  mode: Minor
Credit

Charney Kaye

XJ Music

Note

A Note is used to represent the relative duration and pitch of a sound.

GoDoc Coverage

Key

The key of a piece is a group of pitches, or scale upon which a music composition is created in classical, Western art, and Western pop music.

GoDoc Coverage

Chord

In music theory, a chord is any harmonic set of three or more notes that is heard as if sounding simultaneously.

GoDoc Coverage

Scale

In music theory, a scale is any set of musical notes ordered by fundamental frequency or pitch.

GoDoc Coverage

Issues
  • Note expression as sharp/flat is switched based on input

    Note expression as sharp/flat is switched based on input

    The option to return flats is switched based on the input request. E.g. if the requested chord contains "flats" the output notes should all be expressed with flats.

    For example:

    $ go run music.go -c "CMb5b7"
    

    returns:

    root: C
    tones:
    1: C
    3: E
     5: F#
     7: A#
    

    should return:

    root: C
    tones:
    1: C
    3: E
     5: Gb
     7: Bb
    
    enhancement 
    opened by raff 5
  • Update implementation of command actions

    Update implementation of command actions

    A current build returns the following warning message when run:

    DEPRECATED Action signature. Must be cli.ActionFunc. This is an error in the application. Please contact the distributor of this application if this is not you. See https://github.com/urfave/cli/blob/master/CHANGELOG.md#deprecated-cli-app-action-signature

    It seems that the definition of Action methods has changed and you now need to return an error: Action: func (c *cli.context) error {}

    bug 
    opened by raff 3
  • Support for correct note names for more modes

    Support for correct note names for more modes

    Hello! Wonderful library, so far I'm quite happy with whats offered, but there is one thing that bothers me and I'm working on my own fix for right now but I was wondering if you'd thought of it.

    Music theory talks about A-G should be used once each for a scale, here you have Gb and G and Db and D.

    Here's what the library says about Gb phrygian when using Scale.Of() - root: Gb tones: 1: Gb 2: G 3: A 4: B 5: Db 6: D 7: E

    Should be

    opened by mathaou 2
  • Release 0.0.4

    Release 0.0.4

    • Fix make install
    • Dependencies:
      • gopkg.in/stretchr/testify.v1/assert
      • gopkg.in/stretchr/testify.v1/mock
      • gopkg.in/urfave/cli.v1
      • Removed logrus (not used)
    • Go versions:
      • CI tests from 1.11 to 1.13
    • Bump version to 0.0.4
    • Ignore IntelliJ IDE files
    • GNU General Public License v3
    • Author information
    enhancement 
    opened by charneykaye 1
  • fix

    fix "make install"

    Hi! Thanks for the cool package!

    I wanted to compile package locally with make install, but tests didn't pass because package github.com/stretchr/testify/assert wasn't installed. I think that an additional flag to go get should be added. https://golang.org/cmd/go/#hdr-Add_dependencies_to_current_module_and_install_them

    opened by krzysztof-grzybek 1
  • Refactor to proper Go command-line app `music-theory`

    Refactor to proper Go command-line app `music-theory`

    main

    • [X] CLI implements github.com/codegangsta/cli
    • [X] Godoc of /music-theory.go a.k.a. godoc.org/github.com/go-music/music reads as expected for command-line app music-theory
    • [X] /Makefile default make builds target/music-theory/music-theory.linux.amd64 (or whatever your .os.arch is)
    • [X] /Makefile make install builds then installs the target to your os
    • [X] /README.md a.k.a. github.com/go-music/music reads as expected for command-line app music-theory

    theory/note

    theory/key

    theory/chord

    theory/interval

    • [X] DEPRECATE this library- it's used only by the chord package, and should be refactored to live inside there only. The original concept of inter-operability between chords and scales is less important than simple design up-front.
    enhancement 
    opened by charneykaye 1
  • Note pitch has option to set base tuning

    Note pitch has option to set base tuning

    opened by charneykaye 0
  • [Update] Version 0.0.4

    [Update] Version 0.0.4

    • Dependencies:
      • gopkg.in/stretchr/testify.v1/assert
      • gopkg.in/stretchr/testify.v1/mock
      • gopkg.in/urfave/cli.v1
      • Removed logrus (not used)
    • Go versions:
      • CI tests from 1.11 to 1.13
    • Bump version to 0.0.4
    • Ignore IntelliJ IDE files
    • GNU General Public License v3
    • Author information
    enhancement 
    opened by charneykaye 0
  • originalKey.Diff(targetKey) or originalNote.Diff(targetNote) returns nearet +/- semitones

    originalKey.Diff(targetKey) or originalNote.Diff(targetNote) returns nearet +/- semitones

    Key

    originalKey := key.Of("Db minor")
    targetKey := key.Of("F# major")
    shiftSemitones := originalKey.Diff(targetKey) // equals +5
    

    Which implements Note:

    originalNote := note.Fs
    targetNote := note.Cs
    shiftSemitones := originalNote.Diff(targetNote) // equals -5
    
    enhancement 
    opened by charneykaye 0
  • First implementation of Key

    First implementation of Key

    Key

    https://en.wikipedia.org/wiki/Key_(music)

    • [X] has a Root pitch class (a.k.a. tonal center)
    • [X] is minor or major
    • [ ] The relative minor of a major key has the same key signature and starts down a minor third (or equivalently up a major sixth); for example, the relative minor of G major is E minor. Similarly the relative major of a minor key starts up a minor third (or down a major sixth); for example, the relative major of F minor is A♭ major.
    enhancement 
    opened by charneykaye 0
  • Add key-finding algorithm to Key package

    Add key-finding algorithm to Key package

    Hi, I've written a Go implementation for the Krumhansl-Schmuckler key-finding algorithm. I have it packaged in one of my private repos and I'm wondering if it would be of interest to make a pull request with it into this library. Please let me know and I can proceed.

    enhancement help wanted 
    opened by schollz 5
  • Sharp or Flat any interval in a chord

    Sharp or Flat any interval in a chord

    Expect:

    C #4:
      root: C
      tones:
        1: C
        3: E
        4. F#
        5: G
    
    C dim #6:
      root: C
      tones:
        1: C
        3: D#
        5: F#
        6: A#
    
    C dim ♭6:
      root: C
      tones:
        1: C
        3: D#
        5: F#
        6: G#
    

    And especially chords with upper structure in higher intervals.

    enhancement 
    opened by charneykaye 0
  • Note returns Pitch in Hz

    Note returns Pitch in Hz

    Any note (with a pitch class + octave) ought to be able to return a Pitch.

    Allow for future selection of different tunings.

    See jFugue for an example of a pitch algorithm

    There would be a configuration for master tune as well, e.g. 440Hz vs. 432Hz

    enhancement 
    opened by charneykaye 3
  • Advanced implementation of Chord

    Advanced implementation of Chord

    Chord

    https://en.wikipedia.org/wiki/Chord_(music)

    In tonal Western classical music, the most frequently encountered chords are triads, so called because they consist of three distinct notes: the root note, a third above the root and a fifth interval above the root. Further notes may be added to give tetrads such as seventh chords (the most commonly encountered example being the dominant seventh chord) and added tone chords, as well as extended chords and tone clusters. Triads commonly found in the Western classical tradition are major and minor chords, with augmented and diminished chords appearing less often. The descriptions major, minor, augmented, and diminished are referred to collectively as chordal quality. Chords are also commonly classified by their root note—for instance, a C major triad consists of the pitch classes C, E, and G. A chord retains its identity if the notes are stacked in a different way vertically; however, if a chord has a note other than the root note as the lowest note, the chord is said to be in an inversion (this is also called an "inverted chord").

    Additional Chord Forms
    // Lydian
    Lydian
    Omit Lydian
    
    // Specific
    AlphaSpecific
    BridgeSpecific
    ComplexeSonoreSpecific
    DreamSpecific
    ElektraSpecific
    FarbenSpecific
    GrandmotherSpecific
    MagicSpecific
    MµSpecific
    MysticSpecific
    NorthernLightsSpecific
    PetrushkaSpecific
    PsalmsSpecific
    SoWhatSpecific
    TristanSpecific
    VienneseTrichordSpecific
    MixedIntervalGeneral
    SecundalGeneral
    TertianGeneral
    QuartalGeneral
    SyntheticChordGeneral
    
    Chord Function
    // Diatonic
    TonicDiatonic
    DominantDiatonic
    SubdominantDiatonic
    SupertonDiatonicicDiatonic
    MediantDiatonic
    SubmediantDiatonic
    LeadingDiatonic
    SubtonicDiatonic
    
    // Altered
    ApproachAltered
    BorrowedAltered
    ChromaticMediantAltered
    NeapolitanAltered
    PassingAltered
    SecondaryAltered
    SecondaryDominantAltered
    SecondaryLeadingToneAltered
    SecondarySupertonicAltered
    
    // Other
    CommonOther
    ContrastOther
    PrimaryTriadOther
    SubsidiaryOther
    
    Chord Technique
    BlockTechnique
    ChordioidTechnique
    GuitarTechnique
    OpenTechnique
    PowerTechnique
    SlashTechnique
    

    Additional chord text interpretation

    • Δ is sometimes used for major, instead of the standard M, or maj,
    • is sometimes used for minor, instead of the standard m or min,
    • +, or aug, is used for augmented (A is not used),
    • o, °, dim, is used for diminished (d is not used),
    • ø, or Ø is used for half diminished,
    • dom is used for dominant 7th
    • alt is used in jazz to indicate an altered dominant seventh chord (e.g., flat 9 and/or # 11)
    • 7 is used for dominant 7th
    • 9 is used for a ninth chord, which in jazz usually includes the dominant 7th as well
    • 13 indicates that the 13th is added to the chord. In jazz, when a number higher than 9th is used, it implies that other lower numbers are played. Thus for A13, a pianist would play the 3rd, the 7th, 9th and 13th (the 11th is normally omitted unless it is sharpened. Roots and fifths are commonly omitted from jazz chord voicings).
    • sus 4 indicates that the third is omitted and the fourth used instead. Other notes may be added to a - Sus 4 chord, indicated with the word "add" and the scale degree (e.g., A sus 4 (add 9) or A sus 4 (add 7)).
    • /C♯ bass or /C♯ indicates that a bass note other than the root should be played. For example, A/C♯ bass indicates that an A Maj triad should be played with a C♯ in the bass. (Note: in some genres of modern jazz, two chords with a slash between them may indicate an advanced voicing called a polychord, which is the playing of two chords simultaneously--e.g., F/A would be interpreted as an F Major triad played simultaneously with an A Maj triad, that is the notes "F, A, C" and "A, C♯, E". To avoid misunderstanding, the "/C♯ bass" notation can be used).
    • 5 in rock, hard rock and metal indicates that a power chord should be played. A power chord consists of the root and the fifth, possibly with the root doubled an octave higher. Thirds and sevenths are not played in power chords. Typically, power chords are played with distortion or overdrive.
    • Unusual chords can be indicated with a sequence of scale degrees and indicated additions or omissions (e.g., C7 (no 5th add 9) or F9 (no 7th add 13)).
    enhancement help wanted 
    opened by charneykaye 0
  • Harmonic seventh

    Harmonic seventh

    https://en.wikipedia.org/wiki/Harmonic_seventh

    It's more intensive than just a note choice- this requires new implementation of custom pitches between the chromatic scale.

    question 
    opened by charneykaye 0
? ID3 decoding and encoding library for Go

id3v2 Supported ID3 versions: 2.3, 2.4 Installation go get -u github.com/bogem/id3v2 Usage example package main import ( "fmt" "log" "github.com

Albert Nigmatzianov 254 Aug 9, 2022
EasyMidi is a simple and reliable library for working with standard midi file (SMF)

EasyMidi EasyMidi is a simple and reliable library for working with standard midi file (SMF). Installing A step by step series of examples that tell y

null 39 Jun 7, 2022
A yet to be voice call application in terminal. with the power of go and webRTC (pion).

A yet to be voice call application in terminal. with the power of go and webRTC (pion).

Mohammad Fatemi 37 Apr 30, 2022
Self-hosted music streaming server 🎶 with RESTful API and Web interface

Self-hosted music streaming server ?? with RESTful API and Web interface. Think of it as your very own Spotify!

Doychin Atanasov 420 Aug 6, 2022
A utility for sending and listening for OSC messages.

A simple utility to send and listen for OSC messages. It can also be used to send MIDI messages.

Tim Thompson 3 Mar 5, 2022
Download and listen music in the terminal!

?? this cli still has a lot of bugs ?? A simple tool to download and listen music in the terminal. You will need: golang deno v1.16+ youtube-dl Instal

pai 77 Jul 22, 2022
A tool coded by GO to decode cryptoed netease music files and qqmusic files

nqdumpgo A tool coded by GO to decode cryptoed netease music files and qqmusic files 一个使用 Go 语言编写的用于解密被网易云音乐或 QQ 音乐加密的文件的程序,Go 程序在拥有与 C++程序相近的效率的同时,大大

null 3 Jul 29, 2022
Like tar but different. PitCH is an archive file format that aims for high performance and minimal bloat.

Like tar but different. PitCH is an archive file format that aims for high performance and minimal bloat.

Raphael Reyna 2 Feb 17, 2022
Deploy, manage, and scale machine learning models in production

Deploy, manage, and scale machine learning models in production. Cortex is a cloud native model serving platform for machine learning engineering teams.

Cortex Labs 7.8k Aug 16, 2022
Chord transposer for Golang.

Go Chord Transposer Chord transposer for Golang. It will detect chords inside multiline string(Song guitar chords) then replace the chords given strin

Halil Çağrı AKKUZU 2 Sep 3, 2021
GhostDB is a distributed, in-memory, general purpose key-value data store that delivers microsecond performance at any scale.

GhostDB is designed to speed up dynamic database or API driven websites by storing data in RAM in order to reduce the number of times an external data source such as a database or API must be read. GhostDB provides a very large hash table that is distributed across multiple machines and stores large numbers of key-value pairs within the hash table.

Jake Grogan 725 Aug 13, 2022
Music recognition bot for Reddit powered by audd.io. Note that the code currently needs some cleaning up and doesn't follow the best practices.

Music recognition bot for Reddit u/auddbot identifies music on Reddit. When someone mentions it or writes a question like "what's the song", it sends

AudD 230 Aug 15, 2022
A note taking app, that you can draw in, syncs to the cloud, and is on most platforms!

About NotDraw About · How to contribute · How to run · Trello · FAQ This is achived because I dont want to work on it anymore Structure Codebase Descr

YummyOreo 1 Jul 11, 2022
A note taking app, that you can draw in, syncs to the cloud, and is on most platforms!

About NoteDraw About · How to contribute · How to run Structure Codebase Description SRC The sorce code for the client side (Go) Branches Only Ones th

YummyOreo 1 Jul 11, 2022
bryant's go note and source

These are my notes from when I taught myself Golang. It includes the basic syntax of go language, basic operators, function operations, packages, inte

Bryant 1 Aug 8, 2022
A very simple note-taking CLI you can use from the terminal that uses a SQLite DB to persist, and query, notes.

Note Logger Summary A very simple note-taking CLI you can use from the terminal that uses a SQLite DB to persist, and query, notes. Building/Installin

Nicholas Page 3 Apr 14, 2022
So you always leave a note

jWalterWeatherman Seamless printing to the terminal (stdout) and logging to a io.Writer (file) that’s as easy to use as fmt.Println. Graphic by JonnyE

Steve Francia 238 Aug 4, 2022
The Markdown-based note-taking app that doesn't suck.

Notable I couldn't find a note-taking app that ticked all the boxes I'm interested in: notes are written and rendered in GitHub Flavored Markdown, no

Notable 20.1k Aug 12, 2022
The note-tinygo Go library for communicating with Blues Wireless Notecard via serial or I²C

Blues Wireless The note-tinygo Go library for communicating with Blues Wireless Notecard via serial or I²C. This library allows you to control a Notec

Blues Inc 3 Nov 29, 2021
Go service for CRUD note, log tracking by RabbitMQ

Service for CRUD note, log tracking by RabbitMQ Architecture Three components: Service note CRUD, use a DB RabbitMQ for saving messages pushed from se

Võ Trung Nhân 0 Nov 29, 2021
A Simple Note API For Golang

Simple Note API Start up run go run main.go Endpoints GET localhost:8080/notes -> gets all of the notes in the database POST localhost:808/note -> cre

null 0 Dec 15, 2021
wiz note backup & proxy

Wiz Note 虽然很多人吐槽,但是本地化的文档是真的很重要 安装 # https://www.wiz.cn/zh-cn/docker mkdir -p /wiz/data /wiz/logs /wiz/backup docker run --name wiz \ --restart=alw

星冉 1 May 15, 2022
Note - A text editor for the Linux Terminal! (Mainly compatible with Arch, because I made it on there)

Note - A text editor for the Linux Terminal! (Mainly compatible with Arch, because I made it on there)

Awesome Sauce 5 Jul 15, 2022
small go-based app for note taking

Description A small note taking web-app which I am building for myself just for fun and learning purposes. My goal is too use as much of the standard

Ekin Tiras 1 Jul 15, 2022
📝 connote is a simple console-based note taking tool.

?? connote connote is a simple console-based note taking tool. Install Download the binary for your operating system from Releases Run go install gith

Shivaprasad Bhat 2 Jun 10, 2022
Mongo Go Models (mgm) is a fast and simple MongoDB ODM for Go (based on official Mongo Go Driver)

Mongo Go Models Important Note: We changed package name from github.com/Kamva/mgm/v3(uppercase Kamva) to github.com/kamva/mgm/v3(lowercase kamva) in v

kamva 538 Aug 12, 2022
µTask is an automation engine that models and executes business processes declared in yaml. ✏️📋

µTask, the Lightweight Automation Engine µTask is an automation engine built for the cloud. It is: simple to operate: only a postgres DB is required s

OVHcloud 699 Aug 12, 2022
Example of Neural Network models of social and personality psychology phenomena

SocialNN Example of Neural Network models of social and personality psychology phenomena This repository gathers a collection of neural network models

null 6 Jan 15, 2022
🧀 Formaggo is a simple model checker inspired by TLA+, The checker and the models are written in Go

?? Formaggo. A cheesy exhaustive state checker in Go. Formaggo is a simple model checker inspired by TLA+. The checker and the models are written in G

Jakub Mikians 0 Jan 23, 2022