A pulse oximeter shines red (660nm) and infrared (940nm) light through the skin and measures how much is transmitted through the finger/wrist. Arterial blood volume rises and falls with every heartbeat, so absorption oscillates around a steady baseline (Beer–Lambert law):
I(t) = I_DC − I_AC(t), AC = pulsatile arterial blood
Ratio of ratios: R = (AC_red/DC_red) / (AC_ir/DC_ir)
Empirical calibration: SpO2(%) ≈ 110 − 25·R
This simulator generates a real two-lobe systolic-peak + dicrotic-notch PPG waveform for each wavelength from the true heart rate and SpO2 you set, then independently re-derives the monitor's readout from that noisy signal the same way real firmware does:
- Heart rate is recovered by peak-picking the filtered IR trace over a rolling window and averaging the inter-beat intervals.
- SpO₂ is recovered by tracking the AC (peak−trough) and DC (mean) envelope of both channels over each cardiac cycle and applying the ratio-of-ratios formula above — the same empirical curve used in commercial pulse oximeters.
- Motion artifact injects low-frequency baseline wander and high-frequency jitter that swamps the true pulsatile signal, exactly as an arm swing does on a real wearable — watch the measured values drift and the signal-quality index collapse.
- Ambient light noise adds a random DC offset per sample, mimicking stray light leaking under a loose wristband.
Real-world relevance: this red/IR ratio-of-ratios pipeline is the exact principle behind every clinical pulse oximeter and consumer wearable (smartwatches, fitness bands) that reports heart rate and blood oxygen from the wrist or fingertip.