dsp

package
v0.0.0-...-3ce1907 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 12, 2018 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BlackmanFreqCoeff = []float64{0.16 / 4, -1.0 / 4, (1 - 0.16) / 2, -1.0 / 4, 0.16 / 4}
	HammingFreqCoeff  = []float64{(0.53836 - 1) / 2, 0.53836, (0.53836 - 1) / 2}
	HanningFreqCoeff  = []float64{-0.25, 0.5, -0.25}

	BlackmanFreqCoeff32 = []float32{0.16 / 4, -1.0 / 4, (1 - 0.16) / 2, -1.0 / 4, 0.16 / 4}
	HammingFreqCoeff32  = []float32{(0.53836 - 1) / 2, 0.53836, (0.53836 - 1) / 2}
	HanningFreqCoeff32  = []float32{-0.25, 0.5, -0.25}
)

Functions

func Atan2LUT

func Atan2LUT(y, x int) int

func BlackmanWindow

func BlackmanWindow(output []float64)

func BlackmanWindowF32

func BlackmanWindowF32(output []float32)

func Conj32

func Conj32(x complex64) complex64

func F32toi16

func F32toi16(input []float32, output []int16, scale float32)

F32toi16 converts scaled 32-bit floats to 16-bit integers.

func F32toi16ble

func F32toi16ble(input []float32, output []byte, scale float32)

F32toi16ble converts float32 to int16 stored in a byte slice. The values are stored in little-endian.

func FastAtan2

func FastAtan2(y, x float32) float32

max |error| < 0.01

func FastAtan2Fixed

func FastAtan2Fixed(y, x int) int

func FastAtan2_2

func FastAtan2_2(y, x float32) float32

|error| < 0.005

func FastPhase32

func FastPhase32(x complex64) float32

func HammingWindow

func HammingWindow(output []float64)

func HammingWindowF32

func HammingWindowF32(output []float32)

func HanningWindow

func HanningWindow(output []float64)

func HanningWindowF32

func HanningWindowF32(output []float32)

func Hermite4p3o

func Hermite4p3o(samples []float64, x float64) float64

Hermite4p3o interpolates using 4-point, 3rd-order Hermite (x-form)

func Hermite4p3oF32

func Hermite4p3oF32(samples []float32, x float32) float32

Hermite4p3oF32 interpolates using 4-point, 3rd-order Hermite (x-form)

func I16bleToF32

func I16bleToF32(input []byte, output []float32, scale float32)

I16bleToF32 converts int16 stored in a byte slice as little endian to float64.

func I16bleToF64

func I16bleToF64(input []byte, output []float64, scale float64)

I16bleToF64 converts int16 stored in a byte slice as little endian to float64.

func I8tof32

func I8tof32(input []byte, output []float32)

I8tof32 converts signed 8-bit samples to 32-bit float. It does not scale the samples.

func Linear

func Linear(samples []float64, x float64) float64

Linear interpolates using linear interpolation.

func LinearF32

func LinearF32(samples []float32, x float32) float32

LinearF32 interpolates using linear interpolation.

func NuttallWindow

func NuttallWindow(output []float64)

func NuttallWindowF32

func NuttallWindowF32(output []float32)

func Optimal2x4p4o

func Optimal2x4p4o(samples []float64, x float64) float64

Optimal2x4p4o interpolates using optimal 2x (4-point, 4th-order) (z-form)

func Optimal2x4p4oF32

func Optimal2x4p4oF32(samples []float32, x float32) float32

Optimal2x4p4oF32 interpolates using optimal 2x (4-point, 4th-order) (z-form)

func Optimal2x6p5o

func Optimal2x6p5o(samples []float64, x float64) float64

Optimal2x6p5o interpolates using optimal 2x (6-point, 5th-order) (z-form)

func Optimal2x6p5oF32

func Optimal2x6p5oF32(samples []float32, x float32) float32

Optimal2x6p5oF32 interpolates using optimal 2x (6-point, 5th-order) (z-form)

func Phase32

func Phase32(x complex64) float32

func PolarDiscriminator

func PolarDiscriminator(a, b complex128) float64

PolarDiscriminator returns the phase angle between two complex vectors equivalent to arg(a * conj(b)). The returned angle is in the range [-Pi, Pi].

func PolarDiscriminator32

func PolarDiscriminator32(a, b complex64) float32

PolarDiscriminator32 returns the phase angle between two complex vectors equivalent to arg(a * conj(b)). The returned angle is in the range [-Pi, Pi].

func TriangleWindow

func TriangleWindow(output []float64)

func TriangleWindowF32

func TriangleWindowF32(output []float32)

func Ui8toc64

func Ui8toc64(input []byte, output []complex64)

Ui8toc64 converts unsigned 8-bit interleaved complex samples to 32-bit float. It does not scale the samples.

func Ui8tof32

func Ui8tof32(input []byte, output []float32)

Ui8tof32 converts unsigned 8-bit samples to 32-bit float. It does not scale the samples.

func Ui8toi16

func Ui8toi16(input []byte, output []int16)

Ui8toi16 converts and scales unsigned 8-bit samples to 16-bit signed samples.

func Ui8toi16b

func Ui8toi16b(input, output []byte)

Ui8toi16b converts and scales unsigned 8-bit samples to 16-bit signed samples.

func VAbsC64

func VAbsC64(input []complex64, output []float32)

func VAddC64

func VAddC64(input, output []complex64)

func VAddF32

func VAddF32(input, output []float32)

func VMaxF32

func VMaxF32(input []float32) float32

func VMulC64

func VMulC64(input, output, mul []complex64)

VMulC64 multiplies eache value of the input by the matching value in the multiplier.

output[i] = input[i] * mul[i]

func VMulC64xF32

func VMulC64xF32(input, output []complex64, mul []float32)

VMulC64xF32 multiplies a vector of complex values with a vector with real values. This is useful for applying a window to complex samples.

output[i] = complex(real(input[i])*mul[i], imag(input[i])*mul[i])

func VScaleC64

func VScaleC64(input, output []complex64, scale float32)

func VScaleF32

func VScaleF32(input, output []float32, scale float32)

Types

type BiQuadFilter

type BiQuadFilter struct {
	B0, B1, B2 float64
	A0, A1, A2 float64
	// contains filtered or unexported fields
}

func AllPassBiQuadFilter

func AllPassBiQuadFilter(sampleRate, centreFrequency, q float64) *BiQuadFilter

H(s) = (s^2 - s/Q + 1) / (s^2 + s/Q + 1)

func HighShelfBiQuadFilter

func HighShelfBiQuadFilter(sampleRate, cutoffFrequency, shelfSlope, dbGain float64) *BiQuadFilter

H(s) = A * (A*s^2 + (sqrt(A)/Q)*s + 1)/(s^2 + (sqrt(A)/Q)*s + A)

func LowShelfBiQuadFilter

func LowShelfBiQuadFilter(sampleRate, cutoffFrequency, shelfSlope, dbGain float64) *BiQuadFilter

H(s) = A * (s^2 + (sqrt(A)/Q)*s + A)/(A*s^2 + (sqrt(A)/Q)*s + 1) shelfSlope: a "shelf slope" parameter (for shelving EQ only). When S = 1, the shelf slope is as steep as it can be and remain monotonically increasing or decreasing gain with frequency. The shelf slope, in dB/octave, remains proportional to S for all other values for a fixed f0/Fs and dBgain.</param> dbGain: Gain in decibels

func NewBandPassConstantPeakGainBiQuadFilter

func NewBandPassConstantPeakGainBiQuadFilter(sampleRate, centreFrequency, q float64) *BiQuadFilter

H(s) = (s/Q) / (s^2 + s/Q + 1) (constant 0 dB peak gain)

func NewBandPassConstantSkirtGainBiQuadFilter

func NewBandPassConstantSkirtGainBiQuadFilter(sampleRate, centreFrequency, q float64) *BiQuadFilter

H(s) = s / (s^2 + s/Q + 1) (constant skirt gain, peak gain = Q)

func NewHighPassBiQuadFilter

func NewHighPassBiQuadFilter(sampleRate, cutoffFreq, q float64) *BiQuadFilter

H(s) = s^2 / (s^2 + s/Q + 1)

func NewLowPassBiQuadFilter

func NewLowPassBiQuadFilter(sampleRate, cutoffFreq, q float64) *BiQuadFilter

H(s) = 1 / (s^2 + s/Q + 1)

func NotchBiQuadFilter

func NotchBiQuadFilter(sampleRate, centreFrequency, q float64) *BiQuadFilter

H(s) = (s^2 + 1) / (s^2 + s/Q + 1)

func PeakingEQBiQuadFilter

func PeakingEQBiQuadFilter(sampleRate, centreFrequency, q, dbGain float64) *BiQuadFilter

H(s) = (s^2 + s*(A/Q) + 1) / (s^2 + s/(A*Q) + 1)

func (*BiQuadFilter) Filter

func (f *BiQuadFilter) Filter(input, output []float64)

func (*BiQuadFilter) FilterF32

func (f *BiQuadFilter) FilterF32(input, output []float32)

type ComplexFilter

type ComplexFilter interface {
	Filter([]complex64) ([]complex64, error)
}

type ComplexGoertzel

type ComplexGoertzel struct {
	// contains filtered or unexported fields
}

func NewComplexGoertzel

func NewComplexGoertzel(targetFreqs []uint64, sampleRate, blockSize int) *ComplexGoertzel

func (*ComplexGoertzel) Complex

func (g *ComplexGoertzel) Complex() []complex128

func (*ComplexGoertzel) Feed

func (g *ComplexGoertzel) Feed(samples []complex128)

func (*ComplexGoertzel) Magnitude

func (g *ComplexGoertzel) Magnitude() []float64

func (*ComplexGoertzel) Reset

func (g *ComplexGoertzel) Reset()

type ComplexIIRFilter

type ComplexIIRFilter struct {
	// contains filtered or unexported fields
}

func NewComplexIIRFilter

func NewComplexIIRFilter(bCoef, aCoef []float64) *ComplexIIRFilter

func (*ComplexIIRFilter) Filter

func (f *ComplexIIRFilter) Filter(input, output []complex128)

type ComplexIIRFilter32

type ComplexIIRFilter32 struct {
	// contains filtered or unexported fields
}

func NewComplexIIRFilter32

func NewComplexIIRFilter32(bCoef, aCoef []float32) *ComplexIIRFilter32

func (*ComplexIIRFilter32) Filter

func (f *ComplexIIRFilter32) Filter(input, output []complex64)

type ComplexSource

type ComplexSource interface {
	Source() ([]complex64, error)
}

type Demodulator

type Demodulator interface {
	Demodulate(input []complex64, output []float32) (int, error)
}

type FMDemodFilter

type FMDemodFilter struct {
	// contains filtered or unexported fields
}

FMDemodFilter is an FM demodulator filter using a polar disciminator.

x(n)─────▶○───────────────────▶(X)──────────────────▶arctan──▶
          │                     ▲  y(n)=x(n)x*(n-1)
          │   ┌───┐     ┌───┐   │
          └──▶│z⁻¹├────▶│z^*├───┘
              └───┘     └───┘

func (*FMDemodFilter) Demodulate

func (fi *FMDemodFilter) Demodulate(input []complex64, output []float32) int

type Goertzel

type Goertzel struct {
	// contains filtered or unexported fields
}

func NewGoertzel

func NewGoertzel(targetFreqs []uint64, sampleRate, blockSize int) *Goertzel

func (*Goertzel) Complex

func (g *Goertzel) Complex() []complex128

func (*Goertzel) Feed

func (g *Goertzel) Feed(samples []float64)

func (*Goertzel) Magnitude

func (g *Goertzel) Magnitude() []float64

func (*Goertzel) Reset

func (g *Goertzel) Reset()

type Goertzel32

type Goertzel32 struct {
	// contains filtered or unexported fields
}

func NewGoertzel32

func NewGoertzel32(targetFreqs []uint64, sampleRate, blockSize int) *Goertzel32

func (*Goertzel32) Complex

func (g *Goertzel32) Complex() []complex64

func (*Goertzel32) Feed

func (g *Goertzel32) Feed(samples []float32)

func (*Goertzel32) Magnitude

func (g *Goertzel32) Magnitude() []float32

func (*Goertzel32) Reset

func (g *Goertzel32) Reset()

type I32Rotate90Filter

type I32Rotate90Filter struct {
}

func (*I32Rotate90Filter) Filter

func (fi *I32Rotate90Filter) Filter(samples []int32) []int32

type IIRFilter

type IIRFilter struct {
	// contains filtered or unexported fields
}

func NewIIRFilter

func NewIIRFilter(bCoef, aCoef []float64) *IIRFilter

func (*IIRFilter) Filter

func (f *IIRFilter) Filter(input, output []float64)

type LowPassDownsampleComplexFilter

type LowPassDownsampleComplexFilter struct {
	Downsample int
	// contains filtered or unexported fields
}

func (*LowPassDownsampleComplexFilter) Filter

func (fi *LowPassDownsampleComplexFilter) Filter(samples []complex64) []complex64

type LowPassDownsampleRationalFilter

type LowPassDownsampleRationalFilter struct {
	Fast, Slow int
	// contains filtered or unexported fields
}

func (*LowPassDownsampleRationalFilter) Filter

func (fi *LowPassDownsampleRationalFilter) Filter(samples []float32) []float32

type RealSink

type RealSink interface {
	Sink([]float32) error
}

type Rotate90Filter

type Rotate90Filter struct {
}

func (*Rotate90Filter) Filter

func (fi *Rotate90Filter) Filter(samples []complex64) []complex64

type SDFT

type SDFT struct {
	// contains filtered or unexported fields
}

SDFT is a sliding DFT.

func NewSDFT

func NewSDFT(k, n int, window []float64) *SDFT

func (*SDFT) Filter

func (sd *SDFT) Filter(x complex128) complex128

type SDFT32

type SDFT32 struct {
	// contains filtered or unexported fields
}

SDFT32 is a 32-bit float version of a sliding DFT.

func NewSDFT32

func NewSDFT32(k, n int, window []float32) *SDFT32

func (*SDFT32) Filter

func (sd *SDFT32) Filter(x complex64) complex64

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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