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 ¶
- type Machine
- func (m *Machine) ChangeTempo(tempo float32)
- func (m *Machine) ClearBeats(row int)
- func (m *Machine) Close()
- func (m *Machine) EnableSection(row int)
- func (m *Machine) LoadSequence(row int)
- func (m *Machine) NewSequence(name, version string)
- func (m *Machine) SaveCurrentSequence(name string)
- func (m *Machine) SetBeatChangeCB(cb func(int))
- func (m *Machine) ToggleBeat(row int, beat int)
- func (m *Machine) TogglePlayPause()
- type Pattern
- type Sample
- type Section
- type Sequence
- type Track
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 ¶
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 ¶
ChangeTempo modifies the tempo of the currently playing sequence.
func (*Machine) ClearBeats ¶
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 ¶
EnableSection turns on a section of a sequence, allowing the audio samples (if any) to be heard.
func (*Machine) LoadSequence ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
Pattern is the high level representation of the drum pattern contained in a .splice file.
func DecodeFile ¶
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 ¶
EncodeFile takes a Pattern, encodes it to binary, and saves it to the specified file path
func (Pattern) MarshalBinary ¶
MarshalBinary encodes a given Pattern to binary form.
func (*Pattern) UnmarshalBinary ¶
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