TorchDSP / torchsig

TorchSig is an open-source signal processing machine learning toolkit based on the PyTorch data handling pipeline.
MIT License
155 stars 37 forks source link

roll_off() transform needs review of center_freq calculation #201

Closed MattCarrickPL closed 11 months ago

MattCarrickPL commented 1 year ago

The roll_off() transform needs another pass over the center_freq calculation:

center_freq = lowercutfreq - 0.5 + bandwidth / 2

https://github.com/TorchDSP/torchsig/blob/v0.4.2/torchsig/transforms/functional.py#L932

The formulation isn't immediately clear. Calculating some test values lowercutfreq = 0.125 and uppercutfreq=0.25, center_freq=-0.3125 which doesn't align with the input parameters. Also possible that I am not using the parameters within the proper units or normalization. Overall a better understanding of center_freq is needed which could result in a new calculation for it's value.

MattCarrickPL commented 12 months ago

Looking at a broader rework of roll-off. From https://github.com/TorchDSP/torchsig/blob/v0.4.2/tests/test_transforms_figures.py#L86 the roll-off has a nominal passband frequency of 0.05, and a stop band frequency of 0.98. The passband frequency has a 50% chance to be 0 or 0.05, and the stopband frequency has 50% chance to 0.98 or 1. Unclear the impact to the 50% chance to use a different passband or stopband frequency.

Plotting the resulting filter. The top image is the LPF that is designed, and the bottom image is after upconversion to the center frequency: image

Based on the paper, presumably the roll-off impairment is intended to generate these three effects: image

Considering a rework to include:

MattCarrickPL commented 12 months ago

Here's the section on roll_off() from the paper for context image

MattCarrickPL commented 12 months ago

Example filter designs for the new roll_off() transform:

image

The filter is a sinc with randomized length and cutoff. A Bartlett window taper is applied to the filter to remove any nulls in the frequency response.

MattCarrickPL commented 12 months ago

A slight, randomized center frequency offset is added to the filter as well. Here are some example filter responses: image

MattCarrickPL commented 12 months ago

Branch 201-roll_off-transform-needs-review-of-center_freq-calculation gitrev 84bc22e625e0bc5b6c6157e648fab3c1b14f9174 has the appropriate mods, but needs to be tested against the changes in wideband.py before merging into v0.4.2

MattCarrickPL commented 11 months ago

Code merged into v0.4.2 via https://github.com/TorchDSP/torchsig/pull/209