fix build.
2 SDL_mixer: An audio mixer library based on the SDL library
3 Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any damages
7 arising from the use of this software.
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must not
14 claim that you wrote the original software. If you use this software
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
21 This file by Ryan C. Gordon (icculus@icculus.org)
23 These are some helper functions for the internal mixer special effects.
27 /* ------ These are used internally only. Don't touch. ------ */
31 #include "SDL_mixer.h"
33 #define MIX_INTERNAL_EFFECT__
34 #include "effects_internal.h"
36 /* Should we favor speed over memory usage and/or quality of output? */
37 int _Mix_effects_max_speed = 0;
40 void _Mix_InitEffects(void)
42 _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
45 void _Mix_DeinitEffects(void)
47 _Eff_PositionDeinit();
51 void *_Eff_volume_table = NULL;
54 /* Build the volume table for Uint8-format samples.
56 * Each column of the table is a possible sample, while each row of the
57 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
58 * volume. So _Eff_volume_table[128][mysample] would be the value of
59 * mysample, at half volume.
61 void *_Eff_build_volume_table_u8(void)
67 if (!_Mix_effects_max_speed) {
71 if (!_Eff_volume_table) {
72 rc = SDL_malloc(256 * 256);
74 _Eff_volume_table = (void *) rc;
75 for (volume = 0; volume < 256; volume++) {
76 for (sample = -128; sample < 128; sample ++) {
77 *rc = (Uint8)(((float) sample) * ((float) volume / 255.0f))
85 return(_Eff_volume_table);
89 /* Build the volume table for Sint8-format samples.
91 * Each column of the table is a possible sample, while each row of the
92 * table is a volume. Volume is a Uint8, where 0 is silence and 255 is full
93 * volume. So _Eff_volume_table[128][mysample+128] would be the value of
94 * mysample, at half volume.
96 void *_Eff_build_volume_table_s8(void)
102 if (!_Eff_volume_table) {
103 rc = SDL_malloc(256 * 256);
105 _Eff_volume_table = (void *) rc;
106 for (volume = 0; volume < 256; volume++) {
107 for (sample = -128; sample < 128; sample ++) {
108 *rc = (Sint8)(((float) sample) * ((float) volume / 255.0f));
115 return(_Eff_volume_table);
119 /* end of effects.c ... */
121 /* vi: set ts=4 sw=4 expandtab: */