From 34462445e8dddb31a1d0a157d0857d47f2af9ecf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Wed, 23 Jul 2025 18:51:57 +0200 Subject: [PATCH] ts-audiotestsrc: fix non-desirable harmonics Part-of: --- generic/threadshare/src/audiotestsrc/imp.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/generic/threadshare/src/audiotestsrc/imp.rs b/generic/threadshare/src/audiotestsrc/imp.rs index 626423364..e2c65418a 100644 --- a/generic/threadshare/src/audiotestsrc/imp.rs +++ b/generic/threadshare/src/audiotestsrc/imp.rs @@ -403,7 +403,7 @@ impl TaskImpl for AudioTestSrcTask { let value = if self.mute { 0 } else { - (self.accumulator.sin() * self.volume * (i16::MAX as f64)) as i16 + (f64::sin(self.accumulator) * (i16::MAX as f64) * self.volume).round() as i16 }; for sample in chunk { *sample = value; @@ -411,7 +411,7 @@ impl TaskImpl for AudioTestSrcTask { self.accumulator += self.step; if self.accumulator >= 2.0 * std::f64::consts::PI { - self.accumulator = -2.0 * std::f64::consts::PI; + self.accumulator -= 2.0 * std::f64::consts::PI; } } }