The Short-Time Fourier Transform (STFT) is a Fourier-related transform that computes the sinusoidal frequency and phase content of local, short-duration segments of a signal as it evolves, producing a time-frequency representation called a spectrogram. It works by applying a sliding window to the time-domain signal and computing the Discrete Fourier Transform (DFT)—typically via the Fast Fourier Transform (FFT)—on each windowed segment. This reveals how spectral components, such as specific tones in audio or vibration frequencies, appear and disappear over time, which is critical for analyzing non-stationary signals from sensors.
Glossary
Short-Time Fourier Transform (STFT)

What is Short-Time Fourier Transform (STFT)?
A core technique for analyzing how the frequency content of a signal, like audio or vibration, changes over time, essential for real-time sensor data processing on edge devices.
For TinyML deployment on microcontrollers, STFT implementation requires careful optimization of the window function (e.g., Hann, Hamming), window length, and hop size to balance time-frequency resolution with computational cost. The resulting spectrogram serves as a foundational feature extraction step for downstream machine learning tasks like Acoustic Event Detection (AED), voice activity detection, and anomaly detection in vibration monitoring. Efficient computation, often using fixed-point arithmetic and optimized FFT libraries, is paramount for real-time analysis under severe memory and power constraints.
Key STFT Parameters & Trade-offs
The Short-Time Fourier Transform (STFT) is defined by a set of interdependent parameters that create a fundamental trade-off between time and frequency resolution. Configuring these parameters is critical for optimizing performance in resource-constrained TinyML applications.
Window Function & Spectral Leakage
The window function (e.g., Hann, Hamming, Blackman) is multiplied with each segment of the signal before the FFT to reduce spectral leakage, a distortion where energy from one frequency spreads into neighboring bins. The choice of window involves a direct trade-off:
- Main lobe width: Determines frequency resolution; wider lobes smear nearby frequencies together.
- Side lobe attenuation: Determines how well the window suppresses leakage from distant frequencies.
- TinyML Implication: Simpler windows (like Hann) offer a good balance and are computationally cheaper to apply on a microcontroller than more complex ones.
Window Length (N) & Frequency Resolution
The window length (N) is the number of samples in each analysis segment. It directly defines the frequency resolution (Δf) of the resulting spectrogram: Δf = Fs / N, where Fs is the sampling rate.
- Longer Windows: Provide finer frequency resolution (smaller Δf), better for distinguishing close tones.
- Shorter Windows: Provide coarser frequency resolution, but better time localization for transient events.
- TinyML Constraint: Longer windows require larger FFTs, increasing memory usage and compute time quadratically (O(N log N)). On an MCU, N is often severely limited by RAM.
Hop Size (H) & Temporal Resolution
The hop size (H) is the number of samples the window advances between successive STFT frames. It determines the temporal resolution (or overlap) of the spectrogram.
- Smaller Hop (High Overlap): Produces a smoother, more detailed spectrogram in time but increases the total number of frames to compute.
- Larger Hop (Low/No Overlap): Reduces computational load and output data rate but can cause temporal aliasing, missing short-duration events.
- TinyML Optimization: A hop size of N/2 (50% overlap) is common, but for ultra-low-power applications, H = N (no overlap) may be necessary to minimize compute.
The Time-Frequency Uncertainty Principle
The Heisenberg-Gabor limit (or uncertainty principle) imposes a fundamental constraint: one cannot simultaneously achieve arbitrarily high resolution in both time and frequency. This is the core trade-off governing STFT parameter selection.
- Fine Frequency Resolution requires a long time window, which blurs the timing of rapid changes.
- Fine Time Resolution requires a short window, which spreads out frequency information.
- Engineering Implication: Parameters must be chosen based on the signal's characteristics. Analyzing a steady hum requires high frequency resolution; detecting a brief click requires high time resolution.
FFT Size & Zero-Padding
The FFT size (M) is often larger than the window length (N). The difference is filled with zero-padding, which appends zeros to the windowed segment before the FFT.
- Purpose: Zero-padding interpolates the frequency spectrum, providing a smoother visual representation and allowing frequency bins to be centered on specific frequencies of interest.
- Critical Note: It does not improve true frequency resolution (which is fixed by N). It only provides interpolated bins.
- TinyML Cost: Increasing M increases FFT computation time. Efficient libraries use M as a power of two. The choice is a balance between spectral smoothness and MCU cycle count.
Computational Complexity & MCU Optimization
The STFT's computational load on a microcontroller is dominated by the window multiply and the FFT for each frame.
- Operations per Frame: ~N (window multiply) + O(M log₂ M) (FFT).
- Frames per Second: Fs / H.
- Total Load: Scales with (Fs / H) * (N + M log₂ M).
- Optimization Strategies for TinyML:
- Use fixed-point arithmetic instead of floating-point.
- Pre-compute and store the window function in ROM.
- Use a highly optimized, power-of-two FFT library (e.g., CMSIS-DSP for ARM Cortex-M).
- Carefully select N, M, and H to stay within real-time deadlines and memory limits.
STFT vs. Other Time-Frequency Analysis Methods
A technical comparison of the Short-Time Fourier Transform (STFT) against other common time-frequency analysis techniques, focusing on characteristics critical for sensor data processing on resource-constrained devices.
| Feature / Metric | Short-Time Fourier Transform (STFT) | Wavelet Transform (CWT/DWT) | Wigner-Ville Distribution (WVD) |
|---|---|---|---|
Time-Frequency Resolution | Fixed (Uniform tiling) | Variable (Multi-resolution tiling) | Theoretically optimal (No windowing) |
Computational Complexity (for N samples) | O(N log N) via FFT | Continuous (CWT): O(N^2), Discrete (DWT): O(N) | O(N^2) |
Memory Footprint (Typical) | Low (One window at a time) | Low to Moderate (Depends on decomposition) | High (Full quadratic matrix) |
Suitability for Non-Stationary Signals | Moderate (Assumes local stationarity) | High (Designed for transients) | High (No stationarity assumption) |
Cross-Term Interference | |||
Real-Time Streaming Feasibility (MCU) | DWT: true, CWT: false | ||
Common Output Representation | Spectrogram (2D matrix) | Scalogram (CWT) / Coefficient Tree (DWT) | Wigner-Ville Distribution (2D matrix) |
Primary Use Case in TinyML | General-purpose spectral analysis (audio, vibration) | Transient detection, signal compression, denoising | Theoretical analysis; rarely deployed on MCUs |
Frequently Asked Questions
Essential questions about the Short-Time Fourier Transform (STFT), a core technique for analyzing how the frequency content of a signal, such as audio or vibration data, changes over time.
The Short-Time Fourier Transform (STFT) is a signal processing technique that computes the Fourier Transform of sequential, overlapping windowed segments of a time-domain signal to produce a time-frequency representation called a spectrogram. It works by:
- Windowing: A sliding window function (e.g., Hamming, Hann) isolates a short segment of the signal.
- Transformation: The Fast Fourier Transform (FFT) is applied to each windowed segment.
- Shifting: The window is shifted forward by a hop length, and the process repeats. The output is a complex-valued matrix where one axis represents time (window center), the other represents frequency bins, and the magnitude reveals the signal's spectral power over time.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Short-Time Fourier Transform (STFT) is a cornerstone of time-frequency analysis. These related concepts are essential for understanding its role in processing real-time sensor streams on constrained devices.
Fast Fourier Transform (FFT)
The Fast Fourier Transform (FFT) is an efficient algorithm for computing the Discrete Fourier Transform (DFT), which decomposes a signal from its time domain into its constituent frequencies. It is the computational engine behind each windowed segment in the STFT.
- Core Relationship: The STFT applies the FFT repeatedly to overlapping, windowed segments of a signal.
- Efficiency: The FFT's O(N log N) complexity makes real-time STFT feasible on microcontrollers.
- Constraint: The standard FFT assumes stationarity, which the STFT overcomes by analyzing local, short-time windows.
Spectrogram
A spectrogram is the visual or data representation produced by the STFT, plotting signal frequency content against time. It is the primary output used for analysis and feature extraction.
- Axes: Time (x-axis), Frequency (y-axis), and Intensity/Energy (color or z-axis).
- Applications: Used for visualizing audio patterns, vibration analysis, and as input features for convolutional neural networks (CNNs) in TinyML.
- Optimization: On-device, spectrograms are often computed using fixed-point arithmetic and stored in quantized formats to minimize memory footprint.
Windowing Function
A windowing function (e.g., Hann, Hamming, Blackman) is applied to each segment of data before the FFT in the STFT process to minimize spectral leakage.
- Purpose: Tapers the edges of the signal segment to reduce artifacts caused by analyzing a non-integer number of cycles.
- Trade-off: Introduces a resolution trade-off between frequency precision and time localization.
- TinyML Impact: Window choice and pre-computed window tables affect accuracy and compute load on microcontrollers.
Wavelet Transform
The Wavelet Transform is an alternative time-frequency analysis method that uses variable-sized windows, providing multi-resolution analysis.
- Key Difference: Unlike the STFT's fixed window, wavelets use short windows at high frequencies and long windows at low frequencies.
- Advantage: Better suited for analyzing signals with sudden, transient events (e.g., impacts, clicks).
- Computational Consideration: Can be more computationally intensive than STFT, making STFT often preferred for predictable, real-time streams on MCUs.
Mel-Frequency Cepstral Coefficients (MFCCs)
Mel-Frequency Cepstral Coefficients (MFCCs) are a compact feature set derived from an STFT-based spectrogram, designed to mimic human auditory perception.
- Processing Pipeline: STFT → Mel-filter bank (warping to Mel scale) → Logarithm → Discrete Cosine Transform (DCT).
- Primary Use: The standard feature for speech and audio recognition models, including those deployed on edge devices.
- Efficiency: MFCCs drastically reduce the dimensionality of the raw spectrogram, making them ideal for TinyML models with limited input size.
Time-Frequency Resolution Trade-off
The time-frequency resolution trade-off is a fundamental principle (related to the Heisenberg-Gabor limit) governing all time-frequency analyses like the STFT.
- Window Length: A long window provides good frequency resolution but poor time localization.
- Short Window: Provides good time localization but poor frequency resolution.
- Design Implication: Selecting the STFT window size and overlap is a critical system design choice for sensor applications, balancing the need to detect rapid events versus precisely identifying their frequency components.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us