Skip to content

Commit 3630d9b

Browse files
author
Vivian Stewart
committed
fast sine function
1 parent 8062f8e commit 3630d9b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/AudioEffects/SoundGenerator.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
#include "AudioBasic/Collections.h"
66

77
namespace audio_tools {
8-
8+
// sine approximation.
9+
float sine(float t) {
10+
float p = (t - (int)t) - 0.5f; // 0 <= p <= 1
11+
float pp = p * p;
12+
return (p - 6.283211f * pp * p + 9.132843f * pp * pp * p) * -6.221086f;
13+
}
914
/**
1015
* @brief Base class to define the abstract interface for the sound generating classes
1116
* @author Phil Schatzmann

0 commit comments

Comments
 (0)