Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brettbuddin/musictheory
π΅ Music theory concepts in Go.
https://github.com/brettbuddin/musictheory
audio go midi music music-theory
Last synced: 3 days ago
JSON representation
π΅ Music theory concepts in Go.
- Host: GitHub
- URL: https://github.com/brettbuddin/musictheory
- Owner: brettbuddin
- License: mit
- Created: 2015-08-22T16:05:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-07-24T02:42:24.000Z (5 months ago)
- Last Synced: 2024-07-24T04:47:03.233Z (5 months ago)
- Topics: audio, go, midi, music, music-theory
- Language: Go
- Homepage:
- Size: 91.8 KB
- Stars: 74
- Watchers: 6
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Music Theory
[![Build Status](https://travis-ci.org/brettbuddin/musictheory.svg?branch=master)](https://travis-ci.org/brettbuddin/musictheory)
[![GoDoc](https://godoc.org/github.com/brettbuddin/musictheory?status.svg)](https://godoc.org/github.com/brettbuddin/musictheory)Explorations in music theory.
## Usage
```go
package mainimport (
mt "github.com/brettbuddin/musictheory"
"github.com/brettbuddin/musictheory/intervals"
)func main() {
root := mt.NewPitch(mt.C, mt.Natural, 4)root.Name(mt.AscNames) // C4
root.Freq() // 261.625565 (Hz)
root.MIDI() // 72P5 := mt.Perfect(5) // Perfect 5th
A4 := mt.Augmented(4) // Augmented 4throot.Transpose(P5).Name(mt.AscNames) // G4
root.Transpose(A4).Name(mt.AscNames) // F#4
root.Transpose(P5.Negate()).Name(mt.AscNames) // F3mt.NewScale(root, intervals.Dorian, 1)
// [C4, D4, Eb4, F4, G4, A4, Bb4]mt.NewScale(root, intervals.Mixolydian, 2)
// [C4, D4, E4, F4, G4, A4, Bb4, C5, D5, E5, F5, G5, A5, Bb5]rootPosition := mt.NewChord(root, intervals.DiminishedSeventh)
// [C4, Eb4, Gb4, A4]firstInversion := rootPosition.Invert(1)
// [C5, Eb4, Gb4, A4]secondInversion := rootPosition.Invert(2)
// [C5, Eb5, Gb4, A4]note := mt.NewNote(root, mt.D16) // C4 sixteenth note
note.Time(mt.D4, 120) // 125ms (quarter note getting the beat at 120 BPM)
}
```ζ₯½γγΏγΎγοΌ