ts-audiotestsrc: fix non-desirable harmonics

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2392>
This commit is contained in:
François Laignel 2025-07-23 18:51:57 +02:00 committed by GStreamer Marge Bot
parent 00cd58a21c
commit 34462445e8

View file

@ -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;
}
}
}