theory

package
v0.0.0-...-4e4ff22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2021 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package theory implements music theory. There is also support for associating MIDI numbers with music theory. It vaguely corresponds to the MusicXML data structures.

Note that this is inahga's(tm) music theory. My understanding of actual music theory is pretty bad :).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accidental

type Accidental int
const (
	Natural Accidental = iota
	Flat
	Sharp
)

func (Accidental) String

func (a Accidental) String() string

type Class

type Class int
const (
	C Class = iota
	D
	E
	F
	G
	A
	B
)

func (Class) String

func (c Class) String() string

type Clef

type Clef int
const (
	Treble Clef = iota
	Bass
)

func (Clef) String

func (c Clef) String() string

type Duration

type Duration float64
const (
	Whole Duration = 1 << iota
	Half
	Quarter
	Eight
	Sixteenth
	ThirtySecond
)

type Key

type Key struct {
	Major Tone
	Minor Tone
	Sig   []KeySignature
}

func GetKeyByClass

func GetKeyByClass(class Class, adjustment Accidental, mode Mode) (Key, error)

func MustGetKeyByClass

func MustGetKeyByClass(class Class, adjustment Accidental, mode Mode) Key

type KeySignature

type KeySignature struct {
	Tone
	TrebleOctave Octave // Helps render the time signature for treble clef
	BassOctave   Octave // Helps render the time signature for bass clef
}

func (KeySignature) BassNote

func (s KeySignature) BassNote() Note

BassNote returns a note indicating the octave at which the signature should be placed when rendering bass clef.

func (KeySignature) TrebleNote

func (s KeySignature) TrebleNote() Note

BassNote returns a note indicating the octave at which the signature should be placed when rendering treble clef.

type Measure

type Measure []Note

type Mode

type Mode int
const (
	Major Mode = iota
	Minor
)

func (Mode) String

func (m Mode) String() string

type Note

type Note struct {
	Tone
	Octave
	Duration
}

Note represents the pitch and duration of a sound.

func N

func N(c Class, a Accidental, o Octave, d Duration) Note

type Octave

type Octave int

type Part

type Part struct {
	Clef
	Time
	Key
	Measures []Measure
}

type Time

type Time struct {
	BeatsPerBar, BeatUnit int
}

type Tone

type Tone struct {
	Class
	Accidental
}

func (Tone) String

func (t Tone) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL