Bases: object
Fixedpoint Hamming window manager. Caches Hamming windows.
Hamming window is one of a parametric family of windowing functions that are a raised cosine. The parameter for this family is the bottom of the function’s range:
range is (b, 1), where 0 < b < 1
and the window function reaches b at the edges, and 1 in the center (if the length is odd). Given b, set:
a = (b + 1) / 2, where 1/2 < a < 1
the Hamming window, with support (0, length - 1), is given by:
w[index] = a - (1 - a) * cos(2 * pi * index / (length - 1))
Most references to Hamming window use b = 0.08 (giving a = 0.54 and 1 - a = 0.46), but b = 0.07677... is also used. In order to reduce floating-point issues, we choose a value for b that is slightly less than 0.08, but which has only 16 significant bits.
Bases: onyx.signalprocessing.sigprocbase
Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.
Process each of the elements of ‘items’. Return a list of results.
Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.
Bases: onyx.signalprocessing.sigprocbase
Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.
Process each of the elements of ‘items’. Return a list of results.
Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.
Bases: onyx.signalprocessing.sigprocbase, onyx.dataflow.processor
Process each of the elements of ‘items’. Return a list of results.
Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.
Bases: onyx.signalprocessing.sigprocbase
Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.
Process each of the elements of ‘items’. Return a list of results.
Return a serialized version of this object as a tuple of strings. The form of the tuple is: (module_name, factory_name, version, arg0, arg1, ...) where the version and the args will be passed to the factory to construct the object.
Function returns a frozentuple with a fixed-point hamming window of ‘length’ with values scaled by 1 << ‘scale’.
Optional ‘norm’ selects the normalization to use prior to applying the scale. If not given, or None, no normalization is applied. Otherwise the values are scaled so that a computed value is one. The legal values of ‘norm’ are ‘sum’, ‘sumsq’, or ‘mode’ which cause the computed value to be the sum of the samples, the sum of the squares of the samples, or the mode of the samples in the window respectively.
The returned values are cached, so it is not expensive to use this function repeatedly with the same arguments.
>>> length_range = 7
>>> scale_shift = 10
>>> for norm in None, 'sum', 'sumsq', 'mode':
... print
... print "normalization:", repr(norm)
... for length in xrange(length_range):
... print length, iHamming(length, scale_shift, norm)
<BLANKLINE>
normalization: None
0 frozentuple(())
1 frozentuple((1024.0,))
2 frozentuple((81, 81))
3 frozentuple((81, 1024, 81))
4 frozentuple((81, 788, 788, 81))
5 frozentuple((81, 552, 1024, 552, 81))
6 frozentuple((81, 407, 934, 934, 407, 81))
<BLANKLINE>
normalization: 'sum'
0 frozentuple(())
1 frozentuple((1024.0,))
2 frozentuple((512, 512))
3 frozentuple((70, 882, 70))
4 frozentuple((48, 463, 463, 48))
5 frozentuple((36, 246, 457, 246, 36))
6 frozentuple((29, 146, 335, 335, 146, 29))
<BLANKLINE>
normalization: 'sumsq'
0 frozentuple(())
1 frozentuple((1024.0,))
2 frozentuple((724, 724))
3 frozentuple((81, 1017, 81))
4 frozentuple((74, 720, 720, 74))
5 frozentuple((64, 437, 810, 437, 64))
6 frozentuple((58, 288, 661, 661, 288, 58))
<BLANKLINE>
normalization: 'mode'
0 frozentuple(())
1 frozentuple((1024.0,))
2 frozentuple((1024, 1024))
3 frozentuple((81, 1024, 81))
4 frozentuple((106, 1024, 1024, 106))
5 frozentuple((81, 552, 1024, 552, 81))
6 frozentuple((89, 446, 1024, 1024, 446, 89))
Integer Hamming calculation. Returns the value for zero-based ‘index’ in a Hamming window of ‘length’ scaled by 1 << ‘shift’.
>>> xHamming(1, 3, 10)
81