note

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidDegree = errors.New("InvalidDegree")
)
View Source
var (
	ErrUnknownAccidental = errors.New("UnknownAccidental")
)
View Source
var (
	ErrUnknownName = errors.New("UnknownName")
)

Functions

func GenerateDegrees

func GenerateDegrees(maxDegree uint) iter.Seq[Degree]

Types

type Accidental

type Accidental int
const (
	UnknownAccidental Accidental = iota
	Natural
	Sharp
	Flat
	DoubleSharp
	DoubleFlat
)

func NewAccidental

func NewAccidental(s string) Accidental

func (Accidental) Semitone

func (a Accidental) Semitone() Semitone

func (Accidental) String

func (a Accidental) String(simple bool) string

type CoerceDegreeName

type CoerceDegreeName int
const (
	UnknownCoerceDegreeName CoerceDegreeName = iota
	MajorOrPerfectCoerceDegree
	MinorOrDiminishedCoerceDegree
	AugmentedCoerceDegree
	DiminishedCoerceDegree
	DoublyAugmentedCoerceDegree
	DoublyDiminishedCoerceDegree
)

func NewCoerceDegree

func NewCoerceDegree(s string) CoerceDegreeName

func (CoerceDegreeName) Degree

func (c CoerceDegreeName) Degree(value uint) (Degree, bool)

func (CoerceDegreeName) String

func (c CoerceDegreeName) String() string

type Degree

type Degree struct {
	Value uint
	Name  DegreeName
}

func MustNewDegree

func MustNewDegree(value uint, name DegreeName) Degree

func NewDegree

func NewDegree(value uint, name DegreeName) (Degree, bool)

func ParseDegree

func ParseDegree(s string) (Degree, error)

func (Degree) MarshalYAML

func (d Degree) MarshalYAML() (any, error)

func (Degree) Semitone

func (d Degree) Semitone() (Semitone, bool)

func (Degree) String

func (d Degree) String() string

func (*Degree) UnmarshalYAML

func (d *Degree) UnmarshalYAML(value *yaml.Node) error

type DegreeName

type DegreeName int
const (
	UnknownDegree DegreeName = iota
	MajorDegree
	MinorDegree
	PerfectDegree
	AugmentedDegree
	DiminishedDegree
	DoublyAugmentedDegree
	DoublyDiminishedDegree
)

func (DegreeName) Coerce

func (d DegreeName) Coerce() CoerceDegreeName

func (DegreeName) String

func (i DegreeName) String() string

type Name

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

func NewName

func NewName(s string) Name

func (Name) AddDegree

func (n Name) AddDegree(degree int) (Name, Octave)

func (Name) GetDegree

func (x Name) GetDegree(y Name) (uint, bool)

func (Name) MarshalJSON

func (n Name) MarshalJSON() ([]byte, error)

func (Name) MarshalYAML

func (n Name) MarshalYAML() (any, error)

func (Name) Semitone

func (n Name) Semitone() Semitone

func (Name) String

func (n Name) String() string

type Note

type Note struct {
	Name       Name
	Accidental Accidental
}

func NewNote

func NewNote(name Name, accidental Accidental) Note

func ParseNote

func ParseNote(s string) (Note, error)

func (Note) AddDegree

func (n Note) AddDegree(d Degree, precedeSharp bool) (Note, Octave, error)

func (Note) MarshalYAML

func (n Note) MarshalYAML() (any, error)

func (Note) Semitone

func (n Note) Semitone() Semitone

func (Note) String

func (n Note) String() string

type Octave

type Octave int

func (Octave) Semitone

func (o Octave) Semitone() Semitone

type Semitone

type Semitone int

func (Semitone) MarshalYAML

func (s Semitone) MarshalYAML() (any, error)

func (Semitone) Octave

func (s Semitone) Octave() Octave

func (*Semitone) UnmarshalYAML

func (s *Semitone) UnmarshalYAML(value *yaml.Node) error

func (Semitone) WithoutOctave

func (s Semitone) WithoutOctave() Semitone

type Value

type Value struct {
	util.Rat
}

func MustNewValue

func MustNewValue(num, denom uint) Value

func NewValue

func NewValue(num, denom uint) (Value, error)

func (Value) MarshalYAML

func (v Value) MarshalYAML() (any, error)

func (*Value) UnmarshalYAML

func (v *Value) UnmarshalYAML(value *yaml.Node) error

Jump to

Keyboard shortcuts

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