Vegastrike 0.5.1 rc1
1.0
Original sources for Vegastrike Evolved
|
#include <stdlib.h>
#include <map>
#include <memory.h>
#include <stdio.h>
#include <math.h>
#include <limits>
#include "softvolume.h"
Go to the source code of this file.
Classes | |
class | t_rng16 |
class | shape_sampler |
struct | t_SoftVolume_State |
Macros | |
#define | SDL_MIX_MAXVOLUME 128 |
#define | SDL_INT64 __undefined_64bit_type__ |
#define | SDL_UINT64 __undefined_64bit_type__ |
#define | UC8_MIN ( (unsigned long) std::numeric_limits< unsigned char >::min() ) |
#define | UC8_MAX ( (unsigned long) std::numeric_limits< unsigned char >::max() ) |
#define | SC8_MIN ( (signed long) std::numeric_limits< signed char >::min() ) |
#define | SC8_MAX ( (signed long) std::numeric_limits< signed char >::max() ) |
#define | US16_MIN ( (unsigned long) std::numeric_limits< unsigned short >::min() ) |
#define | US16_MAX ( (unsigned long) std::numeric_limits< unsigned short >::max() ) |
#define | SS16_MIN ( (signed long) std::numeric_limits< signed short >::min() ) |
#define | SS16_MAX ( (signed long) std::numeric_limits< signed short >::max() ) |
#define | DB_INF -144.0 |
#define | STD_ERR stderr |
#define | STD_OUT stdout |
#define | SHAPE_SAMPLE_ORDER 10 |
#define | SHAPE_SAMPLES (1<<SHAPE_SAMPLE_ORDER) |
#define | SHAPE_SAMPLE_SAFEPOS(p) ( (p)&( (1<<SHAPE_SAMPLE_ORDER)-1 ) ) |
#define | RNG_COUNT (1<<16) |
#define | RNG_MASK ( (1<<16)-1 ) |
#define | LOG_10 2.3025850929940456840179914546844 |
#define | INV_LOG_10 (1.0/LOG_10) |
#define | C_PI 3.1415926535897932384626433832795 |
#define | lil_endian_to_native(x) x |
#define | native_to_big_endian(x) big_endian_to_native( x ) |
#define | native_to_lil_endian(x) lil_endian_to_native( x ) |
Typedefs | |
typedef int | Mix_Music |
typedef struct t_SoftVolume_State | SoftVolume_State |
Functions | |
template<typename T > | |
T | min (const T a, const T b) |
template<typename T > | |
T | max (const T a, const T b) |
unsigned long | interpolateF16F16 (unsigned long a, unsigned long b, unsigned long t) |
unsigned long | dtof16 (double f) |
double | f16tod (unsigned long f16) |
double | log2linear (double lg) |
double | linear2log (double lin) |
unsigned short | mpyUS16F16 (unsigned short a, unsigned long f16) |
signed short | mpySS16F16 (signed short a, unsigned long f16) |
unsigned char | mpyUC8F16 (unsigned char a, unsigned long f16) |
signed char | mpySC8F16 (signed char a, unsigned long f16) |
signed short | big_endian_to_native (signed short x) |
unsigned short | big_endian_to_native (unsigned short x) |
void | sdl_softvolume_effect_U8 (int chan, void *stream, int len, void *) |
void | sdl_softvolume_effect_S8 (int chan, void *stream, int len, void *) |
void | sdl_softvolume_effect_U16LSB (int chan, void *stream, int len, void *) |
void | sdl_softvolume_effect_S16LSB (int chan, void *stream, int len, void *) |
void | sdl_softvolume_effect_U16MSB (int chan, void *stream, int len, void *) |
void | sdl_softvolume_effect_S16MSB (int chan, void *stream, int len, void *) |
void | Mix_SoftVolume_Init () |
void | Mix_SoftVolume_Change (int chan, double newvolume, double time, Mix_SoftVolume_Shape shape) |
void | Mix_SoftVolume_Force (int chan, double newvolume) |
double | Mix_SoftVolume_GetCurrentVolume (int chan) |
void | Mix_SoftVolume_AutoStopMusic (int chan, int enable) |
Variables | |
class t_rng16 | rng16 |
std::map< int, SoftVolume_State > | channel_state |
int | g_sdl_frequency |
Uint16 | g_sdl_format |
int | g_sdl_channels |
int | g_sdl_init = 0 |
Mix_EffectFunc_t | g_sdl_effect_func = 0 |
#define C_PI 3.1415926535897932384626433832795 |
Definition at line 189 of file softvolume.cpp.
Referenced by Mix_SoftVolume_Change().
#define DB_INF -144.0 |
Definition at line 61 of file softvolume.cpp.
Referenced by linear2log().
#define INV_LOG_10 (1.0/LOG_10) |
Definition at line 188 of file softvolume.cpp.
Referenced by linear2log().
Definition at line 258 of file softvolume.cpp.
Referenced by sdl_softvolume_effect_S16LSB(), and sdl_softvolume_effect_U16LSB().
#define LOG_10 2.3025850929940456840179914546844 |
Definition at line 187 of file softvolume.cpp.
Referenced by log2linear().
#define native_to_big_endian | ( | x) | big_endian_to_native( x ) |
Definition at line 259 of file softvolume.cpp.
Referenced by sdl_softvolume_effect_S16MSB(), and sdl_softvolume_effect_U16MSB().
#define native_to_lil_endian | ( | x) | lil_endian_to_native( x ) |
Definition at line 260 of file softvolume.cpp.
Referenced by sdl_softvolume_effect_S16LSB(), and sdl_softvolume_effect_U16LSB().
#define RNG_COUNT (1<<16) |
Definition at line 76 of file softvolume.cpp.
Referenced by t_rng16::t_rng16().
#define RNG_MASK ( (1<<16)-1 ) |
Definition at line 77 of file softvolume.cpp.
Referenced by t_rng16::get().
#define SC8_MAX ( (signed long) std::numeric_limits< signed char >::max() ) |
Definition at line 45 of file softvolume.cpp.
Referenced by mpySC8F16().
#define SC8_MIN ( (signed long) std::numeric_limits< signed char >::min() ) |
Definition at line 44 of file softvolume.cpp.
Referenced by mpySC8F16().
#define SDL_INT64 __undefined_64bit_type__ |
Definition at line 26 of file softvolume.cpp.
#define SDL_MIX_MAXVOLUME 128 |
Definition at line 2 of file softvolume.cpp.
#define SDL_UINT64 __undefined_64bit_type__ |
Definition at line 27 of file softvolume.cpp.
#define SHAPE_SAMPLE_ORDER 10 |
Definition at line 72 of file softvolume.cpp.
Referenced by shape_sampler::done().
#define SHAPE_SAMPLE_SAFEPOS | ( | p) | ( (p)&( (1<<SHAPE_SAMPLE_ORDER)-1 ) ) |
Definition at line 74 of file softvolume.cpp.
Referenced by shape_sampler::operator*().
#define SHAPE_SAMPLES (1<<SHAPE_SAMPLE_ORDER) |
Definition at line 73 of file softvolume.cpp.
Referenced by shape_sampler::finalsample(), shape_sampler::init(), and Mix_SoftVolume_Change().
#define SS16_MAX ( (signed long) std::numeric_limits< signed short >::max() ) |
Definition at line 49 of file softvolume.cpp.
#define SS16_MIN ( (signed long) std::numeric_limits< signed short >::min() ) |
Definition at line 48 of file softvolume.cpp.
#define STD_ERR stderr |
Definition at line 68 of file softvolume.cpp.
Referenced by Mix_SoftVolume_Change().
#define STD_OUT stdout |
Definition at line 69 of file softvolume.cpp.
#define UC8_MAX ( (unsigned long) std::numeric_limits< unsigned char >::max() ) |
Definition at line 43 of file softvolume.cpp.
Referenced by mpyUC8F16().
#define UC8_MIN ( (unsigned long) std::numeric_limits< unsigned char >::min() ) |
Definition at line 42 of file softvolume.cpp.
Referenced by mpyUC8F16().
#define US16_MAX ( (unsigned long) std::numeric_limits< unsigned short >::max() ) |
Definition at line 47 of file softvolume.cpp.
#define US16_MIN ( (unsigned long) std::numeric_limits< unsigned short >::min() ) |
Definition at line 46 of file softvolume.cpp.
Definition at line 9 of file softvolume.cpp.
typedef struct t_SoftVolume_State SoftVolume_State |
|
inline |
Definition at line 250 of file softvolume.cpp.
Referenced by sdl_softvolume_effect_S16MSB(), and sdl_softvolume_effect_U16MSB().
|
inline |
Definition at line 254 of file softvolume.cpp.
|
inline |
Definition at line 178 of file softvolume.cpp.
Referenced by Mix_SoftVolume_Change(), and Mix_SoftVolume_Force().
|
inline |
Definition at line 182 of file softvolume.cpp.
Referenced by Mix_SoftVolume_Change(), and Mix_SoftVolume_GetCurrentVolume().
|
inline |
Definition at line 129 of file softvolume.cpp.
Referenced by shape_sampler::operator*().
|
inline |
Definition at line 195 of file softvolume.cpp.
References DB_INF, INV_LOG_10, and UniverseUtil::log().
Referenced by Mix_SoftVolume_Change().
|
inline |
Definition at line 191 of file softvolume.cpp.
References UniverseUtil::exp(), and LOG_10.
Referenced by Mix_SoftVolume_Change().
T max | ( | const T | a, |
const T | b | ||
) |
Definition at line 88 of file softvolume.cpp.
Referenced by applyto(), ParticleTrail::ChangeMax(), Point::Clamp(), ClampIt(), Technique::Pass::compile(), GameCockpit::Draw(), Radar::BubbleDisplay::DrawBackground(), DrawOneTargetBox(), Radar::BubbleDisplay::DrawTargetMarker(), Radar::PlaneDisplay::DrawTargetMarker(), Radar::BubbleDisplay::DrawTrack(), Radar::PlaneDisplay::DrawTrack(), dtof16(), anonymous_namespace{autodocking.cpp}::FindDockingPort(), Quaternion::from_vectors(), AIEvents::GeneralAIEventBegin(), get_alpha(), UniverseUtil::getRandCargo(), lerp(), Audio::OpenALSimpleSound::loadImpl(), Audio::OpenALStreamingSound::loadImpl(), loadsounds(), mpySC8F16(), mpySS16F16(), mpyUC8F16(), mpyUS16F16(), Radar::PlaneDisplay::PrepareAnimation(), UnitUtil::removeWeapon(), RGB_To_HSV(), Slider::setMaxMin(), GameCockpit::SetupViewPort(), NavigationSystem::SystemIterator::SystemIterator(), AABBCollider::TriBoxOverlap(), OBBCollider::TriBoxOverlap(), and CommunicatingAI::UpdateContrabandSearch().
T min | ( | const T | a, |
const T | b | ||
) |
Definition at line 80 of file softvolume.cpp.
Referenced by aynrand(), Point::Clamp(), ClampIt(), Audio::__impl::TemplateManagerData::DefinitionFileInfo::computeExpirationTime(), csSmoothStep(), GameCockpit::Draw(), dtof16(), Unit::ExplodingProgress(), AIEvents::GeneralAIEventBegin(), get_alpha(), lerp(), mpySC8F16(), mpySS16F16(), mpyUC8F16(), mpyUS16F16(), Audio::Stream::read(), RGB_To_HSV(), Slider::setMaxMin(), Scroller::setRangeValues(), GameCockpit::SetupViewPort(), AABBCollider::TriBoxOverlap(), OBBCollider::TriBoxOverlap(), VSRandom::uniformExc(), VSRandom::uniformInc(), and uniformrand().
Definition at line 560 of file softvolume.cpp.
References Mix_SoftVolume_Init().
Referenced by PlayMusic().
void Mix_SoftVolume_Change | ( | int | chan, |
double | newvolume, | ||
double | time, | ||
Mix_SoftVolume_Shape | shape | ||
) |
Definition at line 474 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, C_PI, UniverseUtil::cos(), t_SoftVolume_State::current_volume, dtof16(), f16tod(), fprintf, i, t_SoftVolume_State::in_transition, shape_sampler::init(), linear2log(), log2linear(), Mix_SoftVolume_Init(), MIX_SV_SHAPE_EASED, MIX_SV_SHAPE_EASED_EXP, MIX_SV_SHAPE_EXP, MIX_SV_SHAPE_LINEAR, shape_sampler::shape, SHAPE_SAMPLES, STD_ERR, and t_SoftVolume_State::t_shape.
Referenced by main(), and PlayMusic().
void Mix_SoftVolume_Force | ( | int | chan, |
double | newvolume | ||
) |
Definition at line 530 of file softvolume.cpp.
References t_SoftVolume_State::current_volume, dtof16(), t_SoftVolume_State::in_transition, and Mix_SoftVolume_Init().
Referenced by PlayMusic().
double Mix_SoftVolume_GetCurrentVolume | ( | int | chan) |
void Mix_SoftVolume_Init | ( | ) |
Definition at line 444 of file softvolume.cpp.
References sdl_softvolume_effect_S16LSB(), sdl_softvolume_effect_S16MSB(), sdl_softvolume_effect_S8(), sdl_softvolume_effect_U16LSB(), sdl_softvolume_effect_U16MSB(), and sdl_softvolume_effect_U8().
Referenced by Mix_SoftVolume_AutoStopMusic(), Mix_SoftVolume_Change(), Mix_SoftVolume_Force(), and Mix_SoftVolume_GetCurrentVolume().
|
inline |
|
inline |
Definition at line 229 of file softvolume.cpp.
References t_rng16::get(), max(), min(), and rng16.
Referenced by sdl_softvolume_effect_S16LSB(), and sdl_softvolume_effect_S16MSB().
|
inline |
Definition at line 237 of file softvolume.cpp.
References t_rng16::get(), max(), min(), rng16, UC8_MAX, and UC8_MIN.
Referenced by sdl_softvolume_effect_U8().
|
inline |
Definition at line 221 of file softvolume.cpp.
References t_rng16::get(), max(), min(), and rng16.
Referenced by sdl_softvolume_effect_U16LSB(), and sdl_softvolume_effect_U16MSB().
Definition at line 369 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, lil_endian_to_native, mpySS16F16(), native_to_lil_endian, and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
Definition at line 419 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, big_endian_to_native(), t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, mpySS16F16(), native_to_big_endian, and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
Definition at line 318 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, mpySC8F16(), and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
Definition at line 342 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, lil_endian_to_native, mpyUS16F16(), native_to_lil_endian, and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
Definition at line 393 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, big_endian_to_native(), t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, mpyUS16F16(), native_to_big_endian, and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
Definition at line 296 of file softvolume.cpp.
References t_SoftVolume_State::autoStopMusic, t_SoftVolume_State::current_volume, shape_sampler::done(), shape_sampler::finalsample(), i, t_SoftVolume_State::in_transition, mpyUC8F16(), and t_SoftVolume_State::t_shape.
Referenced by Mix_SoftVolume_Init().
std::map< int, SoftVolume_State > channel_state |
Definition at line 289 of file softvolume.cpp.
int g_sdl_channels |
Definition at line 292 of file softvolume.cpp.
Mix_EffectFunc_t g_sdl_effect_func = 0 |
Definition at line 294 of file softvolume.cpp.
Uint16 g_sdl_format |
Definition at line 291 of file softvolume.cpp.
int g_sdl_frequency |
Definition at line 290 of file softvolume.cpp.
int g_sdl_init = 0 |
Definition at line 293 of file softvolume.cpp.
class t_rng16 rng16 |
Referenced by mpySC8F16(), mpySS16F16(), mpyUC8F16(), and mpyUS16F16().