godsp: github.com/goccmack/godsp Index | Files | Directories

package godsp

import "github.com/goccmack/godsp"

Package dsp has a set of digital signal processing functions that are primarily designed to support the discrete wavelet transform ("https://github.com/goccmack/dsp/dwt")

Index

Package Files

dsp.go wavread.go

func Abs Uses

func Abs(x []float64) []float64

Abs returns |x|

func AbsAll Uses

func AbsAll(X [][]float64) [][]float64

AbsAll returns Abs(x) for every x in X

func AbsInt Uses

func AbsInt(x []int) []int

AbsInt returns |x|

func Average Uses

func Average(x []float64) float64

Average returns Sum(x)/len(x).

func DivS Uses

func DivS(x []float64, s float64) []float64

DivS returns x/s where x is a vector and s a scalar.

func DownSample Uses

func DownSample(x []float64, n int) []float64

DownSample returns x downsampled by n Function panics if len(x) is not an integer multiple of n.

func DownSampleAll Uses

func DownSampleAll(xs [][]float64) [][]float64

DownSampleAll returns DownSample(x, len(x)/min(len(xs))) for all x in xs

func FindMax Uses

func FindMax(x []float64) (value float64, index int)

FindMax returns the value and index of the first element of x equal to the maximum value in x.

func FindMaxI Uses

func FindMaxI(x []int) (value int, index int)

FindMax* returns the value and index of the first element of x equal to the maximum value in x.

func FindMin Uses

func FindMin(x []float64) (value float64, index int)

FindMin returns the value and index of the first element of x equal to the minimum value in x.

func Float32ToFloat64 Uses

func Float32ToFloat64(x []float32) []float64

Float32ToFloat64 returns a copy of x with type []float64

func IsPowerOf2 Uses

func IsPowerOf2(x int) bool

func LoadFloats Uses

func LoadFloats(fname string) []float64

LoadFloats reads a text file containing one float per line.

func Log2 Uses

func Log2(n int) int

Log2 returns the integer log base 2 of n. E.g.: log2(12) ~ 3.6. Log2 returns 3

func LowpassFilter Uses

func LowpassFilter(x []float64, alpha float64) []float64

LowpassFilter returns x filtered by alpha

func LowpassFilterAll Uses

func LowpassFilterAll(xs [][]float64, alpha float64) [][]float64

LowpassFilterAll returns LowpassFilter(x) for all x in xs.

func Max Uses

func Max(x []float64) float64

Max returns the maximum value of the elements of x

func MaxInt Uses

func MaxInt(x []int) int

MaxInt returns the maximum value of the elements of x

func MovAvg Uses

func MovAvg(x []float64, w int) []float64

MovAvg returns the moving average for each x[i], given by sum(x[i-w:i+w])/(2w)

func Multiplex Uses

func Multiplex(channels [][]float64) []float64

Multiplex returns on vector with the element of vs interleaved

func Normalise Uses

func Normalise(x []float64) []float64

Normalise returns x/max(x)

func NormaliseAll Uses

func NormaliseAll(xs [][]float64) [][]float64

Normalise returns x/max(x) for all x in xs

func Pow2 Uses

func Pow2(x int) int

Pow2 returns 2^x. The function panics if x < 0

func Range Uses

func Range(n int) []int

Range returns an interger range 0:1:n-1

func ReadWavFile Uses

func ReadWavFile(wavName string) (channels [][]float64, sampleRate, bitsPerSample int)

ReadWavFile returns the demultiplexed channels of a wav file, and the sample rate in Hz.

func RemoveAvg Uses

func RemoveAvg(x []float64) []float64

RemoveAvgZ returns x[i] = x[i]-sum(x)/len(x) or 0 if x[i]-sum(x)/len(x) < 0

func RemoveAvgAllZ Uses

func RemoveAvgAllZ(xs [][]float64) [][]float64

RemoveAvgAllZ removes the average of all vectors x in xs. The minimum value of any x[i] is 0.

func Smooth Uses

func Smooth(x []float64, wdw int)

Smooth smoothts x: x[i] = sum(x[i-wdw:i+wdw])/(2*wdw)

func Sub Uses

func Sub(x, y []float64) []float64

Sub returns x - y. The function panics if len(x) != len(y).

func Sum Uses

func Sum(x []float64) float64

Sum returns the sum of the elements of the vector x

func SumVectors Uses

func SumVectors(X [][]float64) []float64

SumVectors returns the sum of the vectors in X. The function panics if all vectors don't have the same length

func ToFloat Uses

func ToFloat(x []int) []float64

func ToInt Uses

func ToInt(x []float64, bitsPerSample int) []int

ToInt returns y * math.MaxInt64. The range of x is [-1.0,1.0]. The function panics if bitsPerSample is not one of 8,16,32.

func ToIntS Uses

func ToIntS(x float64, bitsPerSample int) int

func WriteAllDataFile Uses

func WriteAllDataFile(xs [][]float64, fname string)

WriteAllDataFile writes each xs[i] in xs to a test file `fname_i.txt`

func WriteDataFile Uses

func WriteDataFile(x []float64, fname string)

WriteDataFile writes x to a text file `fname.txt`

func WriteIntDataFile Uses

func WriteIntDataFile(x []int, fname string)

WriteIntDataFile writes x to a text file `fname.txt`

func WriteIntMatrixDataFile Uses

func WriteIntMatrixDataFile(x [][]int, fname string)

WriteIntMatrixDataFile writes an integer matrix to a text file `fname.csv`

func Xcorr Uses

func Xcorr(x, y []float64, maxDelay int) (corr []float64)

Xcorr returns the cross correlation of x with y for maxDelay.

Directories

PathSynopsis
dbscanPackage dbscan implements the DBSCAN clustering algorithm (https://en.wikipedia.org/wiki/DBSCAN)
dwtPackage DWT has functions supporting the Discrete Wavelet Transform.
peaksPackage peaks finds the maxima in a vector.
ppeaksPackage ppeaks detects the peaks in a time series by means of persistent homology: https://www.sthu.org/blog/13-perstopology-peakdetection/index.html.

Package godsp imports 9 packages (graph) and is imported by 3 packages. Updated 2020-04-01. Refresh now. Tools for package owners.