Documentation ¶
Index ¶
- func ApplyWindow(arr []float64, wf WindowFunc)
- func DFT(arr []float64) []float64
- func Downsample(arr []float64, ratio int) []float64
- func FFT(in []float64) []float64
- func HammingWindow(M int) []float64
- func MatchScore(sample, match map[model.EncodedKey]model.TableValue) float64
- func Reshape(arr []float64, size int) [][]float64
- func SpecToImg(matrix [][]float64) image.Image
- type Filterer
- type LPFilter
- type Spectrogrammer
- type WindowFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyWindow ¶
func ApplyWindow(arr []float64, wf WindowFunc)
ApplyWindow applies the provided window on the given array
func DFT ¶
DFT is a discrete fourier transform implementation (it is slow O(N^2)) TODO parallelize ?
func Downsample ¶
Downsample downsamples the given array using the given ratio by averaging
func FFT ¶
FFT is a fast fourier transform using gonum/fourier TODO remove adding duplicate frequencies (it's ~33% slower with them)
func HammingWindow ¶
HammingWindow is a hamming window the formula used is w(n) = 0.54 - 0.46 * cos(2 * pi * n / (M - 1)) for M in [0, M-1]
func MatchScore ¶
func MatchScore(sample, match map[model.EncodedKey]model.TableValue) float64
MatchScore computes a match score between the two transformed audio samples (into a list of Key + TableValue)
Types ¶
type LPFilter ¶
type LPFilter struct {
// contains filtered or unexported fields
}
LPFilter is a first order low pass filter usig H(p) = 1 / (1 + pRC)
func NewLPFilter ¶
NewLPFilter creates a new low pass Filter
type Spectrogrammer ¶
type Spectrogrammer struct {
// contains filtered or unexported fields
}
Spectrogrammer is a struct that allows to create spectrograms
func NewSpectrogrammer ¶
func NewSpectrogrammer(dsRatio, maxFreq, binSize float64, windowing bool) *Spectrogrammer
NewSpectrogrammer creates a new spectrogrammer
func (*Spectrogrammer) ConstellationMap ¶
func (s *Spectrogrammer) ConstellationMap(spec [][]float64, sampleRate float64) []model.ConstellationPoint
ConstellationMap takes a spectrogram, its sample rate and returns the highest frequencies and their time in the audio file The returned slice is ordered by time and is ordered by frequency for a constant time: If two time-frequency points have the same time, the time-frequency point with the lowest frequency is before the other one. If a time time-frequency point has a lower time than another point one then it is before.
func (*Spectrogrammer) Spectrogram ¶
Spectrogram reads the provided audio file and returns a spectrogram for it Matrix is in the following format: TIME : FREQUENCY : Value time is t * binSize * dsp.DownsampleRatio / reader.SampleRate() frequency is f * freqBinSize
type WindowFunc ¶
WindowFunc represents a window function It takes the number of points we want in the output window