# sansen10/cmsis_stft architecture

> Architecture diagram of the GitHub repository sansen10/cmsis_stft, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sansen10/cmsis_stft
- Repository: https://github.com/sansen10/cmsis_stft

## Overview

This is a lightweight STM32/Cortex-M STFT library using CMSIS-DSP. A caller initializes an instance, optionally configures ADC conversion and a callback, then submits a buffer for windowing, FFT and magnitude processing; results are delivered through the callback. The runtime supports floating-point and q15/q31 fixed-point paths, plus instance cleanup. The excerpts show parts of initialization, window generation and q15 execution; other advertised paths and capabilities are represented from the README rather than assumed source details.

Main entry points: [`src/cmsis_stft.c`](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c) (Float processing), [`inc/cmsis_stft.h`](https://github.com/sansen10/cmsis_stft/blob/main/inc/cmsis_stft.h) (STFT API), [`inc/stft_port.h`](https://github.com/sansen10/cmsis_stft/blob/main/inc/stft_port.h) (Core detection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Public interface"]
  node_public_api["STFT API<br/>[cmsis_stft.h]"]
  node_adc_config["ADC configuration<br/>[cmsis_stft.c]"]
end

subgraph group_runtime["STFT runtime"]
  node_float_path["Float processing<br/>[cmsis_stft.c]"]
  node_fixed_path["Fixed-point processing<br/>[cmsis_stft.c]"]
  node_windowing["Window generation<br/>[cmsis_stft.c]"]
  node_instance_memory["Instance lifecycle<br/>[cmsis_stft.c]"]
end

subgraph group_platform["DSP platform"]
  node_port_config["Core detection<br/>[stft_port.h]"]
  node_cmsis_dsp["CMSIS-DSP"]
end

node_caller(("Application"))
node_result_consumer(("Result callback"))

node_caller -->|"uses"| node_public_api
node_public_api -->|"includes"| node_port_config
node_caller -->|"submits float data"| node_float_path
node_caller -->|"submits ADC data"| node_fixed_path
node_caller -->|"sets ADC parameters"| node_adc_config
node_float_path -->|"generates coefficients"| node_windowing
node_float_path -->|"uses FFT math"| node_cmsis_dsp
node_fixed_path -->|"calls FFT routines"| node_cmsis_dsp
node_fixed_path -->|"invokes callback"| node_result_consumer
node_float_path -->|"provides callback output"| node_result_consumer
node_caller -->|"frees instance"| node_instance_memory

click node_public_api "https://github.com/sansen10/cmsis_stft/blob/main/inc/cmsis_stft.h"
click node_float_path "https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c"
click node_fixed_path "https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c"
click node_windowing "https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c"
click node_adc_config "https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c"
click node_instance_memory "https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c"
click node_port_config "https://github.com/sansen10/cmsis_stft/blob/main/inc/stft_port.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_public_api,node_adc_config toneBlue
class node_float_path,node_fixed_path,node_windowing,node_instance_memory toneAmber
class node_port_config,node_cmsis_dsp toneMint
class node_caller,node_result_consumer toneIndigo
```

## Components

### Public interface

- [STFT API](https://github.com/sansen10/cmsis_stft/blob/main/inc/cmsis_stft.h): `inc/cmsis_stft.h`
- [ADC configuration](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c): `src/cmsis_stft.c`

### STFT runtime

- [Float processing](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c): `src/cmsis_stft.c`
- [Fixed-point processing](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c): `src/cmsis_stft.c`
- [Window generation](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c): `src/cmsis_stft.c`
- [Instance lifecycle](https://github.com/sansen10/cmsis_stft/blob/main/src/cmsis_stft.c): `src/cmsis_stft.c`

### DSP platform

- [Core detection](https://github.com/sansen10/cmsis_stft/blob/main/inc/stft_port.h): `inc/stft_port.h`
- **CMSIS-DSP**

### Other components

- **Application**
- **Result callback**

## Connections

- Application → STFT API: uses (evidence: `README.md`)
- STFT API → Core detection: includes (evidence: `inc/cmsis_stft.h`)
- Application → Float processing: submits float data (evidence: `README.md`)
- Application → Fixed-point processing: submits ADC data (evidence: `README.md`)
- Application → ADC configuration: sets ADC parameters (evidence: `README.md`)
- Float processing → Window generation: generates coefficients (evidence: `src/cmsis_stft.c`)
- Float processing → CMSIS-DSP: uses FFT math (evidence: `README.md`)
- Fixed-point processing → CMSIS-DSP: calls FFT routines (evidence: `src/cmsis_stft.c`)
- Fixed-point processing → Result callback: invokes callback (evidence: `src/cmsis_stft.c`)
- Float processing → Result callback: provides callback output (evidence: `README.md`)
- Application → Instance lifecycle: frees instance (evidence: `README.md`)
