RainbowZephyr / dsp

Signal processing library, written in pure Crystal (high level and fast)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DSP

Signal processing library written in Crystal (high-level and fast).

Installation

Add this to your application's shard.yml:

dependencies:
  dsp:
    github: RainbowZephyr/dsp

Features

  • FFT Planner, multiple optimized FFT implementations (forward and inverse)
  • Windows (Blackman, Hamming, etc.)
  • Windowed sinc filtering (lowpass, highpass, bandpass, bandstop)
  • Signal Detrending

Usage

require "dsp"

FFT

require "dsp"
waveform  = Array(Float64).new(16384) { |e| Random.rand }
transformed : Array(Complex) = DSP::Transforms::FFTPlanner.fft(waveform)
inverse : Array(Complex) = DSP::Transforms::FFTPlanner.ifft(transformed)

Detrend

require "dsp"

# Linear
waveform = [1,2,3,4]
hash = Analysis::Detrend.apply(waveform) # {:detrended => ...., :trend_line => ...}

waveform = [1,2,3,4]
hash = Analysis::Detrend.apply(waveform, DSP::Analysis::Mode::POLYNOMIAL, 15) # {:detrended => ...., :trend_line => ...}

Integrals and Differentials

require "dsp"

# Integration
waveform = [1,2,3,4]
sample_rate = 5
linear_factor = 1
result : Array(Float64) = DSP::Signal::Integrate(waveform, sample_rate, linear_factor)

waveform = [1,2,3,4]
sample_rate = 5
linear_factor = 1
result : Array(Float64) = DSP::Signal::Differentiate(waveform, sample_rate, linear_factor)

TODO: Write more usage instructions here

Contributing

  1. Fork it ( https://github.com/[your-github-name]/dsp/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

About

Signal processing library, written in pure Crystal (high level and fast)

License:MIT License


Languages

Language:Crystal 99.3%Language:Ruby 0.7%