godsp

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

README

Package godsp

Package godsp is a Go package developed to support some basic signal processing functions using the discrete wavelet transform (DWT).

Packages

  • go-dsp: General functions on vectors or sets of vectors.

  • go-dsp/dbscan: Implementation of DBSCAN (https://en.wikipedia.org/wiki/DBSCAN) to cluster histogram bins.

  • go-dsp/dwt: Lifting implementation of the discrete wavelet transform using the Daubechies 4 wavelet. See:

    Ripples in Mathematics. The Discrete Wavelet Transform.
    A. Jensen and A. la Cour-Harbo
    Springer 2001
    Section 3.4

Installation

$ go get github.com/mjibson/go-dsp/fft

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(x []float64) []float64

Abs returns |x|

func AbsAll

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

AbsAll returns Abs(x) for every x in X

func AbsInt

func AbsInt(x []int) []int

AbsInt returns |x|

func Average

func Average(x []float64) float64

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

func DivS added in v0.0.2

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

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

func DownSample

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

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

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

func FindMax

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 added in v0.0.2

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

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

func Float32ToFloat64(x []float32) []float64

Float32ToFloat64 returns a copy of x with type []float64

func IsPowerOf2

func IsPowerOf2(x int) bool

func LoadFloats

func LoadFloats(fname string) []float64

LoadFloats reads a text file containing one float per line.

func Log2

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

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

LowpassFilter returns x filtered by alpha

func LowpassFilterAll

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

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

func Max

func Max(x []float64) float64

Max returns the maximum value of the elements of x

func MaxInt

func MaxInt(x []int) int

MaxInt returns the maximum value of the elements of x

func MovAvg added in v0.0.2

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

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

Multiplex returns on vector with the element of vs interleaved

func Normalise

func Normalise(x []float64) []float64

Normalise returns x/max(x)

func NormaliseAll

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

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

func Pow2

func Pow2(x int) int

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

func Range

func Range(n int) []int

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

func ReadWavFile

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

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

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

func Smooth(x []float64, wdw int)

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

func Sub added in v0.0.2

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

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

func Sum

func Sum(x []float64) float64

Sum returns the sum of the elements of the vector x

func SumVectors

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

func ToFloat(x []int) []float64

func ToInt added in v0.0.3

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 added in v0.0.3

func ToIntS(x float64, bitsPerSample int) int

func WriteAllDataFile

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

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

func WriteDataFile

func WriteDataFile(x []float64, fname string)

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

func WriteIntDataFile

func WriteIntDataFile(x []int, fname string)

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

func WriteIntMatrixDataFile added in v0.0.6

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

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

func Xcorr

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

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

Types

This section is empty.

Directories

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

Jump to

Keyboard shortcuts

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