# cristellcp/wave_visualizer architecture

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

- Interactive diagram: https://gitdiagram.com/cristellcp/wave_visualizer
- Repository: https://github.com/cristellcp/wave_visualizer

## Overview

#### Purpose and startup

Wave Visualizer is a desktop Python application for generating electrical/signal-processing waveforms, displaying them in real time, and playing or exporting them as audio. The executable entry point is `main.py`, which assembles the GUI and connects waveform, plotting, and audio capabilities.

#### Application shell and user control

The Tkinter-based interface lives in `gui/main_window.py`. It exposes user-selected waveform type plus frequency and amplitude controls, then drives updates into visualization and audio paths. This is the primary boundary between interactive UI events and signal-processing logic.

Paths:
- `main.py`
- `gui/main_window.py`

#### Waveform domain layer

Waveform definitions and generation are separated into an `ondas` package. `ondas/tipos_ondas.py` represents the supported signal families—sine, cosine, square, triangular, and sawtooth—while `ondas/generador_ondas.py` produces sampled numeric signals from the selected type and parameters.

This layer should remain independent of GUI rendering and device playback: its output is the shared signal representation consumed downstream.

Paths:
- `ondas/generador_ondas.py`
- `ondas/tipos_ondas.py`
- `ondas/__init__.py`

#### Sampling and signal flow

The central data flow is: GUI control values → waveform generator → sampled numerical array → plot renderer and/or audio output. Frequency and amplitude affect generated samples; sampling rate and duration define the time-domain resolution needed for both visualization and playback. NumPy and SciPy are the material numerical/signal dependencies described by the project.

Paths:
- `gui/main_window.py`
- `ondas/generador_ondas.py`
- `requirements.txt`

#### Real-time visualization

`graficas/realtime_plot.py` is the plotting boundary. It receives generated samples and renders the current waveform, likely embedding or coordinating Matplotlib output with the Tkinter application. Rendering is downstream-only: it visualizes the numerical signal rather than defining waveform mathematics.

Paths:
- `graficas/realtime_plot.py`
- `graficas/__init__.py`
- `gui/main_window.py`

#### Audio playback and export

The `audio` package converts the same sampled signal into an audio-oriented representation. `audio/audio.py` handles playback through the local audio stack, using SoundDevice according to the README. `audio/wav_exporter.py` provides a durable-file boundary by writing waveform data as WAV output, rather than requiring live hardware playback.

Paths:
- `audio/audio.py`
- `audio/wav_exporter.py`
- `audio/audio.py`

#### Runtime and external dependencies

The project runs locally under Python 3 with a desktop display server and an accessible audio device. Tkinter supplies UI widgets; Matplotlib renders plots; NumPy/SciPy support sampled signal computation; SoundDevice interfaces with the host audio subsystem. There are no indicated network services, databases, backend servers, or cloud infrastructure.

Paths:
- `requirements.txt`
- `main.py`

Main entry points: [`ondas/generador_ondas.py`](https://github.com/cristellcp/wave_visualizer/blob/main/ondas/generador_ondas.py) (Waveform generator), [`requirements.txt`](https://github.com/cristellcp/wave_visualizer/blob/main/requirements.txt) (Numerical and media libraries), [`audio/audio.py`](https://github.com/cristellcp/wave_visualizer/blob/main/audio/audio.py) (Audio playback), [`main.py`](https://github.com/cristellcp/wave_visualizer/blob/main/main.py) (Application entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Desktop application"]
  node_entry["Application entry<br/>Python entry point<br/>[main.py]"]
  node_ui["Tkinter main window<br/>GUI controller<br/>[main_window.py]"]
end

subgraph group_signal["Signal domain"]
  node_wave_types["Waveform types<br/>signal families<br/>[tipos_ondas.py]"]
  node_generator["Waveform generator<br/>signal generator<br/>[generador_ondas.py]"]
  node_samples["Sampled signal<br/>numeric array"]
end

subgraph group_outputs["Visualization and audio"]
  node_plot["Real-time plot<br/>plot renderer<br/>[realtime_plot.py]"]
  node_playback["Audio playback<br/>audio adapter<br/>[audio.py]"]
  node_exporter["WAV exporter<br/>file exporter<br/>[wav_exporter.py]"]
  node_wav_file["WAV output<br/>audio file"]
end

node_desktop_runtime{{"Python desktop runtime<br/>local runtime"}}
node_dependencies["Numerical and media libraries<br/>dependencies<br/>[requirements.txt]"]
node_audio_device{{"Host audio device<br/>local hardware"}}

node_entry -->|"starts"| node_ui
node_ui -->|"selected type and parameters"| node_generator
node_wave_types -->|"defines families"| node_generator
node_generator -->|"generates"| node_samples
node_samples -->|"visualizes"| node_plot
node_samples -->|"plays"| node_playback
node_samples -->|"exports"| node_exporter
node_exporter -->|"writes"| node_wav_file
node_dependencies -.->|"numeric processing"| node_generator
node_dependencies -.->|"Matplotlib"| node_plot
node_dependencies -.->|"SoundDevice"| node_playback
node_playback -->|"outputs audio"| node_audio_device
node_desktop_runtime -.->|"runs"| node_entry

click node_entry "https://github.com/cristellcp/wave_visualizer/blob/main/main.py"
click node_ui "https://github.com/cristellcp/wave_visualizer/blob/main/gui/main_window.py"
click node_wave_types "https://github.com/cristellcp/wave_visualizer/blob/main/ondas/tipos_ondas.py"
click node_generator "https://github.com/cristellcp/wave_visualizer/blob/main/ondas/generador_ondas.py"
click node_plot "https://github.com/cristellcp/wave_visualizer/blob/main/graficas/realtime_plot.py"
click node_playback "https://github.com/cristellcp/wave_visualizer/blob/main/audio/audio.py"
click node_exporter "https://github.com/cristellcp/wave_visualizer/blob/main/audio/wav_exporter.py"
click node_dependencies "https://github.com/cristellcp/wave_visualizer/blob/main/requirements.txt"

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_entry,node_ui toneBlue
class node_wave_types,node_generator,node_samples toneAmber
class node_plot,node_playback,node_exporter,node_wav_file toneMint
class node_desktop_runtime,node_dependencies,node_audio_device toneNeutral
```

## Components

### Desktop application

- [Application entry](https://github.com/cristellcp/wave_visualizer/blob/main/main.py): Python entry point · Assembles the desktop application. · `main.py`
- [Tkinter main window](https://github.com/cristellcp/wave_visualizer/blob/main/gui/main_window.py): GUI controller · Captures waveform, frequency, and amplitude controls. · `gui/main_window.py`

### Signal domain

- [Waveform types](https://github.com/cristellcp/wave_visualizer/blob/main/ondas/tipos_ondas.py): signal families · Sine, cosine, square, triangular, and sawtooth definitions. · `ondas/tipos_ondas.py`
- [Waveform generator](https://github.com/cristellcp/wave_visualizer/blob/main/ondas/generador_ondas.py): signal generator · Produces sampled signals from selected parameters. · `ondas/generador_ondas.py`
- **Sampled signal**: numeric array · Shared time-domain representation for rendering and audio.

### Visualization and audio

- [Real-time plot](https://github.com/cristellcp/wave_visualizer/blob/main/graficas/realtime_plot.py): plot renderer · Renders the current sampled waveform. · `graficas/realtime_plot.py`
- [Audio playback](https://github.com/cristellcp/wave_visualizer/blob/main/audio/audio.py): audio adapter · Plays sampled signals through the local audio stack. · `audio/audio.py`
- [WAV exporter](https://github.com/cristellcp/wave_visualizer/blob/main/audio/wav_exporter.py): file exporter · Writes sampled waveform data as WAV audio. · `audio/wav_exporter.py`
- **WAV output**: audio file

### Other components

- **Python desktop runtime**: local runtime · Python 3 with display server and accessible audio device.
- [Numerical and media libraries](https://github.com/cristellcp/wave_visualizer/blob/main/requirements.txt): dependencies · NumPy, SciPy, Matplotlib, and SoundDevice support processing and output. · `requirements.txt`
- **Host audio device**: local hardware

## Connections

- Application entry → Tkinter main window: starts
- Tkinter main window → Waveform generator: selected type and parameters
- Waveform types → Waveform generator: defines families
- Waveform generator → Sampled signal: generates
- Sampled signal → Real-time plot: visualizes
- Sampled signal → Audio playback: plays
- Sampled signal → WAV exporter: exports
- WAV exporter → WAV output: writes
- Numerical and media libraries → Waveform generator: numeric processing
- Numerical and media libraries → Real-time plot: Matplotlib
- Numerical and media libraries → Audio playback: SoundDevice
- Audio playback → Host audio device: outputs audio
- Python desktop runtime → Application entry: runs
