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

Documentation

Overview

Package drum imelements the decoding of .splice drum machine files. It also contains a drum machine implementation that support the playback, creation, and modification of the .splice files in real time

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Machine

type Machine struct {
	Sequences []*Sequence
	Curr      *Sequence
	Samples   map[string]Sample
	On        bool
	// contains filtered or unexported fields
}

Machine contains all the information necessary to load, play, and edit multiple Sequences, each containing multiple Sections.

func NewMachine

func NewMachine(sequenceDir, sampleDir string) (*Machine, error)

NewMachine creates the Machine struct and loads it with all available samples and sequences. it is expected that there will both a 'samples' directory and a 'sequences' directory within the package

func (*Machine) ChangeTempo

func (m *Machine) ChangeTempo(tempo float32)

ChangeTempo modifies the tempo of the currently playing sequence.

func (*Machine) ClearBeats

func (m *Machine) ClearBeats(row int)

ClearBeats sets all beats for a given section of the current sequence to false.

func (*Machine) Close

func (m *Machine) Close()

Close stops playback of the Machine and closes the associated audio stream.

func (*Machine) EnableSection

func (m *Machine) EnableSection(row int)

EnableSection turns on a section of a sequence, allowing the audio samples (if any) to be heard.

func (*Machine) LoadSequence

func (m *Machine) LoadSequence(row int)

LoadSequence changes the Machine's currently playing sequence. If a beat changed callback has been registered, it will be called with beat 0

func (*Machine) NewSequence

func (m *Machine) NewSequence(name, version string)

NewSequence will create a new sequence in the machine with the given name, based on the specified version (sample). Note that this will not create a splice file for the new sequence.

func (*Machine) SaveCurrentSequence

func (m *Machine) SaveCurrentSequence(name string)

SaveCurrentSequence writes the current machine sequence to a file in binary format. The file will be located in the sequence directory specified on Machine creation have the filename <name>.splice

func (*Machine) SetBeatChangeCB

func (m *Machine) SetBeatChangeCB(cb func(int))

SetBeatChangeCB set the function that will be called by the Machine at the beginning of every sixteenth note. The notes are zero based (0-15).

func (*Machine) ToggleBeat

func (m *Machine) ToggleBeat(row int, beat int)

ToggleBeat flips the current beat value for a given section/beat combination.

func (*Machine) TogglePlayPause

func (m *Machine) TogglePlayPause()

TogglePlayPause stops/start the audio playback.

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(fp 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 data. The file is expected to conform to the following format.

func (*Pattern) EncodeFile

func (p *Pattern) EncodeFile(fp string) error

EncodeFile takes a Pattern, encodes it to binary, and saves it to the specified file path

func (Pattern) MarshalBinary

func (p Pattern) MarshalBinary() ([]byte, error)

MarshalBinary encodes a given Pattern to binary form.

func (Pattern) String

func (p Pattern) String() string

func (*Pattern) UnmarshalBinary

func (p *Pattern) UnmarshalBinary(data []byte) error

UnmarshalBinary marshals the given binary data into the Pattern receiver.

type Sample

type Sample struct {
	Name string
	// contains filtered or unexported fields
}

Sample represents mutiple audio signal grouped under a common name

type Section

type Section struct {
	ID      uint16
	Name    string
	Beats   [16]bool
	Enabled bool
	Volume  float32
}

Section represents an audio sample, beat pattern, and misc. associated data.

type Sequence

type Sequence struct {
	Name     string
	Version  string
	Tempo    float32
	Sections []*Section
}

Sequence represent a set of sounds (or 'Sections') and the associated playback information such as tempo, and the sample it is connected to (Version).

type Track

type Track struct {
	ID    uint16
	Name  string
	Beats [16]bool
}

A Track represents an individual instrument or sound within a Pattern

func (Track) String

func (t Track) String() string

Directories

Path Synopsis
Package main is a CLI termbox client that provides an interface to it's parent 'drum' package.
Package main is a CLI termbox client that provides an interface to it's parent 'drum' package.

Jump to

Keyboard shortcuts

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