player

package
v1.23.7 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: MIT Imports: 15 Imported by: 3

Documentation

Overview

Package player provides an easy way to play a SMF (Standard MIDI File).

Create a new Player with SMF(). Use PlayAll() to write to a MIDI out port.

See the CLI player in the example folder.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Player

type Player struct {
	// contains filtered or unexported fields
}

Player is a SMF (MIDI file) player.

func New

func New(rd io.Reader, options ...smfreader.Option) (*Player, error)

New creates a new Player, based on the given io.Reader

func SMF

func SMF(file string, options ...smfreader.Option) (*Player, error)

SMF creates a new Player for the given file. If you need to pass an opened file, use New.

func (*Player) GetMessages

func (p *Player) GetMessages(callback func(wait time.Duration, m midi.Message, track int16))

GetMessages calls the given callback for each midi message and passes the sleeping time until that message is to be played as well as the track number and the message itself. The callback is called until there are no midi messages left.

func (*Player) PlayAll

func (p *Player) PlayAll(out midi.Out, stop <-chan bool, finished chan<- bool)

PlayAll is a shortcut for PlayAllTo when using a MIDI port as output. It stops hanging notes before returning and when stopping. If you need to pass a specific midi.Writer, use PlayAllTo.

func (*Player) PlayAllTo

func (p *Player) PlayAllTo(wr midi.Writer, stop <-chan bool, finished chan<- bool)

PlayAllTo plays all tracks to the given midi.Writer until there are no messages left or a boolean is inserted into the given stop channel. When the function returns, the playing has finished. It stops hanging notes, when finished / stopped. If you need to play to different writers per track or channel, use GetMessages and define your own playing style.

Directories

Path Synopsis
example
smfplayer module

Jump to

Keyboard shortcuts

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