From 196ed03a3d20f61a5f021714dfcb8e7fff920019 Mon Sep 17 00:00:00 2001 From: GABRIEL Sebastian Date: Thu, 12 Nov 2026 21:04:35 +0100 Subject: [PATCH] =?UTF-8?q?v0.6.5=20=E2=80=94=20Two-tone=20audible=20alarm?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both standard/technical and critical alarm sounds now consist of two distinct successive pitches. Critical alarms retain their priority and faster repeat interval; standard alarms retain their slower cadence. The Admin test button plays the standard two-tone alert. A single QRS beep is reserved for a later release and is not generated yet. No visual alarm or simulation logic changed. --- ...-monitor-simulation-v0.6.4-to-v0.6.5.patch | 180 ++++++++++++++++++ patient-monitor-simulation/Cargo.lock | 2 +- patient-monitor-simulation/Cargo.toml | 2 +- patient-monitor-simulation/README.de.md | 13 +- patient-monitor-simulation/README.de.md.orig | 24 +-- patient-monitor-simulation/README.de.md.rej | 28 +-- patient-monitor-simulation/README.md | 25 ++- patient-monitor-simulation/src/alarm.rs | 39 +++- 8 files changed, 267 insertions(+), 46 deletions(-) create mode 100644 patient-monitor-simulation-v0.6.4-to-v0.6.5.patch diff --git a/patient-monitor-simulation-v0.6.4-to-v0.6.5.patch b/patient-monitor-simulation-v0.6.4-to-v0.6.5.patch new file mode 100644 index 0000000..ad52331 --- /dev/null +++ b/patient-monitor-simulation-v0.6.4-to-v0.6.5.patch @@ -0,0 +1,180 @@ +diff --git a/Cargo.toml b/Cargo.toml +index 46b979b..8087e1c 100644 +--- a/Cargo.toml ++++ b/Cargo.toml +@@ -1,6 +1,6 @@ + [package] + name = "patient-monitor-simulation" +-version = "0.6.4" ++version = "0.6.5" + edition = "2021" + license = "MIT" + description = "Synthetic patient-monitor simulation for teaching (not for clinical use)" +diff --git a/README.de.md b/README.de.md +index d9f1101..3a42b91 100644 +--- a/README.de.md ++++ b/README.de.md +@@ -1,4 +1,4 @@ +-# Patient Monitor Simulation (PaMSim) — v0.6.4 ++# Patient Monitor Simulation (PaMSim) — v0.6.5 + + Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenstern für die Lehre unter Fedora Linux. + +@@ -175,7 +175,7 @@ Mit **F11** wird der Vollbildmodus aktiviert bzw. umgeschaltet, mit **Esc** wird + Unter Wayland sollte das Fenster vor dem Wechsel in den Vollbildmodus auf den gewünschten Präsentationsbildschirm verschoben werden. + Der Vollbildmodus sperrt den Computer nicht gegen andere Eingaben. + +-## Akustische Alarme (v0.5.3) ++## Akustische Alarme (aktualisiert v0.6.5) + + Die akustische Alarmierung ist **standardmäßig eingeschaltet**. Im + Admin-Fenster lässt sie sich mit **Audible alarms** aktivieren bzw. stummschalten. +@@ -183,11 +183,14 @@ Mit **Test tone** kann die Tonausgabe unabhängig von der Stummschaltung geprüf + werden. Die optischen Alarme blinken bei stummgeschalteter Tonausgabe weiterhin. + + - **Kritische Rhythmusalarme:** VT, PVT, Kammerflimmern und Asystolie lösen +- einen Doppelton aus (zweimal kurz 880 Hz), der ungefähr alle 1,5 Sekunden +- wiederholt wird. ++ einen **Zweiklang aus aufeinanderfolgenden, unterschiedlichen Tönen** aus ++ (880 Hz gefolgt von 1160 Hz), der ungefähr alle 1,5 Sekunden wiederholt wird. + - **Numerische und technische Alarme:** Grenzwertüberschreitungen sowie +- **NO SENSOR** und **NO READING** lösen einen kurzen Ton mit 700 Hz aus, +- der ungefähr alle 2,5 Sekunden wiederholt wird. ++ **NO SENSOR** und **NO READING** lösen ebenfalls einen **Zweitonalarm** aus ++ (700 Hz gefolgt von 950 Hz), der ungefähr alle 2,5 Sekunden wiederholt wird. ++- Zwischen beiden Tönen liegt jeweils eine kurze Pause. Ein einzelner ++ **QRS-Piepton** ist für eine spätere Version vorgesehen und wird derzeit ++ noch nicht ausgegeben. + - Kritische Alarme haben Vorrang. Auch bei mehreren gleichzeitig aktiven + Alarmen wird nur eine Tonfolge ausgegeben. Bei behobenem Alarm oder + Stummschaltung verstummt die Ausgabe. Ausgeblendete Monitorbereiche +@@ -619,3 +622,13 @@ mit **Apply** gespeichert; **Measure now** startet unmittelbar einen Messzyklus, + auch wenn die Automatik ausgeschaltet ist. Die Admin-Oberfläche wird + synchronisiert. Die anderen Parametermenüs bleiben auf Alarmgrenzen beschränkt. + Manschettenzuordnung und simulierter Messausfall verbleiben im Admin-Fenster. ++ ++ ++### v0.6.5 – Zweitonige akustische Alarme ++ ++Sowohl Standard- und technische Alarme als auch kritische Rhythmusalarme ++bestehen nun aus zwei aufeinanderfolgenden Tönen unterschiedlicher Frequenz. ++Die Priorisierung und die Wiederholungsintervalle bleiben unverändert. ++**Test tone** spielt den Standard-Zweitonalarm. Ein einzelner QRS-Piepton ++ist für eine spätere Erweiterung reserviert. Optische Alarme und ++Simulationsverhalten wurden nicht verändert. +diff --git a/README.md b/README.md +index faab37e..f413723 100644 +--- a/README.md ++++ b/README.md +@@ -1,4 +1,4 @@ +-# Patient Monitor Simulation (PaMSim) — v0.6.4 ++# Patient Monitor Simulation (PaMSim) — v0.6.5 + + A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux. + +@@ -166,17 +166,21 @@ The monitor can be resized and toggled fullscreen with **F11**; **Esc** exits + fullscreen. On Wayland, move the monitor to the presentation screen before + activating fullscreen. Fullscreen does not lock down the computer. + +-## Audible alarms (v0.5.3) ++## Audible alarms (updated v0.6.5) + + Sound is **enabled by default**. The Admin window has an **Audible alarms** + checkbox for muting and a **Test tone** button (works even while muted). + Visual alarms keep blinking normally when sound is off. + +-- **Critical rhythm alarm:** VT, PVT, VF and asystole produce a double beep +- (two short 880 Hz tones), repeated approximately every 1.5 seconds. ++- **Critical rhythm alarm:** VT, PVT, VF and asystole produce a higher-pitched ++ **two-tone** alert (880 Hz followed by 1160 Hz), repeated approximately ++ every 1.5 seconds. + - **Numerical and SpO₂ technical alarms:** out-of-range values, **NO SENSOR** +- and **NO READING** produce a single 700 Hz beep, repeated approximately +- every 2.5 seconds. ++ and **NO READING** produce a lower-pitched **two-tone** alert ++ (700 Hz followed by 950 Hz), repeated approximately every 2.5 seconds. ++- Both alarm signals use two **different successive pitches**, separated by ++ a brief silence. A distinct **single QRS beep is reserved for future work**; ++ QRS-related audio is not yet implemented. + - Critical alarms have priority: only one tone pattern is played even if + multiple alarms are active. The sound stops when all alarms clear or when + the checkbox is unchecked. Alarms on hidden monitor channels are excluded. +@@ -634,3 +638,12 @@ are saved with Apply; Measure now starts a cuff cycle immediately regardless + of Auto. Both monitor and Admin display the selected settings. Other monitor + menus remain limited to alarm thresholds; NIBP cuff placement, the simulated + failed-reading option and non-NIBP signal settings remain Admin-only. ++ ++ ++### v0.6.5 — Two-tone audible alarms ++ ++Both standard/technical and critical alarm sounds now consist of two distinct ++successive pitches. Critical alarms retain their priority and faster repeat ++interval; standard alarms retain their slower cadence. The Admin test button ++plays the standard two-tone alert. A single QRS beep is reserved for a later ++release and is not generated yet. No visual alarm or simulation logic changed. +diff --git a/src/alarm.rs b/src/alarm.rs +index 116b7f4..6e0b1af 100644 +--- a/src/alarm.rs ++++ b/src/alarm.rs +@@ -84,14 +84,21 @@ pub fn level(p: &Parameters, sim: &Simulator) -> AlarmLevel { + result + } + +-/// Very short, original synthesized sine beeps; mono PCM16 WAV. ++/// Both alarm priorities sound as two successive, different pitches. ++/// A future QRS beep will be a separate, single-tone signal. ++/// Zero-frequency segments are short silences between the notes. ++fn tone_segments(critical: bool) -> &'static [(f64, f64)] { ++ if critical { ++ &[(880.0, 0.16), (0.0, 0.08), (1160.0, 0.16)] ++ } else { ++ &[(700.0, 0.14), (0.0, 0.06), (950.0, 0.14)] ++ } ++} ++ ++/// Very short, original synthesized two-tone alerts; mono PCM16 WAV. + fn wav(critical: bool) -> Vec { + const SAMPLE_RATE: u32 = 44_100; +- let segments: &[(f64, f64)] = if critical { +- &[(880.0, 0.16), (0.0, 0.09), (880.0, 0.16)] +- } else { +- &[(700.0, 0.18)] +- }; ++ let segments = tone_segments(critical); + let samples: usize = segments.iter() + .map(|(_, seconds)| (seconds * f64::from(SAMPLE_RATE)).round() as usize) + .sum(); +@@ -267,8 +274,9 @@ impl AlarmAudio { + } + + /// Called from a 100-ms GLib timer, not the 250-Hz waveform simulator. +- /// Critical rhythms: double tone every 1.5 s; other alarms: single tone +- /// every 2.5 s. Stop promptly when muted or all alarm states clear. ++ /// Critical rhythms: higher-pitched two-tone alert every 1.5 s; ++ /// other alarms: lower-pitched two-tone alert every 2.5 s. ++ /// Stop promptly when muted or all alarm states clear. + pub fn update(&mut self, level: AlarmLevel, enabled: bool) { + self.reap(); + if !enabled || level == AlarmLevel::None { +@@ -322,6 +330,21 @@ mod tests { + assert!(wav(true).len() > wav(false).len()); + } + ++ #[test] ++ fn both_alarm_priorities_have_two_distinct_audible_pitches() { ++ for critical in [false, true] { ++ let segments = tone_segments(critical); ++ let notes: Vec = segments.iter() ++ .filter_map(|(hz, _seconds)| (*hz > 0.0).then_some(*hz)) ++ .collect(); ++ assert_eq!(notes.len(), 2, "each alarm pattern must contain two notes"); ++ assert_ne!(notes[0], notes[1], "a two-tone alert needs distinct pitches"); ++ assert!(segments.iter().any(|(hz, _)| *hz == 0.0), "notes must be separated"); ++ assert!(segments.iter().all(|(_, seconds)| *seconds > 0.0)); ++ } ++ assert_ne!(wav(false), wav(true)); ++ } ++ + #[test] + fn normal_signals_are_silent_and_numeric_limit_alarms_beep() { + let mut p = Parameters::default(); diff --git a/patient-monitor-simulation/Cargo.lock b/patient-monitor-simulation/Cargo.lock index c38c525..ed569f2 100644 --- a/patient-monitor-simulation/Cargo.lock +++ b/patient-monitor-simulation/Cargo.lock @@ -438,7 +438,7 @@ dependencies = [ [[package]] name = "patient-monitor-simulation" -version = "0.6.4" +version = "0.6.5" dependencies = [ "gtk4", ] diff --git a/patient-monitor-simulation/Cargo.toml b/patient-monitor-simulation/Cargo.toml index 46b979b..8087e1c 100644 --- a/patient-monitor-simulation/Cargo.toml +++ b/patient-monitor-simulation/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "patient-monitor-simulation" -version = "0.6.4" +version = "0.6.5" edition = "2021" license = "MIT" description = "Synthetic patient-monitor simulation for teaching (not for clinical use)" diff --git a/patient-monitor-simulation/README.de.md b/patient-monitor-simulation/README.de.md index 205eab4..8d65b6b 100644 --- a/patient-monitor-simulation/README.de.md +++ b/patient-monitor-simulation/README.de.md @@ -172,7 +172,7 @@ Mit **F11** wird der Vollbildmodus aktiviert bzw. umgeschaltet, mit **Esc** wird Unter Wayland sollte das Fenster vor dem Wechsel in den Vollbildmodus auf den gewünschten Präsentationsbildschirm verschoben werden. Der Vollbildmodus sperrt den Computer nicht gegen andere Eingaben. -## Akustische Alarme (v0.5.3) +## Akustische Alarme (aktualisiert v0.6.5) Die akustische Alarmierung ist **standardmäßig eingeschaltet**. Im Admin-Fenster lässt sie sich mit **Audible alarms** aktivieren bzw. stummschalten. @@ -180,11 +180,14 @@ Mit **Test tone** kann die Tonausgabe unabhängig von der Stummschaltung geprüf werden. Die optischen Alarme blinken bei stummgeschalteter Tonausgabe weiterhin. - **Kritische Rhythmusalarme:** VT, PVT, Kammerflimmern und Asystolie lösen - einen Doppelton aus (zweimal kurz 880 Hz), der ungefähr alle 1,5 Sekunden - wiederholt wird. + einen **Zweiklang aus aufeinanderfolgenden, unterschiedlichen Tönen** aus + (880 Hz gefolgt von 1160 Hz), der ungefähr alle 1,5 Sekunden wiederholt wird. - **Numerische und technische Alarme:** Grenzwertüberschreitungen sowie - **NO SENSOR** und **NO READING** lösen einen kurzen Ton mit 700 Hz aus, - der ungefähr alle 2,5 Sekunden wiederholt wird. + **NO SENSOR** und **NO READING** lösen ebenfalls einen **Zweitonalarm** aus + (700 Hz gefolgt von 950 Hz), der ungefähr alle 2,5 Sekunden wiederholt wird. +- Zwischen beiden Tönen liegt jeweils eine kurze Pause. Ein einzelner + **QRS-Piepton** ist für eine spätere Version vorgesehen und wird derzeit + noch nicht ausgegeben. - Kritische Alarme haben Vorrang. Auch bei mehreren gleichzeitig aktiven Alarmen wird nur eine Tonfolge ausgegeben. Bei behobenem Alarm oder Stummschaltung verstummt die Ausgabe. Ausgeblendete Monitorbereiche diff --git a/patient-monitor-simulation/README.de.md.orig b/patient-monitor-simulation/README.de.md.orig index 891d116..205eab4 100644 --- a/patient-monitor-simulation/README.de.md.orig +++ b/patient-monitor-simulation/README.de.md.orig @@ -26,7 +26,7 @@ vierten Feldes; die gesamte untere Wertezeile bleibt bestehen. Beim Ausblenden anderer Parameter werden die verbleibenden Kurvenzeilen wie bisher dynamisch verteilt. -## Touch-Bedienung am Monitor: ausschließlich Alarmgrenzen (v0.6.1) +## Touch-Bedienung am Monitor: Alarmgrenzen und NIBP-Funktionen (v0.6.4) Durch Berühren oder Anklicken der **Kurve oder des numerischen Wertefeldes** von EKG, SpO₂, ART oder CO₂ öffnet sich das entsprechende Alarmmenü. Bei @@ -36,7 +36,7 @@ Die Menüs funktionieren auch im Vollbildmodus und verwenden **schwarzen Hintergrund, sehr hellgraue Schrift sowie 0,8 Pixel breite Begrenzungs- und Trennlinien** wie der Hauptmonitor. -**Am Monitor können ausschließlich Alarmgrenzen eingestellt werden.** +**In allen Monitor-Menüs können die Alarmgrenzen eingestellt werden.** Für jede untere und obere Alarmgrenze stehen große **−/+**-Tasten sowie separate **ON/OFF**-Tasten zur Verfügung. Nicht gesetzte Grenzwerte sind deaktiviert. Ein unterer Grenzwert darf den oberen nicht überschreiten. @@ -55,18 +55,20 @@ Bei manueller Änderung wechselt das Alarm-Preset zu **Custom**. Mit **Cancel** oder **Esc** werden nicht übernommene Änderungen verworfen. Die Auswahl der EKG-Ableitung, SpO₂-Signalqualität und Sensorverbindung, -der arteriellen Kurvenform, der Kapnogrammform sowie **sämtliche NIBP- -Messfunktionen** sind ausschließlich im **Admin-Fenster** verfügbar. Dazu -zählen Messintervall, automatische Messung, **Measure now**, simulierter -Messausfall und Manschettenlokalisation. Diese Parameter können über die -Alarmmenüs am Monitor nicht verändert werden. +der arteriellen Kurvenform und der Kapnogrammform bleiben ausschließlich im +**Admin-Fenster**. Das **NIBP-Touchmenü** bietet zusätzlich **Measure now**, +**Automatic measurement ON/OFF** und **Measurement interval** (1, 3, 5, 10, +20, 30 oder 60 Minuten). Intervall und Automatik werden erst mit **Apply** +übernommen; **Measure now** startet dagegen sofort, auch bei deaktivierter +Automatik. Eine bereits laufende Messung wird nicht erneut gestartet. +Simulierter Messausfall und Manschettenlokalisation bleiben Admin-only. ### NIBP beim Programmstart Die **automatische NIBP-Messung ist beim Start ausgeschaltet**. Anfangs zeigt der Monitor `---/---` (MAP `---`); es findet keine Messung statt. -Die erste Messung wird über **Measure now** im Admin-Fenster oder durch -Aktivieren von **Automatic NIBP measurement** ausgelöst. Beim Einschalten +Die erste Messung wird über **Measure now** im NIBP-Touchmenü oder Admin-Fenster +oder durch Aktivieren von **Automatic NIBP measurement** ausgelöst. Beim Einschalten von Auto beginnt sofort ein Messzyklus; das Intervall zählt anschließend jeweils ab Ende der vorherigen Messung. Beim Ausschalten von Auto wird eine bereits laufende Messung nicht abgebrochen. **Measure now** funktioniert @@ -83,8 +85,8 @@ rechts **+ · Wert · − · OFF/ON** angeordnet. Die Schaltfläche zum Deaktivieren liegt unmittelbar rechts von Minus. Größe, Gestaltung, Schrittweite, Wiederherstellung des letzten Werts sowie Apply/Cancel bleiben erhalten. Bei Platzmangel lässt sich die Matrix scrollen, während -Apply und Cancel zugänglich bleiben. Andere Einstellungen bleiben dem -Admin-Fenster vorbehalten. +Apply und Cancel zugänglich bleiben. Andere Einstellungen bleiben dem Admin-Fenster vorbehalten, mit Ausnahme der +expliziten NIBP-Messfunktionen im Touchmenü. ## Thoraxkompressionen (v0.5.4) diff --git a/patient-monitor-simulation/README.de.md.rej b/patient-monitor-simulation/README.de.md.rej index bd362a4..c6614e1 100644 --- a/patient-monitor-simulation/README.de.md.rej +++ b/patient-monitor-simulation/README.de.md.rej @@ -1,22 +1,22 @@ --- README.de.md +++ README.de.md @@ -1,4 +1,4 @@ --# Patient Monitor Simulation (PaMSim) — v0.6.3 -+# Patient Monitor Simulation (PaMSim) — v0.6.4 +-# Patient Monitor Simulation (PaMSim) — v0.6.4 ++# Patient Monitor Simulation (PaMSim) — v0.6.5 Ein mit Rust und GTK4 entwickelter Patient*innenmonitor-Simulator mit zwei Fenstern für die Lehre unter Fedora Linux. -@@ -609,3 +611,13 @@ - Kurvenformen sowie NIBP-Messfunktionen wurden aus den Monitor-Menüs entfernt - und bleiben im Admin-Fenster verfügbar. Die Simulationslogik, Alarmprüfung - und das NIBP-Startverhalten wurden nicht verändert. +@@ -622,3 +625,13 @@ mit **Apply** gespeichert; **Measure now** startet unmittelbar einen Messzyklus, + auch wenn die Automatik ausgeschaltet ist. Die Admin-Oberfläche wird + synchronisiert. Die anderen Parametermenüs bleiben auf Alarmgrenzen beschränkt. + Manschettenzuordnung und simulierter Messausfall verbleiben im Admin-Fenster. + -+### v0.6.4 – NIBP-Touchbedienung wiederhergestellt + -+Das NIBP-Menü enthält wieder **Measure now**, **Automatic measurement ON/OFF** -+und das **Messintervall** (1, 3, 5, 10, 20, 30 oder 60 Minuten) oberhalb der -+SYS/MAP/DIA-Alarmmatrix. Die Einstellungen für Intervall und Automatik werden -+mit **Apply** gespeichert; **Measure now** startet unmittelbar einen Messzyklus, -+auch wenn die Automatik ausgeschaltet ist. Die Admin-Oberfläche wird -+synchronisiert. Die anderen Parametermenüs bleiben auf Alarmgrenzen beschränkt. -+Manschettenzuordnung und simulierter Messausfall verbleiben im Admin-Fenster. ++### v0.6.5 – Zweitonige akustische Alarme ++ ++Sowohl Standard- und technische Alarme als auch kritische Rhythmusalarme ++bestehen nun aus zwei aufeinanderfolgenden Tönen unterschiedlicher Frequenz. ++Die Priorisierung und die Wiederholungsintervalle bleiben unverändert. ++**Test tone** spielt den Standard-Zweitonalarm. Ein einzelner QRS-Piepton ++ist für eine spätere Erweiterung reserviert. Optische Alarme und ++Simulationsverhalten wurden nicht verändert. diff --git a/patient-monitor-simulation/README.md b/patient-monitor-simulation/README.md index faab37e..f413723 100644 --- a/patient-monitor-simulation/README.md +++ b/patient-monitor-simulation/README.md @@ -1,4 +1,4 @@ -# Patient Monitor Simulation (PaMSim) — v0.6.4 +# Patient Monitor Simulation (PaMSim) — v0.6.5 A Rust/GTK4 patient-monitor simulator with two main windows for teaching on Fedora Linux. @@ -166,17 +166,21 @@ The monitor can be resized and toggled fullscreen with **F11**; **Esc** exits fullscreen. On Wayland, move the monitor to the presentation screen before activating fullscreen. Fullscreen does not lock down the computer. -## Audible alarms (v0.5.3) +## Audible alarms (updated v0.6.5) Sound is **enabled by default**. The Admin window has an **Audible alarms** checkbox for muting and a **Test tone** button (works even while muted). Visual alarms keep blinking normally when sound is off. -- **Critical rhythm alarm:** VT, PVT, VF and asystole produce a double beep - (two short 880 Hz tones), repeated approximately every 1.5 seconds. +- **Critical rhythm alarm:** VT, PVT, VF and asystole produce a higher-pitched + **two-tone** alert (880 Hz followed by 1160 Hz), repeated approximately + every 1.5 seconds. - **Numerical and SpO₂ technical alarms:** out-of-range values, **NO SENSOR** - and **NO READING** produce a single 700 Hz beep, repeated approximately - every 2.5 seconds. + and **NO READING** produce a lower-pitched **two-tone** alert + (700 Hz followed by 950 Hz), repeated approximately every 2.5 seconds. +- Both alarm signals use two **different successive pitches**, separated by + a brief silence. A distinct **single QRS beep is reserved for future work**; + QRS-related audio is not yet implemented. - Critical alarms have priority: only one tone pattern is played even if multiple alarms are active. The sound stops when all alarms clear or when the checkbox is unchecked. Alarms on hidden monitor channels are excluded. @@ -634,3 +638,12 @@ are saved with Apply; Measure now starts a cuff cycle immediately regardless of Auto. Both monitor and Admin display the selected settings. Other monitor menus remain limited to alarm thresholds; NIBP cuff placement, the simulated failed-reading option and non-NIBP signal settings remain Admin-only. + + +### v0.6.5 — Two-tone audible alarms + +Both standard/technical and critical alarm sounds now consist of two distinct +successive pitches. Critical alarms retain their priority and faster repeat +interval; standard alarms retain their slower cadence. The Admin test button +plays the standard two-tone alert. A single QRS beep is reserved for a later +release and is not generated yet. No visual alarm or simulation logic changed. diff --git a/patient-monitor-simulation/src/alarm.rs b/patient-monitor-simulation/src/alarm.rs index 116b7f4..6e0b1af 100644 --- a/patient-monitor-simulation/src/alarm.rs +++ b/patient-monitor-simulation/src/alarm.rs @@ -84,14 +84,21 @@ pub fn level(p: &Parameters, sim: &Simulator) -> AlarmLevel { result } -/// Very short, original synthesized sine beeps; mono PCM16 WAV. +/// Both alarm priorities sound as two successive, different pitches. +/// A future QRS beep will be a separate, single-tone signal. +/// Zero-frequency segments are short silences between the notes. +fn tone_segments(critical: bool) -> &'static [(f64, f64)] { + if critical { + &[(880.0, 0.16), (0.0, 0.08), (1160.0, 0.16)] + } else { + &[(700.0, 0.14), (0.0, 0.06), (950.0, 0.14)] + } +} + +/// Very short, original synthesized two-tone alerts; mono PCM16 WAV. fn wav(critical: bool) -> Vec { const SAMPLE_RATE: u32 = 44_100; - let segments: &[(f64, f64)] = if critical { - &[(880.0, 0.16), (0.0, 0.09), (880.0, 0.16)] - } else { - &[(700.0, 0.18)] - }; + let segments = tone_segments(critical); let samples: usize = segments.iter() .map(|(_, seconds)| (seconds * f64::from(SAMPLE_RATE)).round() as usize) .sum(); @@ -267,8 +274,9 @@ impl AlarmAudio { } /// Called from a 100-ms GLib timer, not the 250-Hz waveform simulator. - /// Critical rhythms: double tone every 1.5 s; other alarms: single tone - /// every 2.5 s. Stop promptly when muted or all alarm states clear. + /// Critical rhythms: higher-pitched two-tone alert every 1.5 s; + /// other alarms: lower-pitched two-tone alert every 2.5 s. + /// Stop promptly when muted or all alarm states clear. pub fn update(&mut self, level: AlarmLevel, enabled: bool) { self.reap(); if !enabled || level == AlarmLevel::None { @@ -322,6 +330,21 @@ mod tests { assert!(wav(true).len() > wav(false).len()); } + #[test] + fn both_alarm_priorities_have_two_distinct_audible_pitches() { + for critical in [false, true] { + let segments = tone_segments(critical); + let notes: Vec = segments.iter() + .filter_map(|(hz, _seconds)| (*hz > 0.0).then_some(*hz)) + .collect(); + assert_eq!(notes.len(), 2, "each alarm pattern must contain two notes"); + assert_ne!(notes[0], notes[1], "a two-tone alert needs distinct pitches"); + assert!(segments.iter().any(|(hz, _)| *hz == 0.0), "notes must be separated"); + assert!(segments.iter().all(|(_, seconds)| *seconds > 0.0)); + } + assert_ne!(wav(false), wav(true)); + } + #[test] fn normal_signals_are_silent_and_numeric_limit_alarms_beep() { let mut p = Parameters::default();