Digital Signal Processing for Go

GO-DSP

go-dsp is a digital signal processing package for the Go programming language.

Packages

  • dsputils - utilities and data structures for DSP
  • fft - fast Fourier transform
  • spectral - power spectral density functions (e.g., Pwelch)
  • wav - wav file reader functions
  • window - window functions (e.g., Hamming, Hann, Bartlett)

Installation and Usage

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

package main

import (
        "fmt"
        
        "github.com/mjibson/go-dsp/fft"
)

func main() {
        fmt.Println(fft.FFTReal([]float64 {1, 2, 3}))
}
Comments
  • float32 support (or: mismatch in APIs)

    float32 support (or: mismatch in APIs)

    The golang-users thread you announced this in suggests you used to have a float32 interface, but replaced it by float64, right? I'm asking because Im currently writing float32tofloat64 and float64tofloat32 array conversion routines and Im wondering why. The wav package produces float32s, but the other packages consume float64, which feels a little weird for two packages from the same repos.

    I'm trying to tie it into some opus unit tests and libopus also works with float32, as I assume many others do.

    Im curious to know: what made you drop float32?

  • FFTReal output doesn't seem right

    FFTReal output doesn't seem right

    I'm sure this is my fault, but I can't see what I'm doing wrong.

    Given the following simple program, when the input is a 440Hz sine wave, I expect to see a single peak in the frequency domain. Giving the same input to an online FFT calculator, the expected output is obtained.

    Can you point out my mistake, or is go-dsp doing something strange?


    The Program

    package main
    
    import (
        "bufio"
        "fmt"
        "github.com/mjibson/go-dsp/fft"
        "github.com/mjibson/go-dsp/window"
        "math"
        "os"
        "strconv"
    )
    
    func main() {
        file, err := os.Open(os.Args[1])
        if err != nil {
            panic(err)
        }
    
        scanner := bufio.NewScanner(file)
        values := make([]float64, 0)
        for scanner.Scan() {
            line := scanner.Text()
            value, e := strconv.ParseFloat(line, 64)
            if e != nil {
                panic(e)
            }
            values = append(values, value)
        }
    
        fftComplex := doFft(values)
        fftReal := realize(fftComplex)
    
        for _, freq := range fftReal {
            fmt.Println(freq)
        }
    }
    
    func doFft(data []float64) []complex128 {
        window.Apply(data, window.Hamming)
        return fft.FFTReal(data)
    }
    
    func realize(data []complex128) []float64 {
        realVals := make([]float64, len(data))
        for i, comp := range data {
            rel := math.Pow(real(comp), 2)
            img := math.Pow(imag(comp), 2)
            realVals[i] = math.Sqrt(rel + img)
        }
        return realVals
    }
    

    It's run like:

    go run fft.go awave.dat > awave-dsp.fft
    

    The Input

    Data is here, it's 440Hz sine. Plotted it looks like: screen shot 2014-03-09 at 3 53 19 pm

    gnuplot -e "plot 'awave.dat'; pause -1"
    

    The Output

    Data is here. Plotted it looks like: screen shot 2014-03-09 at 3 54 35 pm

    The x-scale here isn't Hz, it's just the bin numbers from FFTReal.

    gnuplot -e "plot 'awave-dsp.fft'; pause -1"
    

    Expected Output

    Using the same input, and the online FFT mentioned above, I get the expected output: screen shot 2014-03-09 at 3 54 54 pm

  • Breaking API Change: Swap indexes of Wav.Data*. Add API for reading WAV in chunks. Added unit tests for 'wav' package

    Breaking API Change: Swap indexes of Wav.Data*. Add API for reading WAV in chunks. Added unit tests for 'wav' package

    Changes in this commit:

    1. Changed Wav.Data8, Wav.Data16, and Wav.Data to be indexed by sample and then by channel.
    2. Added API to stream a wav from an io.Reader rather than loading all data into memory.
    3. Added unit tests for 'wav' package.

    Change #1 is a breaking change to the current API.

  • Index fix

    Index fix

    Use stdlib functions for converting little-endian bytes to single values Fix indexing of sample/channel in readSample. Use int for sample index to avoid overflow for wav files with greater than UINT16_MAX samples

  • examples

    examples

    Hoping its possible to have more examples of common usage of the library. For example, it would be interesting to have a sample program that reads a wav file and segments the file into meaningful features perhaps providing a recognition example?

  • (golang)  High pass filter method question

    (golang) High pass filter method question

    HI. I am new in golang.

    I want open file and do HPF and save the file after HPF.

    the file format is 1 28.00000 2 29.00000 3 28.00000 4 30.00000 5 28.00000 ..... .....

    it has two column (time well_height)

    the sample rate is 0.0166Hz (60 seconds interval well height recording) It has very very long term noise more than 200 sec So I want to High pass filter with cutoff frequency 0.005 Hz

    I looked over your golang code very carefully with 1 week but Still I failed with your code.

    Is there any sample form with open file and do HPF and save to file with HPF results ?

    please help me. I am graduate course student.

    Thanks for all.

    TaeRhee sample_part_small.txt

  • [Breaking API Change] Index wav data by sample then channel

    [Breaking API Change] Index wav data by sample then channel

    Swap indexes of data exposed by wav package. Data is now indexed by sample then channel, e.g. [sample0[ch0, ch1], sample1[ch0, ch1], ...]

    Two reasons for this:

    1. Sample is more natural to index on. Data capsulation makes more sense when data for a discrete instance is contained in a discrete structure.

    2. Client code is cleaner. Clients get an array of all data per sample rather than iterating through channels and pulling out the sample data.

  • Possible memory leak

    Possible memory leak

    Invoking fft.FFT() many times for large wav files (~10MB) couses program to panic because of out of memory. I have tested my program with and without that single line. Without computing fft it occupies ~300MB for very long time. When I enable fft computing it will be 3GB of RAM occupied pretty fast.

  • Fourier transform example?

    Fourier transform example?

    I would love an example of using the Fourier transform utilities on one of the sample wav files. In fact, there are several algorithms here that could use a usage demonstration.

Provides simple, semantic manipulation of the operating system's signal processing.
Provides simple, semantic manipulation of the operating system's signal processing.

Provides simple, semantic manipulation of the operating system's signal processing.

Dec 15, 2021
a TUI for signal messenger, written in Go
a TUI for signal messenger, written in Go

siggo A terminal ui for signal-cli, written in Go. Features vim-style ux useful for quick messages or use $EDITOR to compose fancy ones emoji support,

Jan 2, 2023
As the name says. Forges badge responses for the Defcon 29 badge and allows folks to jump straight to having completed the signal.

Defcon 29 Badge Code Generator Exactly as the title says. Will generate 7 signal keys to get you to signal then will generate 20 keys to distribute th

Aug 25, 2021
Msignal - Basic Utilities for OS Signal Management

msignal ?? - Basic Utilities for OS Signal Management Usage func main() { sysca

Mar 6, 2022
Generate signal for a thing for golang

go_kafka_signal generate signal for a thing go build producer.go ./producer -f ~

Dec 24, 2021
Os-signal-lab - Experiments with os signals and process trees

os-signal-lab Experiments with os signals and process trees There's a lot to rea

Feb 5, 2022
Crypto signal trading bot

Crypto-signal-trading-bot Firstly a warning This project has the ability to spen

Dec 15, 2022
Parallel Digital Universe - A decentralized identity-based social network

Parallel Digital Universe Golang implementation of PDU. What is PDU? Usage Development Contributing PDU PDU is a decentralized identity-based social n

Nov 20, 2022
Go Hosting Solution for AWS, Google Could and Digital Ocean
Go Hosting Solution for AWS, Google Could and Digital Ocean

Furnace Intro Brief Explanation Here is a very short description of what Furnace does in a handy IKEA manual format. In More Depth AWS Cloud Formation

Jan 3, 2023
A dead simple tool to sign files and verify digital signatures.

minisign minisign is a dead simple tool to sign files and verify signatures. $ minisign -G

Dec 16, 2022
Software for archiving my digital stuff like tweets

rsms's memex Software for managing my digital information, like tweets. Usage First check out the source and build. You'll need Make and Go installed.

Nov 17, 2022
🚀 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions and Digital Ocean
🚀 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions and Digital Ocean

Bookings Solução de cadastro de usuários e reservas. Tecnologias Utilizadas Golang MongoDB RabbitMQ Github Actions Docker Hub Docker Kubernetes Digita

Feb 18, 2022
Go decoder for EU Digital COVID Certificate (EUDCC) QR code data

Go Corona QR Code Decoder This repository contains a decoder for EU Digital COVID Certificate (EUDCC) QR code data, written in Go. If you got vaccinat

Nov 30, 2022
Apollo 💎 A Unix-style personal search engine and web crawler for your digital footprint.
Apollo 💎 A Unix-style personal search engine and web crawler for your digital footprint.

Apollo ?? A Unix-style personal search engine and web crawler for your digital footprint Demo apollodemo.mp4 Contents Background Thesis Design Archite

Dec 27, 2022
Digital planner for Supernote and ReMarkable
Digital planner for Supernote and ReMarkable

latex-yearly-planner PDF planner designed for e-ink devices. Download latest PDF with newest features and best bugs from the latest release. Visit the

Jan 9, 2023
Golang Kalkancrypt Wrapper - simple digital signature auth service
Golang Kalkancrypt Wrapper - simple digital signature auth service

Golang Kalkancrypt Wrapper WIP ⭐ Star on GitHub — it motivates me a lot! Overview Golang Kalkancrypt Wrapper - это простой веб-сервис для аутентификац

Dec 1, 2022
Control your legacy Reciva based internet radios (Crane, Grace Digital, Tangent, etc.) via REST api or web browser.

reciva-web-remote Control your legacy Reciva based internet radios (Crane, Grace Digital, Tangent, etc.) via REST api or web browser. Usage This progr

May 3, 2022
EU Digital Covid Certificate utilities in Go [Create, Validate and Parse Green-Pass/EU-DCC]

go-dcc EU Digital Covid Certificate utilities in Go [Create, Validate and Parse Green-Pass/EU-DCC] Repo work in-progress CLI Usage: ######Create and S

Dec 23, 2021
Madsportslab digital scoreboard

mboard-go mboard backend server requirements golang 1.8.x sqlite3 build git clone [email protected]:madsportslab/mboard-go go get github.com/eknkc/am

Nov 27, 2021
Core is the next-generation digital data engine.
Core is the next-generation digital data engine.

tKeel-Core The digital engine of world ?? Core is the data centre of the tKeel IoT Open Platform, a high-performance, scalable and lightweight next-ge

Mar 28, 2022