[linux] Re: programmeervraag: high-pass filter?

Theo v. Werkhoven twe-nllgg op ferrets4me.xs4all.nl
Di Jul 19 22:30:20 CEST 2005


* Tue, 19 Jul 2005, folkert op vanheusden.com:

> > > Geluid.
> > > Voor http://www.vanheusden.com/listener/ wil ik een filter-plugin maken
> > > zodat mensen bijvoorbeeld de ruis van de wind kunnen wegfilteren of het
> > > geluid van een ventilator, dat soort dingen.
> > Gegoogled?
> > "digital filter c"
> > http://www.poynton.com/Poynton-dsp.html
> > http://uazu.net/fiview/
> > http://www.netrino.com/Publications/Glossary/Filters.html
> 
> Helaas, op die urls geen code voor een low, high of bandpass filter.

Fiview maakt voorbeeld code voor je als je het programma runt.
b.v.:
./fiview 20000 -i LpBe5/1000
#+v

// Generated by Fiview 0.9.8 <http://uazu.net/fiview/>.  
// All generated example code below is in the public domain.
// Filter 1
// File: -i #1
// Guessed type: low-pass
//
// Frequency-response:
//   Peak gain: 1
//   Guessed 100% gain: 1
//   Regions between half-power points (70.71% response or -3.01dB):
//     0Hz -> 1000Hz  (width 1000Hz)
//   Regions between quarter-power points (50% response or -6.02dB):
//     0Hz -> 1359.74Hz  (width 1359.74Hz)
//
// Time-response:
//   Sampling rate is 20000Hz
//   50% complete after 8 samples (0.0004s)
//   90% complete after 12 samples (0.0006s)
//   95% complete after 13 samples (0.00065s)
//   99% complete after 18 samples (0.0009s)
//   99.9% complete after 25 samples (0.00125s)
//   99.99% complete after 33 samples (0.00165s)
//   Impulse response max deviation is at 7 samples (0.00035s)
//   Impulse response ranges between -0.00375906 and 0.137965
//
// Original filter:
//   x 0.000436441513669914
//   / 1 -1.33661077903006 0.560554836413156
//   x 1 2 1
//   / 1 -1.25383605661595 0.416066905140775
//   x 1 2 1
//   / 1 -0.615582588954285
//   x 1 1 (LpBe5/1000)
//
// Filter descriptions:
//   LpBe5/1000 == Lowpass Bessel filter, order 5, -3.01dB frequency 1000
//

// Example code (readable version)
double
process(register double val) {
   static double buf[5];
   register double tmp, fir, iir;
   tmp= buf[0]; memmove(buf, buf+1, 4*sizeof(double));
   // use 0.0004364415136699143 below for unity gain at 100% level
   val *= 0.0004364415136699144;
   iir= val+1.336610779030059*buf[0]-0.5605548364131561*tmp;
   fir= iir+buf[0]+buf[0]+tmp;
   tmp= buf[1]; buf[1]= iir; val= fir;
   iir= val+1.253836056615947*buf[2]-0.4160669051407752*tmp;
   fir= iir+buf[2]+buf[2]+tmp;
   tmp= buf[3]; buf[3]= iir; val= fir;
   iir= val+0.6155825889542853*tmp;
   fir= iir+tmp;
   buf[4]= iir; val= fir;
   return val;
}

// Example code (functionally the same as the above code, but 
//  optimised for cleaner compilation to efficient machine code)
double
process(register double val) {
   static double buf[5];
   register double tmp, fir, iir;
   tmp= buf[0]; memmove(buf, buf+1, 4*sizeof(double));
   // use 0.0004364415136699143 below for unity gain at 100% level
   iir= val * 0.0004364415136699144;
   iir -= 0.5605548364131561*tmp; fir= tmp;
   iir -= -1.336610779030059*buf[0]; fir += buf[0]+buf[0];
   fir += iir;
   tmp= buf[1]; buf[1]= iir; val= fir;
   iir= val;
   iir -= 0.4160669051407752*tmp; fir= tmp;
   iir -= -1.253836056615947*buf[2]; fir += buf[2]+buf[2];
   fir += iir;
   tmp= buf[3]; buf[3]= iir; val= fir;
   iir= val;
   iir -= -0.6155825889542853*tmp; fir= tmp;
   fir += iir;
   buf[4]= iir; val= fir;
   return val;
}

[..]
 #v-

> 
> 
> Folkert van Heusden
> 

-- 
Theo v. Werkhoven    Registered Linux user# 99872 http://counter.li.org
ICBM 52 13 26N , 4 29 47E.     +      ICQ: 277217131
SUSE 9.2                       +   Jabber: muadib op jabber.xs4all.nl
Kernel 2.6.8                   +   See headers for PGP/GPG info.
Claimer: any email I receive will become my property. Disclaimers do not apply.



More information about the Linux mailing list