Skip to content

TaylorLCling/sdl-waveform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

sdl-waveform

A real-time ECG waveform viewer written in C++17 using SDL2. Simulates a scrolling cardiac waveform (PQRST complex) at 72 BPM with hardware-accelerated, double-buffered rendering.


Features

  • Simulates a physiologically-shaped PQRST cardiac cycle at 72 BPM
  • Producer/consumer architecture — waveform data is generated on a background thread and rendered on the main thread
  • Double-buffered rendering via SDL2 render targets for tear-free output
  • Thread-safe sample buffer with mutex-guarded access
  • Resizable window — back-buffer is rebuilt automatically on resize
  • Targets ~60 FPS with a 16 ms render loop

Requirements

  • macOS (currently built for x86_64)
  • Clang with C++17 support
  • SDL2 — install via Homebrew:
brew install sdl2

Build

make

Run

make run

Or directly:

./waveform

Controls

Key / Action Behavior
Esc Quit
Close window Quit
Resize window Rescales display

Project Structure

sdl-waveform/
├── main.cpp      # All source — producer thread, renderer, SDL setup
├── Makefile      # Build rules (clang++, sdl2-config)
└── waveform      # Compiled binary (generated)

Architecture

The application uses two threads:

  • Producer thread — recalculates 2000 samples of a PQRST waveform 60 times per second, advancing phase to create the scrolling animation. Writes into a mutex-protected WaveformData buffer.
  • Main thread — polls SDL events, then calls onPaint() which locks the buffer, maps samples to screen coordinates, and renders green line segments onto an off-screen texture before blitting to the screen.

About

simple ECG simulator, written in C

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors