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: 5 Imported by: 16




This section is empty.


This section is empty.


This section is empty.


type Music

type Music struct {
	// Notes map: tick -> pitch -> note
	Notes map[int]map[int]Note

Music stores all the notes that will be played / were already played

func New

func New() *Music

New returns a new object

func Open

func Open(filename string) (*Music, error)

OpenMusic opens a previous music

func (*Music) AddNote

func (m *Music) AddNote(n Note) (err error)

AddNote will add a note in a thread-safe way.

func (*Music) Get

func (m *Music) Get(beat int) (hasNotes bool, notes []Note)

Get retrieve notes in music in a thread-safe way

func (*Music) GetAll

func (m *Music) GetAll() (notes []Note)

GetAll retrieve notes in music in a thread-safe way

func (*Music) HasFuture

func (m *Music) HasFuture(currentBeat int) bool

HasFuture returns whether there are future beats in the registry

func (*Music) Save

func (m *Music) Save(filename string) (err error)

type Note

type Note struct {
	On       bool
	Pitch    int
	Velocity int
	Beat     int

Note carries the pitch, velocity, and duration information of a single press

func (*Note) Name

func (n *Note) Name() string

func (*Note) Time

func (n *Note) Time() string

Time returns when it will be played (or turned off)

type Notes

type Notes []Note

Notes is a structure for sorting the notes based on current beat

func (Notes) Len

func (p Notes) Len() int

func (Notes) Less

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

func (Notes) Swap

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

Source Files

Jump to

Keyboard shortcuts

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