import { LinearFilter } from 'scientific/signal' ; const numSamples = 4096 ; const sampleFreq = 44100 ; const X = new Float32Array ( numSamples ) ; for ( let i = 0 ; i < X . length ; i ++ ) { const t = i / sampleFreq ; let S = 0.7 * Math . sin ( 2 * Math . PI * 50 * t ) ; S += Math . sin ( 2 * Math . PI * 120 * t ) ; X [ i ] = S + 2 * Math . random ( ) ; } const filter50hz = new LinearFilter ( new Float32Array ( [ 2.88394643e-9 , 0.0 , - 8.65183928e-9 , 0.0 , 8.65183928e-9 , 0.0 , - 2.88394643e-9 , ] ) , new Float32Array ( [ 1 , - 5.99415495 , 14.97093756 , - 19.94220015 , 14.94252458 , - 5.97142422 , 0.99431717 , ] ) ) ; const y = filter50hz . update ( X ) ;