models

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Instrument

type Instrument struct {
	// Name of the instrument, e.g. Snare
	Name string
	// File location of the instrument's audio sample (relative to root of project)
	// Filename string
	// Beat subdivisions where the instrument should be triggered
	Pattern []int
	// Manager for audio of instrument
	Audio audio.Manager
}

Instrument stores audio for later playback.

func NewInstrument

func NewInstrument(name, filename string, pattern []int) (*Instrument, error)

NewInstrument builds an Instrument object with Audio support.

type Track

type Track struct {
	// Title of the track
	Title string
	// Amount of time the track should play
	Length time.Duration
	// Beats per minute (BPM) of the track
	BeatsPerMinute int
	// Number of beats per measure
	BeatsPerMeasure int
	// Number of times to divide each beat (e.g. 1 for quarter notes, 2 for eighth notes)
	DivisionsPerBeat int
	// Instruments used in the track.
	Instruments []*Instrument
	// Sequence of instruments to be played in the track.
	Patterns [][]*Instrument
}

Track is an object which can be played.

func NewTrack

func NewTrack(title string, instruments []*Instrument, beatsPerMinute, beatsPerMeasure, divisionsPerBeat int) (*Track, error)

NewTrack creates a new track with calculated track pattern.

func (*Track) Play

func (t *Track) Play() error

Play plays a track. This entails printing out the track's pattern as it is played, and playing the audio for the instruments of the track.

Jump to

Keyboard shortcuts

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