Skip to content

Commit f0ea2e4

Browse files
Ensure float operations in SoundSynthesizerEffects.
1 parent 6ac8666 commit f0ea2e4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

source/SoundSynthesizerEffects.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ void SoundSynthesizerEffects::linearInterpolation(SoundEmojiSynthesizer *synth,
102102
void SoundSynthesizerEffects::logarithmicInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context)
103103
{
104104
// Original frequency gen here, for reference. -John
105-
//synth->frequency = synth->effect->frequency+(log10(context->step)*(context->parameter[0]-synth->effect->frequency)/1.95);
105+
//synth->frequency = synth->effect->frequency+(log10f(context->step)*(context->parameter[0]-synth->effect->frequency)/1.95);
106106

107-
synth->frequency = synth->effect->frequency+(log10(
107+
synth->frequency = synth->effect->frequency+(log10f(
108108
( context->step==0 ? 1 : context->step ) // This is a hack, to prevent step==0 from jumping this to extreme values. -John
109-
)*(context->parameter[0]-synth->effect->frequency)/1.95);
109+
)*(context->parameter[0]-synth->effect->frequency)/1.95f);
110110

111111
// This is a bit of a hack, but will protect the synth for now until the math here can be fixed properly. -John
112112
if( synth->frequency < 0 )
@@ -117,39 +117,39 @@ void SoundSynthesizerEffects::logarithmicInterpolation(SoundEmojiSynthesizer *sy
117117
// parameter[0]: end frequency
118118
void SoundSynthesizerEffects::curveInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context)
119119
{
120-
synth->frequency = (sin(context->step*3.12159f/180.0f)*(context->parameter[0]-synth->effect->frequency)+synth->effect->frequency);
120+
synth->frequency = (sinf(context->step*3.12159f/180.0f)*(context->parameter[0]-synth->effect->frequency)+synth->effect->frequency);
121121
}
122122

123123
// Cosine interpolate function
124124
// parameter[0]: end frequency
125125
void SoundSynthesizerEffects::slowVibratoInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context){
126-
synth->frequency = sin(context->step/10)*context->parameter[0]+synth->effect->frequency;
126+
synth->frequency = sinf(context->step/10)*context->parameter[0]+synth->effect->frequency;
127127
}
128128

129129
//warble function
130130
// parameter[0]: end frequency
131131
void SoundSynthesizerEffects::warbleInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context)
132132
{
133-
synth->frequency = (sin(context->step)*(context->parameter[0]-synth->effect->frequency)+synth->effect->frequency);
133+
synth->frequency = (sinf(context->step)*(context->parameter[0]-synth->effect->frequency)+synth->effect->frequency);
134134
}
135135

136136
// Vibrato function
137137
// parameter[0]: end frequency
138138
void SoundSynthesizerEffects::vibratoInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context){
139-
synth->frequency = synth->effect->frequency + sin(context->step)*context->parameter[0];
139+
synth->frequency = synth->effect->frequency + sinf(context->step)*context->parameter[0];
140140
}
141141

142142
// Exponential rising function
143143
// parameter[0]: end frequency
144144
void SoundSynthesizerEffects::exponentialRisingInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context)
145145
{
146-
synth->frequency = synth->effect->frequency + sin(0.01745329f*context->step)*context->parameter[0];
146+
synth->frequency = synth->effect->frequency + sinf(0.01745329f*context->step)*context->parameter[0];
147147
}
148148

149149
// Exponential falling function
150150
void SoundSynthesizerEffects::exponentialFallingInterpolation(SoundEmojiSynthesizer *synth, ToneEffect *context)
151151
{
152-
synth->frequency = synth->effect->frequency + cos(0.01745329f*context->step)*context->parameter[0];
152+
synth->frequency = synth->effect->frequency + cosf(0.01745329f*context->step)*context->parameter[0];
153153
}
154154

155155
// Argeppio functions

0 commit comments

Comments
 (0)