Onyx logo

Previous topic

onyx.signalprocessing.vocalsource – Use of coincident one-pole filters to generate reasonable, reversed,

Next topic

onyx.signalprocessing.channel – Channel – an unnecessary abstraction for bootstrapping the processor framework

This Page

onyx.signalprocessing.window – Windowing functionality.

class onyx.signalprocessing.window.FixedPointHammingMgr

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.

windows
class onyx.signalprocessing.window.Hamming(options=None)

Bases: onyx.signalprocessing.sigprocbase

Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.

check_serial_version(version)
configure(**kwargs)
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

send_many(inputs)
serialize()

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.

class onyx.signalprocessing.window.Padding(options=None)

Bases: onyx.signalprocessing.sigprocbase

Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.

check_serial_version(version)
configure(**kwargs)
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

send_many(inputs)
serialize()

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.

class onyx.signalprocessing.window.Sliding(*_)

Bases: onyx.signalprocessing.sigprocbase, onyx.dataflow.processor

check_serial_version(version)
config(samplerate)
configure(**kwargs)
get_recipient()
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

reset()
send_many(inputs)
send_signals(**kwargs)
static senderator(length, hop, signal, recipient=None)
serialize()

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.

set_recipient(recipient)
class onyx.signalprocessing.window.Truncate(options=None)

Bases: onyx.signalprocessing.sigprocbase

Updates self.init_options dictionary with option values, creating the dictionary if it doesn’t exist.

check_serial_version(version)
configure(**kwargs)
get_serial_factory_args()
get_serial_factory_name()
get_serial_module_name()
get_serial_version()
process_one(item)
process_some(items)

Process each of the elements of ‘items’. Return a list of results.

send_many(inputs)
serialize()

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.

onyx.signalprocessing.window.iHamming(length, shift_scale, norm=None)

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))
onyx.signalprocessing.window.xHamming(index, length, shift)

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