Version: v1.0.0 Latest Latest

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

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




This section is empty.


This section is empty.


This section is empty.


type Player

type Player struct {
	// BPM is the beats per minute
	BPM int
	// Beat counts the number of 1/64 beats
	Tick int
	// Key stores the key of the song (TODO: Add in key-signature constraints)
	Key string

	// Piano is the piano that does the playing, the MIDI keyboard
	Piano *piano.Piano
	// MusicFuture is a map of future chords to play
	MusicFuture *music.Music
	// MusicHistory is a map of all the previous notes played
	MusicHistory     *music.Music
	MusicHistoryFile string

	// AI stores the AI being used
	AI *ai2.AI
	// BeatsOfSilence waits this number of beats before asking
	// the AI for an improvisation
	BeatsOfSilence int

	// HighPassFilter only uses notes above a certain level
	// for computing last note
	HighPassFilter int
	// KeysCurrentlyPressed keeps track of whether a key is down (should be 0 if no keys are down)
	KeysCurrentlyPressed int

	// Listening frequency (to determine tick size)
	ListeningRateHertz int
	// Number of ticks per beat
	TicksPerBeat int
	// 1/Quantize = shortest possible note
	Quantize int

	// flag to allow only manually activation
	ManualAI bool

	// UseHostVelocity changes emitted notes to follow the velocity of the host
	UseHostVelocity bool

	LastHostPress int
	IsImprovising bool
	// contains filtered or unexported fields

Player is the main structure which facilitates the Piano, and the AI. The Player spawns threads for listening to events on the Piano, and also spawns threads for playing notes on the piano. It also spawns threads for doing the machine learning and using the results.

func New

func New(bpm, listenHertz int, debug bool) (p *Player, err error)

New initializes the parameters and connects up the piano

func (*Player) Close

func (p *Player) Close() (err error)

Close will do the shutdown routines before exiting

func (*Player) Emit

func (p *Player) Emit(beat int)

Emit will play/stop notes depending on the current beat. This should be run in a separate thread.

func (*Player) Improvisation

func (p *Player) Improvisation()

Improvisation generates an improvisation from the AI and loads into the next beats to be playing

func (*Player) Listen

func (p *Player) Listen()

Listen tells the player to listen to events from the piano MIDI connection. This is meant to be run in a separate thread.

func (*Player) Start

func (p *Player) Start()

Start initializes the metronome which keeps track of beats Each beat will start new threads to Emit new chords, and/or generate new Improvisation

func (*Player) Teach

func (p *Player) Teach() (err error)

Source Files

Jump to

Keyboard shortcuts

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