Skip to content
heliaEDGE
Reference
HELIA

spectral

Classes

Name Description
StftMagnitude Magnitude of a short-time Fourier transform with a fixed, stored basis

Functions

Name Description
max_projection Magnitude of complex values without a square root, within 0.25%

Machine-readable model

  • DIRECTIONSconstant
  • max_projectionfunctionMagnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.
  • StftMagnitudeclassMagnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.
function

Magnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.

helia_edge/layers/spectral.py:19

max_projection(pairs)

Magnitude of complex values as the largest of 9 projections of (|re|, |im|), within 0.25% in float32.

The directions are spread from 0 to 90 degrees and scaled so the error is centred: the result is within -0.25% and +0.25% of sqrt(re**2 + im**2). It needs no square root, so integer kernels run it.

Parameters of max_projection
NameDefaultDescription
pairsRequiredReal and imaginary parts on the last axis, ``(..., 2)``, rank 4.
Returns of max_projection
Description
The magnitudes, ``(...)``.
class

Magnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.

helia_edge/layers/spectral.py:39

StftMagnitude(
frame_length: int,
frame_step: int,
bins: int,
padding: tuple[int, int] = (0, 0),
magnitude: str = 'sqrt',
**kwargs={},
)

Magnitude of a short-time Fourier transform computed as a strided convolution with a stored basis.

The input (batch, samples) is reflect-padded by padding (start, end) samples and convolved with basis (frame_length taps, frame_step stride, 2 * bins filters: the real parts of every bin, then the imaginary parts). The output is the magnitude of shape (batch, frames, bins): sqrt(re**2 + im**2), or max_projection of (re, im). The basis is a non-trainable weight, so a model’s window and transform travel with its weights.

Parameters of StftMagnitude
NameTypeDefaultDescription
frame_lengthintRequiredSamples per frame.
frame_stepintRequiredSamples between frames.
binsintRequiredFrequency bins.
paddingtuple[int, int](0, 0)Samples of reflect padding before the first and after the last sample.
magnitudestr'sqrt'``sqrt`` (exact) or ``max_projection`` (no square root, within 0.25%).