Documentation ¶
Index ¶
- Constants
- Variables
- func AscNames(i int) int
- func DescNames(i int) int
- type Duration
- type Interval
- func Augmented(step int) Interval
- func Diminished(step int) Interval
- func DoublyAugmented(step int) Interval
- func DoublyDiminished(step int) Interval
- func Major(step int) Interval
- func Minor(step int) Interval
- func NewInterval(step, octaves, offset int) Interval
- func Octave(step int) Interval
- func ParseInterval(str string) (*Interval, error)
- func Perfect(step int) Interval
- type IntervalFunc
- type ModifierStrategy
- type Note
- type Pitch
- type Quality
- type QualityType
- type Scale
- type Transposer
Constants ¶
const ( DoubleFlat = -2 Flat = -1 Natural = 0 Sharp = 1 DoubleSharp = 2 )
Modifiers
const ( C int = iota + 1 D E F G A B )
Note naturals
Variables ¶
var ( D1 = Duration{1, 0, false} // Whole D2 = Duration{2, 0, false} // Half D4 = Duration{4, 0, false} // Quarter D8 = Duration{8, 0, false} // Eighth D16 = Duration{16, 0, false} // Sixteenth D32 = Duration{32, 0, false} // Thirty Second D64 = Duration{64, 0, false} // Sixty Fourth D128 = Duration{128, 0, false} // Hundred Twenty Eighth )
Durations
Functions ¶
Types ¶
type Interval ¶
Interval represents an interval in 12-tone equal temperament
func NewInterval ¶
NewInterval builds a new Interval
func ParseInterval ¶
func (Interval) Semitones ¶
Semitones returns the total number of semitones that make up the interval
func (Interval) Transpose ¶
func (i Interval) Transpose(o Interval) Transposer
Transpose returns a new Interval that has been transposed by the given Interval
type IntervalFunc ¶
IntervalFunc creates an interval at as specific step/degree
type ModifierStrategy ¶
ModifierStrategy is a function that maps a modifier to a diatonic
type Note ¶
Note is a pitch with a duration
func (Note) Transpose ¶
func (n Note) Transpose(i Interval) Transposer
Transpose transposes a note by a given interval
type Pitch ¶
type Pitch struct {
Interval
}
Pitch represents an absolute pitch in 12-tone equal temperament
func MustParsePitch ¶
MustParsePitch parses and returns a Pitch in scientific pitch notation or panics
func ParsePitch ¶
ParsePitch parses and returns a Pitch in scientific pitch notation
func (Pitch) Name ¶
func (p Pitch) Name(strategy ModifierStrategy) string
Name returns the name of the pitch using a particular name strategy (either AscNames or DescNames). The result is in scientific pitch notation format.
func (Pitch) Transpose ¶
func (p Pitch) Transpose(i Interval) Transposer
Transpose transposes a pitch by a given interval
type Quality ¶
type Quality struct { Type QualityType Size int }
Quality describes the quality of an interval
type QualityType ¶
type QualityType int
QualityType represents the type a Quality can take
const ( PerfectType QualityType = iota MajorType MinorType AugmentedType DiminishedType )
Quality types
func (QualityType) String ¶
func (q QualityType) String() string
type Scale ¶
type Scale []Transposer
Scale is a series of Transposers
func NewScale ¶
func NewScale(root Transposer, intervals []Interval, octaves int) Scale
NewScale returns a Scale built using a set of intervals
func (Scale) Transpose ¶
func (s Scale) Transpose(i Interval) Transposer
Transpose transposes a scale by the specified Interval
type Transposer ¶
type Transposer interface {
Transpose(Interval) Transposer
}
Transposer is something that shifts by an Interval