mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-06-06 07:20:48 +00:00
Fixed maths in testaudiostreamdynamicresample (and just show the actual scale)
This commit is contained in:
parent
14e38b17d6
commit
d2b9c8b80d
1 changed files with 10 additions and 12 deletions
|
@ -66,25 +66,23 @@ static void loop(void)
|
||||||
SDL_AudioSpec newspec;
|
SDL_AudioSpec newspec;
|
||||||
char title[64];
|
char title[64];
|
||||||
int newfreq = spec.freq;
|
int newfreq = spec.freq;
|
||||||
|
float scale = 1.0f;
|
||||||
|
|
||||||
multiplier = newmultiplier;
|
multiplier = newmultiplier;
|
||||||
if (multiplier == 0) {
|
|
||||||
SDL_snprintf(title, sizeof (title), "Drag the slider: Normal speed");
|
if (multiplier < 0) {
|
||||||
} else if (multiplier < 0) {
|
scale = 100.0f / (100.0f - multiplier);
|
||||||
SDL_snprintf(title, sizeof (title), "Drag the slider: %.2fx slow", (-multiplier / 100.0f) + 1.0f);
|
} else if (multiplier > 0) {
|
||||||
} else {
|
scale = (multiplier + 100.0f) / 100.0f;
|
||||||
SDL_snprintf(title, sizeof (title), "Drag the slider: %.2fx fast", (multiplier / 100.0f) + 1.0f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_snprintf(title, sizeof (title), "Drag the slider: %.2fx speed", scale);
|
||||||
|
|
||||||
for (i = 0; i < state->num_windows; i++) {
|
for (i = 0; i < state->num_windows; i++) {
|
||||||
SDL_SetWindowTitle(state->windows[i], title);
|
SDL_SetWindowTitle(state->windows[i], title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this math sucks, but whatever. */
|
newfreq = (int) (spec.freq * scale);
|
||||||
if (multiplier < 0) {
|
|
||||||
newfreq = spec.freq + (int) ((spec.freq * (multiplier / 400.0f)) * 0.75f);
|
|
||||||
} else if (multiplier > 0) {
|
|
||||||
newfreq = spec.freq + (int) (spec.freq * (multiplier / 100.0f));
|
|
||||||
}
|
|
||||||
/* SDL_Log("newfreq=%d multiplier=%d\n", newfreq, multiplier); */
|
/* SDL_Log("newfreq=%d multiplier=%d\n", newfreq, multiplier); */
|
||||||
SDL_memcpy(&newspec, &spec, sizeof (spec));
|
SDL_memcpy(&newspec, &spec, sizeof (spec));
|
||||||
newspec.freq = newfreq;
|
newspec.freq = newfreq;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue