Documentation ¶
Overview ¶
wavetable implementation
Index ¶
- func FourierTable(nharms int, amps []float64, length int, phase float64) []float64
- func Len(g *Gtable) int
- func SawTable(nharms, length int) []float64
- func SquareTable(nharms, length int) []float64
- func TriangleTable(nharms, length int) []float64
- type Gtable
- type LookupOscillator
- type Oscillator
- type Shape
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FourierTable ¶ added in v0.10.0
FourierTable constructs a lookup table based on fourier addition with 'nharmns' harmonics If amps is provided, scales the harmonics by the provided amp
func SquareTable ¶ added in v0.10.0
SquareTable uses fourier addition to create a square waveform
func TriangleTable ¶ added in v0.10.0
TriangleTable uses fourier addition to create a triangle waveform
Types ¶
type Gtable ¶
type Gtable struct {
// contains filtered or unexported fields
}
Gtable is a Guard-table for oscillator lookup
func NewSineTable ¶
NewSineTable returns a lookup table populated for sine-wave generation.
type LookupOscillator ¶
type LookupOscillator struct { Oscillator Table *Gtable SizeOverSr float64 // convenience variable for calculations }
LookupOscillator is an oscillator that's more gentle on your CPU By performing a table lookup to generate the required waveform..
func NewLookupOscillator ¶
func NewLookupOscillator(sr int, t *Gtable, phase float64) (*LookupOscillator, error)
NewLookupOscillator creates a new oscillator which performs a table-lookup to generate the required waveform
func (*LookupOscillator) BatchInterpolateTick ¶ added in v0.10.0
func (l *LookupOscillator) BatchInterpolateTick(freq float64, nframes int) []float64
BatchInterpolateTick performs a lookup for N frames, and interpolates the value if the requested index does not appear in the table.
func (*LookupOscillator) BatchTruncateTick ¶ added in v0.10.0
func (l *LookupOscillator) BatchTruncateTick(freq float64, nframes int) []float64
BatchTruncateTick returns a slice of samples from the oscillator of the requested length
func (*LookupOscillator) InterpolateTick ¶
func (l *LookupOscillator) InterpolateTick(freq float64) float64
InterpolateTick performs a lookup but interpolates the value if the requested index does not appear in the table.
func (*LookupOscillator) TruncateTick ¶
func (l *LookupOscillator) TruncateTick(freq float64) float64
TruncateTick performs a lookup and truncates the value index down (if the index for lookup = 10.5, return index 10)
type Oscillator ¶
type Oscillator struct {
// contains filtered or unexported fields
}
Oscillator represents a wave-oscillator where each tick is calculated in the moment.
func NewOscillator ¶
func NewOscillator(sr int, shape Shape) (*Oscillator, error)
NewOscillator set to a given sample rate
func NewPhaseOscillator ¶
func NewPhaseOscillator(sr int, phase float64, shape Shape) (*Oscillator, error)
NewPhaseOscillator creates a new oscillator where the initial phase is offset by a given phase
func (*Oscillator) Tick ¶
func (o *Oscillator) Tick(freq float64) float64
Tick generates the next value of the oscillator waveform at a given frequency in Hz