Documentation
¶
Overview ¶
Package sequence provides generators and options for creating audio sequences.
Index ¶
- type ChordPattern
- type Generator
- type HasChords
- type HasHolds
- type HasLength
- type HasLoops
- type HasPitches
- type HasTicks
- type HasVolumes
- type HasWaves
- type HoldPattern
- type Length
- type Loop
- type Option
- func And(opts ...Option) Option
- func Chords(cp ChordPattern) Option
- func HoldAt(t time.Duration, n int) Option
- func HoldPatternAt(t time.Duration, n int) Option
- func Holds(vs ...time.Duration) Option
- func Loops(b bool) Option
- func PitchAt(p synth.Pitch, n int) Option
- func PitchPatternAt(p synth.Pitch, n int) Option
- func Pitches(ps ...synth.Pitch) Option
- func PlayLength(i int) Option
- func Ticks(t time.Duration) Option
- func VolumeAt(v float64, n int) Option
- func VolumePatternAt(v float64, n int) Option
- func Volumes(vs ...float64) Option
- func WaveAt(w synth.Wave, n int) Option
- func WavePatternAt(w synth.Wave, n int) Option
- func Waves(ws ...synth.Wave) Option
- type PitchPattern
- type Sequence
- func (s *Sequence) Append(s2 *Sequence) (*Sequence, error)
- func (s *Sequence) Copy() (audio.Audio, error)
- func (s *Sequence) Filter(fs ...audio.Filter) (audio.Audio, error)
- func (s *Sequence) Mix(s2 *Sequence) (*Sequence, error)
- func (s *Sequence) MustCopy() audio.Audio
- func (s *Sequence) MustFilter(fs ...audio.Filter) audio.Audio
- func (s *Sequence) Play() <-chan error
- func (s *Sequence) PlayLength() time.Duration
- func (s *Sequence) SetVolume(int32) error
- func (s *Sequence) Stop() error
- type Tick
- type VolumePattern
- type WaveGenerator
- type WavePattern
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChordPattern ¶
A ChordPattern represents the order of pitches and holds for each of those pitches over a sequence of (potential) chords. Todo: pitchPattern is a subset of this, should it even exist?
func (*ChordPattern) GetChordPattern ¶
func (cp *ChordPattern) GetChordPattern() *ChordPattern
GetChordPattern returns a pointer to a generator's chord pattern
type Generator ¶
type Generator interface {
Generate() *Sequence
}
A Generator stores settings to create a sequence
type HasChords ¶
type HasChords interface {
GetChordPattern() *ChordPattern
}
HasChords lets generators be built from chord Options if they have a pointer to a chord pattern
type HasHolds ¶
HasHolds enables generators to be built from HoldPattern and use the related option functions
type HasPitches ¶
type HasVolumes ¶
type HoldPattern ¶
A HoldPattern is a pattern that might loop on itself for how long notes should be held
func (*HoldPattern) GetHoldPattern ¶
func (hp *HoldPattern) GetHoldPattern() *HoldPattern
GetHoldPattern lets composing HoldPattern satisfy HasHolds
type Option ¶
type Option func(Generator)
Option types are inserted into Constructors to create generators
func And ¶
And combines any number of options into a single option. And is a reminder that you can store combined settings to avoid having to rewrite them
func HoldAt ¶
HoldAt sets the n'th value in the entire play sequence to be Hold p. This could involve duplicating a pattern until it is long enough to reach n. Meaningless if the Hold pattern has not been set yet.
func HoldPatternAt ¶
HoldPatternAt sets the n'th value in the Hold pattern to be Hold p. Meaningless if the Hold pattern has not been set yet.
func PitchAt ¶
PitchAt sets the n'th value in the entire play sequence to be pitch p. This could involve duplicating a pattern until it is long enough to reach n. Meaningless if the pitch pattern has not been set yet.
func PitchPatternAt ¶
PitchPatternAt sets the n'th value in the pitch pattern to be pitch p. Meaningless if the pitch pattern has not been set yet.
func PlayLength ¶
func VolumeAt ¶
VolumeAt sets the n'th value in the entire play sequence to be Volume p. This could involve duplicating a pattern until it is long enough to reach n. Meaningless if the Volume pattern has not been set yet.
func VolumePatternAt ¶
VolumePatternAt sets the n'th value in the Volume pattern to be Volume p. Meaningless if the Volume pattern has not been set yet.
func WaveAt ¶
WaveAt sets the n'th value in the entire play sequence to be Wave p. This could involve duplicating a pattern until it is long enough to reach n. Meaningless if the Wave pattern has not been set yet.
func WavePatternAt ¶
WavePatternAt sets the n'th value in the Wave pattern to be Wave p. Meaningless if the Wave pattern has not been set yet.
type PitchPattern ¶
func (*PitchPattern) GetPitchPattern ¶
func (pp *PitchPattern) GetPitchPattern() []synth.Pitch
func (*PitchPattern) SetPitchPattern ¶
func (pp *PitchPattern) SetPitchPattern(ps []synth.Pitch)
type Sequence ¶
type Sequence struct { // Sequences play patterns of audio // everything at Pattern[0] will be simultaneously Play()ed at // Sequence.Play() Pattern []*audio.Multi // Every tick, the next index in Pattern will be played by a Sequence // until the pattern is over. Ticker *time.Ticker // contains filtered or unexported fields }
A Sequence is a timed pattern of simultaneously played audios.
func (*Sequence) MustFilter ¶
MustFilter acts as filter, but does not respect errors.
func (*Sequence) PlayLength ¶
PlayLength returns how long this sequence will play before looping or stopping. This does not include how long the last note is held beyond the tick duration
type VolumePattern ¶
type VolumePattern []float64
func (*VolumePattern) GetVolumePattern ¶
func (vp *VolumePattern) GetVolumePattern() []float64
func (*VolumePattern) SetVolumePattern ¶
func (vp *VolumePattern) SetVolumePattern(vs []float64)
type WaveGenerator ¶
type WaveGenerator struct { ChordPattern PitchPattern WavePattern VolumePattern HoldPattern Length Tick Loop }
A WaveGenerator composes sets of simple waveforms as a sequence
func NewWaveGenerator ¶
func NewWaveGenerator(opts ...Option) *WaveGenerator
NewWaveGenerator uses optional variadic syntax to enable any variant of a generator to be made
func (*WaveGenerator) Generate ¶
func (wg *WaveGenerator) Generate() *Sequence
Generate generates a sequence from this wave generator
type WavePattern ¶
func (*WavePattern) GetWavePattern ¶
func (wp *WavePattern) GetWavePattern() []synth.Wave
func (*WavePattern) SetWavePattern ¶
func (wp *WavePattern) SetWavePattern(ws []synth.Wave)