# interactive-sonification/pya architecture

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

- Interactive diagram: https://gitdiagram.com/interactive-sonification/pya
- Repository: https://github.com/interactive-sonification/pya

## Overview

pya is a Python audio-signal toolkit centered on Asig: users create or load signals, manipulate and analyze them, then queue playback or record audio through a selected backend. The graph preserves synthesis, spectrum/STFT/MFCC analysis, plotting and helper capabilities documented by the README. Edges are limited to README statements and source-index references; unsampled implementation details are not inferred.

Main entry points: [`pya/asig.py`](https://github.com/interactive-sonification/pya/blob/master/pya/asig.py) (Audio signal), [`pya/helper/visualization.py`](https://github.com/interactive-sonification/pya/blob/master/pya/helper/visualization.py) (Plotting), [`pya/aserver.py`](https://github.com/interactive-sonification/pya/blob/master/pya/aserver.py) (Playback server), [`pya/helper/backend.py`](https://github.com/interactive-sonification/pya/blob/master/pya/helper/backend.py) (Backend selection)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_signals["Signal workflow"]
  node_asig["Audio signal<br/>[asig.py]"]
  node_ugen["Unit generators<br/>[ugen.py]"]
  node_codec["Audio file codec<br/>[codec.py]"]
end

subgraph group_analysis["Signal analysis"]
  node_aspec["Spectrum<br/>[aspec.py]"]
  node_astft["STFT<br/>[astft.py]"]
  node_amfcc["MFCC features<br/>[amfcc.py]"]
end

subgraph group_io["Audio I/O"]
  node_recorder["Audio recorder<br/>[arecorder.py]"]
  node_server["Playback server<br/>[aserver.py]"]
end

subgraph group_backend["Audio backends"]
  node_backend_select["Backend selection<br/>[backend.py]"]
  node_backend_base["Backend interface<br/>[base.py]"]
  node_pyaudio["PyAudio backend<br/>[PyAudio.py]"]
  node_jupyter["Jupyter backend<br/>[Jupyter.py]"]
  node_dummy["Dummy backend<br/>[Dummy.py]"]
end

subgraph group_support["Helpers and display"]
  node_visualization["Plotting<br/>[visualization.py]"]
  node_helpers["Audio helpers<br/>[helpers.py]"]
end

node_user(("Python user"))
node_audio_device(("Audio device"))
node_jupyter_client(("Jupyter browser"))

node_user -->|"creates or edits"| node_asig
node_user -->|"generates signals"| node_ugen
node_asig -->|"loads audio"| node_codec
node_asig -->|"plays through"| node_server
node_user -->|"records input"| node_recorder
node_user -->|"analyzes spectrum"| node_aspec
node_user -->|"analyzes STFT"| node_astft
node_user -->|"extracts features"| node_amfcc
node_asig -->|"converts to"| node_aspec
node_asig -->|"converts to"| node_astft
node_asig -->|"provides signal"| node_amfcc
node_user -->|"plots signals"| node_visualization
node_asig -->|"plots via"| node_visualization
node_aspec -->|"plots via"| node_visualization
node_astft -->|"plots via"| node_visualization
node_server -->|"selects backend"| node_backend_select
node_backend_select -->|"tries local"| node_pyaudio
node_backend_select -->|"tries remote"| node_jupyter
node_pyaudio -->|"implements"| node_backend_base
node_jupyter -->|"implements"| node_backend_base
node_dummy -->|"implements"| node_backend_base
node_server -->|"plays audio"| node_audio_device
node_recorder -->|"captures audio"| node_audio_device
node_jupyter -->|"streams audio"| node_jupyter_client
node_asig -->|"uses utilities"| node_helpers

click node_asig "https://github.com/interactive-sonification/pya/blob/master/pya/asig.py"
click node_ugen "https://github.com/interactive-sonification/pya/blob/master/pya/ugen.py"
click node_codec "https://github.com/interactive-sonification/pya/blob/master/pya/helper/codec.py"
click node_aspec "https://github.com/interactive-sonification/pya/blob/master/pya/aspec.py"
click node_astft "https://github.com/interactive-sonification/pya/blob/master/pya/astft.py"
click node_amfcc "https://github.com/interactive-sonification/pya/blob/master/pya/amfcc.py"
click node_visualization "https://github.com/interactive-sonification/pya/blob/master/pya/helper/visualization.py"
click node_helpers "https://github.com/interactive-sonification/pya/blob/master/pya/helper/helpers.py"
click node_recorder "https://github.com/interactive-sonification/pya/blob/master/pya/arecorder.py"
click node_server "https://github.com/interactive-sonification/pya/blob/master/pya/aserver.py"
click node_backend_select "https://github.com/interactive-sonification/pya/blob/master/pya/helper/backend.py"
click node_backend_base "https://github.com/interactive-sonification/pya/blob/master/pya/backend/base.py"
click node_pyaudio "https://github.com/interactive-sonification/pya/blob/master/pya/backend/PyAudio.py"
click node_jupyter "https://github.com/interactive-sonification/pya/blob/master/pya/backend/Jupyter.py"
click node_dummy "https://github.com/interactive-sonification/pya/blob/master/pya/backend/Dummy.py"

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_asig,node_ugen,node_codec,node_user,node_jupyter_client toneBlue
class node_aspec,node_astft,node_amfcc toneAmber
class node_recorder,node_server toneMint
class node_backend_select,node_backend_base,node_pyaudio,node_jupyter,node_dummy toneRose
class node_visualization,node_helpers,node_audio_device toneIndigo
```

## Components

### Signal workflow

- [Audio signal](https://github.com/interactive-sonification/pya/blob/master/pya/asig.py): `pya/asig.py`
- [Unit generators](https://github.com/interactive-sonification/pya/blob/master/pya/ugen.py): `pya/ugen.py`
- [Audio file codec](https://github.com/interactive-sonification/pya/blob/master/pya/helper/codec.py): `pya/helper/codec.py`

### Signal analysis

- [Spectrum](https://github.com/interactive-sonification/pya/blob/master/pya/aspec.py): `pya/aspec.py`
- [STFT](https://github.com/interactive-sonification/pya/blob/master/pya/astft.py): `pya/astft.py`
- [MFCC features](https://github.com/interactive-sonification/pya/blob/master/pya/amfcc.py): `pya/amfcc.py`

### Audio I/O

- [Audio recorder](https://github.com/interactive-sonification/pya/blob/master/pya/arecorder.py): `pya/arecorder.py`
- [Playback server](https://github.com/interactive-sonification/pya/blob/master/pya/aserver.py): `pya/aserver.py`

### Audio backends

- [Backend selection](https://github.com/interactive-sonification/pya/blob/master/pya/helper/backend.py): `pya/helper/backend.py`
- [Backend interface](https://github.com/interactive-sonification/pya/blob/master/pya/backend/base.py): `pya/backend/base.py`
- [PyAudio backend](https://github.com/interactive-sonification/pya/blob/master/pya/backend/PyAudio.py): `pya/backend/PyAudio.py`
- [Jupyter backend](https://github.com/interactive-sonification/pya/blob/master/pya/backend/Jupyter.py): `pya/backend/Jupyter.py`
- [Dummy backend](https://github.com/interactive-sonification/pya/blob/master/pya/backend/Dummy.py): `pya/backend/Dummy.py`

### Helpers and display

- [Plotting](https://github.com/interactive-sonification/pya/blob/master/pya/helper/visualization.py): `pya/helper/visualization.py`
- [Audio helpers](https://github.com/interactive-sonification/pya/blob/master/pya/helper/helpers.py): `pya/helper/helpers.py`

### Other components

- **Python user**
- **Audio device**
- **Jupyter browser**

## Connections

- Python user → Audio signal: creates or edits (evidence: `README.md`)
- Python user → Unit generators: generates signals (evidence: `README.md`)
- Audio signal → Audio file codec: loads audio (evidence: `pya/asig.py`)
- Audio signal → Playback server: plays through (evidence: `pya/asig.py`)
- Python user → Audio recorder: records input (evidence: `README.md`)
- Python user → Spectrum: analyzes spectrum (evidence: `README.md`)
- Python user → STFT: analyzes STFT (evidence: `README.md`)
- Python user → MFCC features: extracts features (evidence: `pya/amfcc.py`)
- Audio signal → Spectrum: converts to (evidence: `pya/aspec.py`)
- Audio signal → STFT: converts to (evidence: `pya/astft.py`)
- Audio signal → MFCC features: provides signal (evidence: `pya/amfcc.py`)
- Python user → Plotting: plots signals (evidence: `README.md`)
- Audio signal → Plotting: plots via (evidence: `pya/asig.py`)
- Spectrum → Plotting: plots via (evidence: `pya/aspec.py`)
- STFT → Plotting: plots via (evidence: `pya/astft.py`)
- Playback server → Backend selection: selects backend (evidence: `pya/aserver.py`)
- Backend selection → PyAudio backend: tries local (evidence: `pya/helper/backend.py`)
- Backend selection → Jupyter backend: tries remote (evidence: `pya/helper/backend.py`)
- PyAudio backend → Backend interface: implements (evidence: `pya/backend/PyAudio.py`)
- Jupyter backend → Backend interface: implements (evidence: `pya/backend/Jupyter.py`)
- Dummy backend → Backend interface: implements (evidence: `pya/backend/Dummy.py`)
- Playback server → Audio device: plays audio (evidence: `README.md`)
- Audio recorder → Audio device: captures audio (evidence: `README.md`)
- Jupyter backend → Jupyter browser: streams audio (evidence: `pya/backend/Jupyter.py`)
- Audio signal → Audio helpers: uses utilities (evidence: `pya/asig.py`)
