aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-10-12 16:41:13 -0700
committerChris Robinson <[email protected]>2019-10-12 16:41:13 -0700
commite70f98c95afc61802b26795dbe8aeb20514a211b (patch)
treeba88a30a2cea797ec85e1c687adfaad0e22ecb10 /examples
parent630d4d573dbe09828cb1b161581207ff53af4b52 (diff)
Wrap the cycle amount when passing to sin()
Diffstat (limited to 'examples')
-rw-r--r--examples/altonegen.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/examples/altonegen.c b/examples/altonegen.c
index 26ae788d..553bc996 100644
--- a/examples/altonegen.c
+++ b/examples/altonegen.c
@@ -82,7 +82,10 @@ static void ApplySin(ALfloat *data, ALdouble g, ALuint srate, ALuint freq)
ALdouble smps_per_cycle = (ALdouble)srate / freq;
ALuint i;
for(i = 0;i < srate;i++)
- data[i] += (ALfloat)(sin(i/smps_per_cycle * 2.0*M_PI) * g);
+ {
+ ALdouble ival;
+ data[i] += (ALfloat)(sin(modf(i/smps_per_cycle, &ival) * 2.0*M_PI) * g);
+ }
}
/* Generates waveforms using additive synthesis. Each waveform is constructed