ai

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2017 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertNotes

func ConvertNotes(notes [][]int, startBeat int) (song *music.Music)

Types

type AI

type AI struct {
	// BeatsBetweenLicks specifies the amount of space
	// between each lick before adding an "end"
	BeatsBetweenLicks int

	// HighPassFilter only uses notes above a certain level
	HighPassFilter int

	// MinimumLickLength is the minimum number of notes for a lick
	MinimumLickLength int

	// MaximumLickLength is the maximum number of notes for a lick
	MaximumLickLength int

	// keep track of whether it is learning,
	// so learning can be done asynchronously
	IsLearning bool
	HasLearned bool
	// contains filtered or unexported fields
}

MarkovAI is an implementation of an AI that aims to improvise in realtime. In this implementation, the current history of real playing is used to generate transition probabilities which are used to reconstruct new licks.

func New

func New() (m *AI)

func (*AI) Analyze

func (m *AI) Analyze(notes music.Notes) (analyzedNotes [][]int)

func (*AI) Couple

func (m *AI) Couple(index int, coupling []int)

Couple will take an index and a coupling and attach to the matrix. For example, to couple current Velocity to previous Pitch and previous Velocity, you would use Couple(1,[]int{-1,-1,0,0}), where {0,1,2,3} -> {Pitch,Velocity,Duration,Lag}.

func (*AI) GenerateNote

func (m *AI) GenerateNote(prevValue []int, prevPrevValue []int) (curValue []int)

func (*AI) Learn

func (m *AI) Learn(notes music.Notes) (err error)

Learn is for calculating the matricies for the transition probabilities

func (*AI) Learn2

func (ai *AI) Learn2(notes music.Notes) (err error)

Learn is for calculating the matricies for the transition probabilities

func (*AI) Learn3

func (ai *AI) Learn3(notes music.Notes) (err error)

Learn is for calculating the matricies for the transition probabilities

func (*AI) Learn4

func (ai *AI) Learn4(notes music.Notes) (err error)

Learn is for calculating the matricies for the transition probabilities

func (*AI) Lick

func (m *AI) Lick(startBeat int) (lick *music.Music, err error)

Lick generates a sequence of chords using the Markov probabilities. Must run Learn() beforehand.

func (*AI) Lick2

func (ai *AI) Lick2(startBeat int) (lick *music.Music, err error)

Lick2 generates a sequence of chords using the Markov probabilities. Must run Learn2() beforehand.

func (*AI) Lick3

func (ai *AI) Lick3(startBeat int) (lick *music.Music, err error)

Lick2 generates a sequence of chords using the Markov probabilities. Must run Learn2() beforehand.

func (*AI) Lick4

func (ai *AI) Lick4(startBeat int) (lick *music.Music, err error)

Lick2 generates a sequence of chords using the Markov probabilities. Must run Learn2() beforehand.

type Pair

type Pair struct {
	Key   int
	Value int
}

type PairList

type PairList []Pair

func (PairList) Len

func (p PairList) Len() int

func (PairList) Less

func (p PairList) Less(i, j int) bool

func (PairList) Swap

func (p PairList) Swap(i, j int)

Jump to

Keyboard shortcuts

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