How to implement low pass filter using java

前端 未结 7 1888
野趣味
野趣味 2020-11-29 23:53

I am trying to implement a low pass filter in Java. My requirement is very simple,I have to eliminate signals beyond a particular frequency (Single dimension). Looks like Bu

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-30 00:46

    I adopted this from http://www.dspguide.com/ I'm quite new to java, so it's not pretty, but it works

    /*
    * To change this license header, choose License Headers in Project Properties.
     * To change this template file, choose Tools | Templates
     * and open the template in the editor.
     */
    package SoundCruncher;
    
    import java.util.ArrayList;
    
    /**
     *
     * @author 2sloth
     * filter routine from "The scientist and engineer's guide to DSP" Chapter 20
     * filterOrder can be any even number between 2 & 20
    
    
    * cutoffFreq must be smaller than half the samplerate
     * filterType: 0=lowPass   1=highPass
     * ripplePercent is amount of ripple in Chebyshev filter (0-29) (0=butterworth)
     */
    public class Filtering {
        double[] filterSignal(ArrayList signal, double sampleRate ,double cutoffFreq, double filterOrder, int filterType, double ripplePercent) {
            double[][] recursionCoefficients =   new double[22][2];
            // Generate double array for ease of coding
            double[] unfilteredSignal =   new double[signal.size()];
            for (int i=0; i

提交回复
热议问题