drum

package
v0.0.0-...-e04bdec Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2015 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package drum is supposed to implement the decoding of .splice drum machine files. See golang-challenge.com/go-challenge1/ for more information

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder

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

Decoder is intended for use in unmarshalling binary formatted pattern data.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a *Decoder instance over an io.Reader instance.

func (*Decoder) Unmarshal

func (d *Decoder) Unmarshal() (*Pattern, error)

Unmarshal will return a Pattern instance or an error if there is a problem reading the binary data handed to the decoder.

type Pattern

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

Pattern is the high level representation of the drum pattern contained in a .splice file.

func DecodeFile

func DecodeFile(path string) (*Pattern, error)

DecodeFile decodes the drum machine file found at the provided path and returns a pointer to a parsed pattern which is the entry point to the rest of the data.

func (*Pattern) AddTrack

func (p *Pattern) AddTrack(b *Track)

AddTrack will append the given track instance to the pattern.

func (*Pattern) SetTempo

func (p *Pattern) SetTempo(t float32)

SetTempo assigns the tempo for the pattern instance. This is in bpm (beats per minute).

func (*Pattern) SetVersion

func (p *Pattern) SetVersion(v string)

SetVersion assigns the version string to the pattern instance.

func (*Pattern) String

func (p *Pattern) String() string

String will return a string value of the pattern; this includes version, tempo and the tracks and there associated steps in 4/4 format.

func (*Pattern) Tempo

func (p *Pattern) Tempo() float32

Tempo returns the tempo of the pattern. This is in bpm (beats per minute).

func (*Pattern) Version

func (p *Pattern) Version() string

Version returns the patterns version number.

type Track

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

Track represents the 4/4 set of steps for a name/id.

func NewTrack

func NewTrack() *Track

NewTrack creates a new instance of a track with fixed number of steps.

func (*Track) ID

func (t *Track) ID() uint32

ID returns the tracks integer identifier.

func (*Track) Name

func (t *Track) Name() string

Name is the tracks user-friendly representation.

func (*Track) SetID

func (t *Track) SetID(id uint32)

SetID sets the identifier number of the track.

func (*Track) SetName

func (t *Track) SetName(name string)

SetName sets the name of the track.

func (*Track) SetStep

func (t *Track) SetStep(n int, v bool)

SetStep assigns the given step index the value true/false.

func (*Track) Step

func (t *Track) Step(n int) bool

Step returns the n'th index value - whether it is true/false.

func (*Track) String

func (t *Track) String() string

String returns the id, name and steps of the track as a string.

Jump to

Keyboard shortcuts

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