Sliding DFT: Difference between revisions

From Hydrogenaudio Knowledgebase
(Added sources)
(Renamed the last link on the External links section: Sorry about that, but foo_cqt_analyzer only belongs to Fanon Wiki)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Stub}}
{{Stub}}
A '''sliding [[DFT]]''' is a recursive complex FIR filter bank that calculates short-time Fourier transform sample-by-sample. Unlike [[FFT]], the sDFT calculation for each bin is independent of each other, making it ideal for single-bin STFT and even [[constant-Q transform]] but this technique are limited by having only integer K otherwise, the sDFT goes out of phase but this is not in case on some sDFT implementations that allows non-integer K.<ref>The section "Sliding Spectrum Analysis for a Non-integer k Analysis Frequency" at "[Improvements to the Sliding DFT Algorithm]" by Richard Lyons and Carl Howard (July 2021)</ref>
[[Image:sDFT network.png|thumb|A block diagram of guaranteed-stable sDFT network with non-integer K compatibility.]]
A '''sliding [[DFT]]''' is a recursive complex FIR filter bank that calculates short-time Fourier transform sample-by-sample. Unlike [[FFT]], the sDFT calculation for each bin is independent of each other, making it ideal for single-bin STFT and even [[constant-Q transform]] but this technique are limited by having only integer K otherwise, the sDFT goes out of phase but this is not in case on some sDFT implementations that allows non-integer K.<ref>The section "Sliding Spectrum Analysis for a Non-integer k Analysis Frequency" at "[https://digital.library.adelaide.edu.au/dspace/bitstream/2440/133370/3/hdl_133370.pdf Improvements to the Sliding DFT Algorithm]" by Richard Lyons and Carl Howard (July 2021)</ref>


The sliding DFT can also have asymmetric windowing function by replacing ring buffers with an IIR exponential decay and it can be cascaded to further increase rolloff.<ref>A paper "[https://par.nsf.gov/servlets/purl/10078055 The Sliding Windowed Infinite Fourier Transform]" on "Tips & Tricks" part of ''IEEE Signal Processing Magazine''</ref><ref>[https://gist.github.com/TF3RDL/0f20d771ad92841d8a30d448f1140e6e Implementation of the sliding windowed infinite Fourier transform with functionality to cascade sDFTs serially] at GitHub Gist</ref>
The sliding DFT can also have asymmetric windowing function by replacing comb filtering stage with an exponential decay and it can be cascaded to further increase rolloff.<ref>A paper "[https://par.nsf.gov/servlets/purl/10078055 The Sliding Windowed Infinite Fourier Transform]" on "Tips & Tricks" part of ''IEEE Signal Processing Magazine''</ref><ref>[https://gist.github.com/TF3RDL/0f20d771ad92841d8a30d448f1140e6e Implementation of the sliding windowed infinite Fourier transform with functionality to cascade sDFTs serially] at GitHub Gist</ref>


== Implementation in foobar2000 ==
== Implementation in foobar2000 ==
The sliding DFT, unlike FFT requires contiguous stream of data, which means implementing that requires tricks involved with delta variable (time difference between current and previous calculations). However, the offset part of audio capture part of visualization (especially with <code>get_chunk_absolute(data, offset, size)</code>) is kinda complicated; the time of the resulting captured signal is <code>requested_length/2</code> samples ahead of actual playback (as long as the requested length is lower than buffer size in samples), which means the offset should be adjusted to something like <code>time - delta/2</code>.
The sliding DFT, unlike FFT requires contiguous stream of data, which means implementing that requires tricks involved with delta variable (time difference between current and previous calculations). However, the offset part of audio capture part of visualization (especially with <code>get_chunk_absolute(data, offset, size)</code>) is kinda complicated; the time of the resulting captured signal is <code>requested_length</code> samples ahead of actual playback (as long as the requested length is lower than buffer size in samples), which means the offset should be adjusted to something like <code>time - delta</code>. Alternatively, you can use previous time as a variable and do <code>get_chunk_absolute(data, previous_time, time - previous_time)</code> this instead and it will have same effect.


== References ==
== References ==
Line 12: Line 13:
== External links ==
== External links ==
* {{Wikipedia|Sliding DFT}}
* {{Wikipedia|Sliding DFT}}
* [https://scratch.mit.edu/projects/184263583/editor/ A video explaining how sliding DFT works and how to properly capture audio samples for sliding DFT calculation in a foobar2000 visualization component]
* [https://scratch.mit.edu/projects/858061428/ An interactive Scratch project on how sliding DFT algorithm with noninteger k support works].
[[Category:Technical]]
[[Category:Technical]]
[[Category:Signal Processing]]
[[Category:Signal Processing]]

Latest revision as of 01:33, 10 September 2023

A block diagram of guaranteed-stable sDFT network with non-integer K compatibility.

A sliding DFT is a recursive complex FIR filter bank that calculates short-time Fourier transform sample-by-sample. Unlike FFT, the sDFT calculation for each bin is independent of each other, making it ideal for single-bin STFT and even constant-Q transform but this technique are limited by having only integer K otherwise, the sDFT goes out of phase but this is not in case on some sDFT implementations that allows non-integer K.[1]

The sliding DFT can also have asymmetric windowing function by replacing comb filtering stage with an exponential decay and it can be cascaded to further increase rolloff.[2][3]

Implementation in foobar2000

The sliding DFT, unlike FFT requires contiguous stream of data, which means implementing that requires tricks involved with delta variable (time difference between current and previous calculations). However, the offset part of audio capture part of visualization (especially with get_chunk_absolute(data, offset, size)) is kinda complicated; the time of the resulting captured signal is requested_length samples ahead of actual playback (as long as the requested length is lower than buffer size in samples), which means the offset should be adjusted to something like time - delta. Alternatively, you can use previous time as a variable and do get_chunk_absolute(data, previous_time, time - previous_time) this instead and it will have same effect.

References

  1. The section "Sliding Spectrum Analysis for a Non-integer k Analysis Frequency" at "Improvements to the Sliding DFT Algorithm" by Richard Lyons and Carl Howard (July 2021)
  2. A paper "The Sliding Windowed Infinite Fourier Transform" on "Tips & Tricks" part of IEEE Signal Processing Magazine
  3. Implementation of the sliding windowed infinite Fourier transform with functionality to cascade sDFTs serially at GitHub Gist

External links