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: 5 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 Pattern

type Pattern struct {
	Version string
	Tempo   float32
	Tracks  []Track
}

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. The drum machine file consists of a header followed by the tracks. Header: the header has a fixed size so we use a struct to read it in one go. Tracks: the tracks have a variable length, therefore we loop through the tracks until we have read all the bytes. The length is stored in the header. Before reading in the tracks we create a slice that can store the maximum number of tracks. We also create a counter that holds the actual number of tracks. After looping through the tracks we re-slice the tracks slice with the actual number of tracks.

func (Pattern) String

func (p Pattern) String() string

String returns the string representation of a Pattern, e.g.: Saved with HW Version: 0.808-alpha Tempo: 98.4 (0) kick |x---|----|x---|----| (1) snare |----|x---|----|x---| (3) hh-open |--x-|--x-|x-x-|--x-| (5) cowbell |----|----|x---|----|

type Track

type Track struct {
	ID    uint32
	Name  string
	Steps [16]bool
}

Track is the high level representation of a single sound track.

func (Track) String

func (t Track) String() string

String returns the output of one track, e.g.: "(40) kick |x--x|----|x---|x--x|"

Jump to

Keyboard shortcuts

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