sfs.tapering

Weights (tapering) for the driving function.

import sfs
import matplotlib.pyplot as plt
import numpy as np
plt.rcParams['figure.figsize'] = 8, 3  # inch
plt.rcParams['axes.grid'] = True

active1 = np.zeros(101, dtype=bool)
active1[5:-5] = True

# The active part can wrap around from the end to the beginning:
active2 = np.ones(101, dtype=bool)
active2[30:-10] = False

Functions

kaiser(active, *, beta)

Kaiser tapering window.

none(active)

No tapering window.

tukey(active, *, alpha)

Tukey tapering window.

sfs.tapering.none(active)[source]

No tapering window.

Parameters

active (array_like, dtype=bool) – A boolean array containing True for active loudspeakers.

Returns

type(active) – The input, unchanged.

Examples

plt.plot(sfs.tapering.none(active1))
plt.axis([-3, 103, -0.1, 1.1])
_images/sfs-tapering-2.svg
plt.plot(sfs.tapering.none(active2))
plt.axis([-3, 103, -0.1, 1.1])
_images/sfs-tapering-3.svg
sfs.tapering.tukey(active, *, alpha)[source]

Tukey tapering window.

This uses a function similar to scipy.signal.tukey(), except that the first and last value are not zero.

Parameters
  • active (array_like, dtype=bool) – A boolean array containing True for active loudspeakers.

  • alpha (float) – Shape parameter of the Tukey window, see scipy.signal.tukey().

Returns

(len(active),) numpy.ndarray – Tapering weights.

Examples

plt.plot(sfs.tapering.tukey(active1, alpha=0), label='alpha = 0')
plt.plot(sfs.tapering.tukey(active1, alpha=0.25), label='alpha = 0.25')
plt.plot(sfs.tapering.tukey(active1, alpha=0.5), label='alpha = 0.5')
plt.plot(sfs.tapering.tukey(active1, alpha=0.75), label='alpha = 0.75')
plt.plot(sfs.tapering.tukey(active1, alpha=1), label='alpha = 1')
plt.axis([-3, 103, -0.1, 1.1])
plt.legend(loc='lower center')
_images/sfs-tapering-4.svg
plt.plot(sfs.tapering.tukey(active2, alpha=0.3))
plt.axis([-3, 103, -0.1, 1.1])
_images/sfs-tapering-5.svg
sfs.tapering.kaiser(active, *, beta)[source]

Kaiser tapering window.

This uses numpy.kaiser().

Parameters
  • active (array_like, dtype=bool) – A boolean array containing True for active loudspeakers.

  • alpha (float) – Shape parameter of the Kaiser window, see numpy.kaiser().

Returns

(len(active),) numpy.ndarray – Tapering weights.

Examples

plt.plot(sfs.tapering.kaiser(active1, beta=0), label='beta = 0')
plt.plot(sfs.tapering.kaiser(active1, beta=2), label='beta = 2')
plt.plot(sfs.tapering.kaiser(active1, beta=6), label='beta = 6')
plt.plot(sfs.tapering.kaiser(active1, beta=8.6), label='beta = 8.6')
plt.plot(sfs.tapering.kaiser(active1, beta=14), label='beta = 14')
plt.axis([-3, 103, -0.1, 1.1])
plt.legend(loc='lower center')
_images/sfs-tapering-6.svg
plt.plot(sfs.tapering.kaiser(active2, beta=7))
plt.axis([-3, 103, -0.1, 1.1])
_images/sfs-tapering-7.svg