File: generate_filter.m

package info (click to toggle)
libsamplerate 0.2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,444 kB
  • sloc: ansic: 371,377; sh: 121; makefile: 111
file content (35 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function f = generate_filter (cycles, fudge_factor, increment, atten)

if nargin != 4,
	error ("Need four args.") ;
	endif

# Calclate N and make sure it is even.
N = fix (4 * cycles * fudge_factor * increment) ;

if rem (N, 2) != 0,
	N = N - 1 ;
	endif

# Generate the Sinc function.

m = -((N-1)/2):((N-1)/2) ;
f = sinc (m / fudge_factor / increment) ;

# Genertate the window function and apply it.

w = kaiser (N, (atten + 0.5) / 10) ;
w = w' ;

f = f .* w ;

f = f / sum (f) ;

endfunction

# Do not edit or modify anything in this comment block.
# The arch-tag line is a file identity tag for the GNU Arch 
# revision control system.
#
# arch-tag: 7e57a3cb-3f5c-4346-bfcd-4da1e758e2a7