Documentation
¶
Overview ¶
Package dsp provides common digital signal processing operations.
Index ¶
- func Chebyshev(n int, x float64) float64
- func Clamp(s, min, max float64) float64
- func Cos(x float64) float64
- func Cubic(y0, y1, y2, y3, m float64) float64
- func ExpRatio(ratio, speed float64) float64
- func Fold(s, min, max float64) float64
- func Hermite(x0, x1, x2, x3, t float64) float64
- func IsPowerOfTwo(x int) bool
- func Lerp(x1, x2, m float64) float64
- func Mix(mix, a, b float64) float64
- func Overload(x float64) float64
- func PanMix(pan, a, b float64) (float64, float64)
- func RandRange(min, max float64) float64
- func Sin(x float64) float64
- func SoftClamp(s, threshold float64) float64
- func Tan(x float64) float64
- type AllPass
- type BeatsPerMin
- type DCBlock
- type Decimate
- type DelayLine
- func (d *DelayLine) ReadAbsolute(pos float64) float64
- func (d *DelayLine) ReadRelative(scale float64) float64
- func (d *DelayLine) Size() int
- func (d *DelayLine) Tick(v float64) float64
- func (d *DelayLine) TickAbsolute(v, delay float64) float64
- func (d *DelayLine) TickRelative(v, scale float64) float64
- func (d *DelayLine) Write(v float64)
- type FBComb
- type FFComb
- type Filter
- type FilterType
- type Float64
- type Hz
- type MS
- type Pitch
- type PitchShift
- type RollingAverage
- type SVFilter
- type Valuer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExpRatio ¶
ExpRatio produces an (inverse-)exponential curve that's inflection can be controlled by a specific ratio
func IsPowerOfTwo ¶
IsPowerOfTwo determines whether or not an integer is a power of two
Types ¶
type AllPass ¶
type AllPass struct {
// contains filtered or unexported fields
}
AllPass is an allpass filter
func (*AllPass) Tick ¶
Tick advances the allpass filter state using the full length of the delay line
func (*AllPass) TickAbsolute ¶
TickAbsolute advances the allpass filter state with a specified absolute delay length (less than maximum)
func (*AllPass) TickRelative ¶
TickRelative advances the allpass filter state with a delay length relative to the length of the delay line
type BeatsPerMin ¶
BeatsPerMin represents beats-per-minute
func BPM ¶
func BPM(v float64, sampleRate int) BeatsPerMin
BPM returns a scalar value in beats-per-minute
func (BeatsPerMin) Float64 ¶
func (bpm BeatsPerMin) Float64() float64
Float64 returns the constant value
func (BeatsPerMin) String ¶
func (bpm BeatsPerMin) String() string
type DCBlock ¶
type DCBlock struct {
// contains filtered or unexported fields
}
DCBlock keeps a signal centered around zero
type Decimate ¶
type Decimate struct { SampleRate float64 // contains filtered or unexported fields }
Decimate reduces the resolution/bandwidth of a signal to produce bitcrushing effects
type DelayLine ¶
type DelayLine struct {
// contains filtered or unexported fields
}
DelayLine is a simple delay line
func NewDelayLine ¶
NewDelayLine returns a new DelayLine of a specific maximum size in milliseconds
func NewDelayLineMS ¶
NewDelayLineMS returns a new DelayLine of a specific maximum size in milliseconds
func (*DelayLine) ReadAbsolute ¶
ReadAbsolute reads a specific sample offset from the DelayLine
func (*DelayLine) ReadRelative ¶
ReadRelative reads sample from the DelayLine at a scale between 0 and 1
func (*DelayLine) TickAbsolute ¶
TickAbsolute advances the state of the DelayLine using a specific delay length (less than total) in samples
func (*DelayLine) TickRelative ¶
TickRelative advances the state of the DelayLine using a scale between 0 and 1
type FBComb ¶
type FBComb struct {
// contains filtered or unexported fields
}
FBComb is a feedback comb filter
func NewFBCombMS ¶
NewFBCombMS returns a new FBComb that's length is represented in milliseconds
func (*FBComb) TickAbsolute ¶
TickAbsolute advances the filter's state with a specific delay
type FFComb ¶
type FFComb struct {
// contains filtered or unexported fields
}
FFComb is a feedforward comb filter
func NewFFCombMS ¶
NewFFCombMS returns a new FFComb that's length is represented in milliseconds
func (*FFComb) TickAbsolute ¶
TickAbsolute advances the filter's state with a specific delay
type Filter ¶
type Filter struct { Type FilterType Poles int Cutoff, Resonance float64 // contains filtered or unexported fields }
Filter is a simple low-pass or high-pass filter.
type FilterType ¶
type FilterType int
FilterType describes what frequencies will be allowed/eliminated in an outgoing signal.
const ( LowPass FilterType = iota HighPass )
FilterTypes for Filter
type MS ¶
MS is a value representation of milliseconds
func DurationInt ¶
DurationInt returns a scalar value (int) in MS
type Pitch ¶
type Pitch struct { Valuer Pitch musictheory.Pitch Raw string }
Pitch is a pitch that has been expressed in scientific notation
func ParsePitch ¶
ParsePitch parses the scientific notation of a pitch
type PitchShift ¶
type PitchShift struct {
// contains filtered or unexported fields
}
PitchShift shifts a pitch
func (*PitchShift) TickSemitones ¶
func (s *PitchShift) TickSemitones(in, semitones float64) float64
TickSemitones shifts a pitch by a specific number of semitones in equal temperament.
type RollingAverage ¶
type RollingAverage struct { Window int // contains filtered or unexported fields }
RollingAverage calculates a rolling average over a specified window size
func (*RollingAverage) Tick ¶
func (a *RollingAverage) Tick(in float64) float64
Tick advances the filter's state