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: 8 Imported by: 0

README

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 Bar

type Bar [4]Note

A Bar is a collection of notes.

func (Bar) String

func (bar Bar) String() string

type Note

type Note bool

A Note is a single unit of musical composition.

func (Note) String

func (n Note) String() string

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) String

func (p Pattern) String() string

type PatternHeader

type PatternHeader struct {
	Version [32]byte
	Tempo   float32
	// contains filtered or unexported fields
}

A PatternHeader refers to the boilerplate above the musical notes in a pattern file.

func (*PatternHeader) GetTempo

func (ph *PatternHeader) GetTempo() Tempo

GetTempo returns a Tempo.

func (*PatternHeader) GetVersion

func (ph *PatternHeader) GetVersion() Version

GetVersion returns a Version which has been parsed and trimmed for further consumption.

type PatternHeaderParser

type PatternHeaderParser struct{}

A PatternHeaderParser is responsible for parsing a PatternHeader.

func NewPatternHeaderParser

func NewPatternHeaderParser() *PatternHeaderParser

NewPatternHeaderParser creates and returns a PatternHeaderParser.

func (*PatternHeaderParser) Parse

func (php *PatternHeaderParser) Parse(b []byte) (PatternHeader, error)

Parse returns a parsed PatternHeader given a valid byte slice.

type PatternParser

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

A PatternParser is responsible for parsing the individual pieces of a pattern file.

func NewPatternParser

func NewPatternParser() *PatternParser

NewPatternParser returns an initialized PatternParser.

func (*PatternParser) Parse

func (pp *PatternParser) Parse(b []byte) (*Pattern, error)

Parse calls its child parsers and returns, if successful, a parsed pattern.

type PatternReader

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

A PatternReader reads a file and takes the appropriate actions to begin parsing.

func NewPatternReader

func NewPatternReader(filePath string) *PatternReader

NewPatternReader creates and returns a PatternReader given a file path to a pattern file.

func (*PatternReader) Read

func (pr *PatternReader) Read() (*Pattern, error)

Read pulls in a file and starts the parsing process, returning a complete Pattern if successful.

type PatternTracksParser

type PatternTracksParser struct{}

A PatternTracksParser is responsible for parsing the musical section of a pattern file.

func NewPatternTracksParser

func NewPatternTracksParser() *PatternTracksParser

NewPatternTracksParser creates and returns a PatternTracksParser.

func (*PatternTracksParser) Parse

func (ptp *PatternTracksParser) Parse(b []byte) Tracks

Parse parses the given byte slice and returns a list of found tracks.

type Steps

type Steps struct {
	Bars [4]Bar
}

Steps refers to a collection of bars combined to create a track.

func (Steps) String

func (s Steps) String() string

type Tempo

type Tempo float64

A Tempo is the number of beats-per-minute used when playing tracks from a given pattern.

func (Tempo) String

func (t Tempo) String() string

type Track

type Track struct {
	ID    int
	Name  string
	Steps Steps
}

A Track is a single instrument's part of the music.

func (Track) String

func (t Track) String() string

type Tracks

type Tracks []Track

Tracks contains a reference to tracks for any instrument used in creating the file.

func (Tracks) String

func (t Tracks) String() string

type Version

type Version string

A Version describes the version of the drum machine used to generate the .splice file.

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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