From af26466968e8d616d612a806bbdae01bf91d0bb7 Mon Sep 17 00:00:00 2001 From: Borin Ouch Date: Thu, 25 Apr 2024 09:24:38 -0700 Subject: [PATCH] Fix triangle and sawtooth functions --- src/sound.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sound.cpp b/src/sound.cpp index b55d9df..f498141 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -74,11 +74,11 @@ static inline float square_wave(float idx) { } static inline float triangle_wave(float idx) { - return std::abs(fmod((idx - 0.25f), 1.0f) - 0.5f) * 4 - 1; + return std::abs(fmod(idx, 1.0f) - 0.5f) * 4 - 1; } static inline float sawtooth_wave(float idx) { - return std::abs(fmod(idx * 2, 1.0f)) * 2 - 1; + return std::abs(fmod(idx, 1.0f)) * 2 - 1; } void WaveGeneratorSource::gen_sound_data(bool play_sound, short buffer[], size_t buffer_size) {