Skip to content

Commit

Permalink
Fix triangle and sawtooth functions
Browse files Browse the repository at this point in the history
  • Loading branch information
aceiii committed Apr 25, 2024
1 parent 6f395d3 commit af26466
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit af26466

Please sign in to comment.