spat

package module
v0.0.0-...-e8f6d10 Latest Latest
Warning

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

Go to latest
Published: May 10, 2021 License: MIT Imports: 16 Imported by: 0

README

spat

spat is a sound utility library written in Go

Documentation

Index

Constants

View Source
const (
	BitLenShort   = 16
	BitLenFloat   = 32
	BitLenDouble  = 64
	ByteLenShort  = 2
	ByteLenFloat  = 4
	ByteLenDouble = 8
)
View Source
const (
	FFTPrimeThreshold = 256
	Forward           = -1
	Backward          = 1
)
View Source
const FftHardCordedSize = 4

Variables

View Source
var (
	ErrUnknownDataType = errors.New("unknown data type")
)

Functions

func AbsFloat32

func AbsFloat32(x float32) float32

func AbsFloat32s

func AbsFloat32s(data []float32) []float32

func AbsFloat64

func AbsFloat64(x float64) float64

func AbsFloat64s

func AbsFloat64s(data []float64) []float64

func AbsInt16

func AbsInt16(x int16) int16

func AbsInt16s

func AbsInt16s(data []int16) []int16

func AbsMinMaxFloat32s

func AbsMinMaxFloat32s(data []float32) (absData []float32, min, max float32)

func AbsMinMaxFloat64s

func AbsMinMaxFloat64s(data []float64) (absData []float64, min, max float64)

func AbsMinMaxInt16s

func AbsMinMaxInt16s(data []int16) (absData []int16, min, max int16)

func BaseFFT

func BaseFFT(array []T, size, sign int)

func BytesToFloat32

func BytesToFloat32(b []byte) (float32, error)

func BytesToFloat64

func BytesToFloat64(b []byte) (float64, error)

func BytesToInt16

func BytesToInt16(b []byte) (int16, error)

func Complex128sToFloat64s

func Complex128sToFloat64s(data []complex128) []float64

func DFT

func DFT(array []complex128, size int)

func FFT

func FFT(array []T, size int)

func FFT2

func FFT2(array, temp, omega []complex128)

func FFTCos

func FFTCos(n, m int) float64

func FFTHardCorded

func FFTHardCorded(array []T, size, n, sign int)

func FFTPrime

func FFTPrime(array []T, size, n, sign int)

func FFTSin

func FFTSin(n, m int) float64

func Float32ToBytes

func Float32ToBytes(v float32) ([]byte, error)

func Float32sToFloat64s

func Float32sToFloat64s(data []float32) []float64

func Float32sToInt16s

func Float32sToInt16s(data []float32) []int16

func Float64ToBytes

func Float64ToBytes(v float64) ([]byte, error)

func Float64sToFloat32s

func Float64sToFloat32s(data []float64) []float32

func Float64sToInt16s

func Float64sToInt16s(data []float64) []int16

func GenerateFadeinFadeoutFilter

func GenerateFadeinFadeoutFilter(length int) (fadeinFilter, fadeoutFilter []float64)

func IDFT

func IDFT(array []complex128, size int)

func IFFT

func IFFT(array []T, size int)

func Int16ToBytes

func Int16ToBytes(v int16) ([]byte, error)

func Int16sToFloat32s

func Int16sToFloat32s(data []int16) []float32

func Int16sToFloat64s

func Int16sToFloat64s(data []int16) []float64

func LenDXXFile

func LenDXXFile(filename string) (int, error)

LenDXXFile reads sample size of .DXX file. This func determines the data type from the filename extension and reads that data.

func LinearConvolutionFreqDomain

func LinearConvolutionFreqDomain(x, y []complex128) []complex128

LinearConvolutionFreqDomain return linear convolution. len: len(x) + len(y) - 1

func LinearConvolutionTimeDomain

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

func MaxFloat32s

func MaxFloat32s(data []float32) float32

func MaxFloat64s

func MaxFloat64s(data []float64) float64

func MaxInt16s

func MaxInt16s(data []int16) int16

func MinFloat32s

func MinFloat32s(data []float32) float32

func MinFloat64s

func MinFloat64s(data []float64) float64

func MinInt16s

func MinInt16s(data []int16) int16

func PinkNoise

func PinkNoise(samples, fs int) []float64

PinkNoise generates pinknoise using Voss algorithm. http://www.firstpr.com.au/dsp/pink-noise/

func Read

func Read(r io.Reader, dt DataType, length int) ([]float64, error)

Read reads data from reader as specified data type. The return type is []float64 to make the data easier to handle.

func ReadDXXFile

func ReadDXXFile(filename string) ([]float64, error)

ReadDXXFile reads .DXX file. This func determines the data type from the filename extension and reads that data. The return type is []float64 to make the data easier to handle.

func SizedDFT

func SizedDFT(array, temp, omega []complex128, size, n int)

func SizedFFT2

func SizedFFT2(array []T, temp, omega []complex128, size int)

func Sum

func Sum(vs []float64) float64

func Write

func Write(w io.Writer, dt DataType, data []float64) error

Writes writes data to writer as specified data type. The return type is []float64 to make the data easier to handle.

func WriteDXXFile

func WriteDXXFile(filename string, data []float64) error

WriteDXXFile writes data to .DXX file. This func determines the data type from the filename extension and writes the data to the file. The return type is []float64 to make the data easier to handle.

Types

type DataType

type DataType int

DataType is type of DataType behaves as enum.

const (
	DSA DataType = iota + 1
	DFA
	DDA
	DSB
	DFB
	DDB
)

func StringToDataType

func StringToDataType(s string) (DataType, error)

StringToDataType determines data type from specified string. If the specified string is invalid, this func returns error.

func (DataType) BitLen

func (dt DataType) BitLen() int

BitLen returns the bit length of data type.

func (DataType) ByteLen

func (dt DataType) ByteLen() int

ByteLen returns the byte length of data type.

func (DataType) String

func (dt DataType) String() string

String returns data type name as string.

type T

type T = complex128

Jump to

Keyboard shortcuts

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