Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- """
- Blackman dual-passband filter generator
- by Damian Yerrick
- Bisqwit wanted help making the FIR filter for NTSC luma/chroma
- separation. I'm using a crossover at 5/6 and 7/6 Fsc (3.0 and
- 4.2 MHz).
- """
- from __future__ import division
- import math
- def sinc(x):
- pix = math.pi*x
- return math.sin(pix)/pix if pix else 1
- # Sum of a lowpass and a bandpass
- ls = [(sinc(x * 5/36) - sinc(x * 7/36) + sinc(x * 10/36))
- * 1
- for x in range(-35, 36)]
- # Apply Blackman window
- N = len(ls)
- alpha = 0.16
- black = [(1 - alpha - math.cos(2*math.pi*x/(N+1))
- + alpha*math.cos(4*math.pi*x/(N+1)))/2
- for x in range(1, N+1)]
- ls = [a * b for (a, b) in zip(black, ls)]
- print "Filter: [%s]" % ",".join("%7.4f" % el for el in ls)
- print "DC convolve: %.4f" % sum(ls)
- sineconv = [sum(math.cos(math.pi*(x + i)/6) * y
- for (x, y) in zip(range(len(ls)), ls))
- for i in range(12)]
- print "Sine convolve (wanna get these values compared to DC convolve):"
- print "[%s]" % ",".join("%7.4f" % el for el in sineconv)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement