Browse Source

Fixed wrong type of `phase` (#12014)

`phase` should be a `float` value that ranges between `0` and `1`.
Nicolas Firmo 3 months ago
parent
commit
842f6dc402

+ 1 - 1
examples/audio/01-simple-playback/simple-playback.c

@@ -76,7 +76,7 @@ SDL_AppResult SDL_AppIterate(void *appstate)
         /* generate a 440Hz pure tone */
         for (i = 0; i < SDL_arraysize(samples); i++) {
             const int freq = 440;
-            const int phase = current_sine_sample * freq / 8000.0f;
+            const float phase = current_sine_sample * freq / 8000.0f;
             samples[i] = SDL_sinf(phase * 2 * SDL_PI_F);
             current_sine_sample++;
         }

+ 1 - 1
examples/audio/02-simple-playback-callback/simple-playback-callback.c

@@ -36,7 +36,7 @@ static void SDLCALL FeedTheAudioStreamMore(void *userdata, SDL_AudioStream *astr
         /* generate a 440Hz pure tone */
         for (i = 0; i < total; i++) {
             const int freq = 440;
-            const int phase = current_sine_sample * freq / 8000.0f;
+            const float phase = current_sine_sample * freq / 8000.0f;
             samples[i] = SDL_sinf(phase * 2 * SDL_PI_F);
             current_sine_sample++;
         }