mirror of https://github.com/bjornbytes/lovr.git
phonon: Directivity adjustments;
This commit is contained in:
parent
f60d6c8900
commit
5f2cdf0c22
|
@ -119,6 +119,23 @@ static int l_lovrSourceSetPose(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrSourceGetDirectivity(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
float weight, power;
|
||||
lovrSourceGetDirectivity(source, &weight, &power);
|
||||
lua_pushnumber(L, weight);
|
||||
lua_pushnumber(L, power);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int l_lovrSourceSetDirectivity(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
float weight = luax_optfloat(L, 2, 0.f);
|
||||
float power = luax_optfloat(L, 3, 0.f);
|
||||
lovrSourceSetDirectivity(source, weight, power);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrSourceIsAbsorptionEnabled(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
bool enabled = lovrSourceIsAbsorptionEnabled(source);
|
||||
|
@ -133,42 +150,6 @@ static int l_lovrSourceSetAbsorptionEnabled(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrSourceGetDirectivity(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
float weight, power;
|
||||
lovrSourceGetDirectivity(source, &weight, &power);
|
||||
if (weight == 0.f && power == 0.f) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
lua_pushnumber(L, weight);
|
||||
lua_pushnumber(L, power);
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int l_lovrSourceSetDirectivity(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
float weight = 0.f;
|
||||
float power = 0.f;
|
||||
switch (lua_type(L, 2)) {
|
||||
case LUA_TNONE:
|
||||
case LUA_TNIL:
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
if (lua_toboolean(L, 2)) {
|
||||
weight = .5f;
|
||||
power = 1.f;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
weight = luax_checkfloat(L, 2);
|
||||
power = luax_checkfloat(L, 3);
|
||||
break;
|
||||
}
|
||||
lovrSourceSetDirectivity(source, weight, power);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrSourceIsFalloffEnabled(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
bool enabled = lovrSourceIsFalloffEnabled(source);
|
||||
|
@ -199,10 +180,10 @@ const luaL_Reg lovrSource[] = {
|
|||
{ "isSpatial", l_lovrSourceIsSpatial },
|
||||
{ "getPose", l_lovrSourceGetPose },
|
||||
{ "setPose", l_lovrSourceSetPose },
|
||||
{ "isAbsorptionEnabled", l_lovrSourceIsAbsorptionEnabled },
|
||||
{ "setAbsorptionEnabled", l_lovrSourceSetAbsorptionEnabled },
|
||||
{ "getDirectivity", l_lovrSourceGetDirectivity },
|
||||
{ "setDirectivity", l_lovrSourceSetDirectivity },
|
||||
{ "isAbsorptionEnabled", l_lovrSourceIsAbsorptionEnabled },
|
||||
{ "setAbsorptionEnabled", l_lovrSourceSetAbsorptionEnabled },
|
||||
{ "isFalloffEnabled", l_lovrSourceIsFalloffEnabled },
|
||||
{ "setFalloffEnabled", l_lovrSourceSetFalloffEnabled },
|
||||
{ NULL, NULL }
|
||||
|
|
|
@ -491,14 +491,6 @@ void lovrSourceSetPose(Source *source, float position[4], float orientation[4])
|
|||
ma_mutex_unlock(&state.lock);
|
||||
}
|
||||
|
||||
bool lovrSourceIsAbsorptionEnabled(Source* source) {
|
||||
return source->absorption;
|
||||
}
|
||||
|
||||
void lovrSourceSetAbsorptionEnabled(Source* source, bool enabled) {
|
||||
source->absorption = enabled;
|
||||
}
|
||||
|
||||
void lovrSourceGetDirectivity(Source* source, float* weight, float* power) {
|
||||
*weight = source->dipoleWeight;
|
||||
*power = source->dipolePower;
|
||||
|
@ -509,6 +501,14 @@ void lovrSourceSetDirectivity(Source* source, float weight, float power) {
|
|||
source->dipolePower = power;
|
||||
}
|
||||
|
||||
bool lovrSourceIsAbsorptionEnabled(Source* source) {
|
||||
return source->absorption;
|
||||
}
|
||||
|
||||
void lovrSourceSetAbsorptionEnabled(Source* source, bool enabled) {
|
||||
source->absorption = enabled;
|
||||
}
|
||||
|
||||
bool lovrSourceIsFalloffEnabled(Source* source) {
|
||||
return source->falloff;
|
||||
}
|
||||
|
|
|
@ -57,10 +57,10 @@ void lovrSourceSetTime(Source* source, double time, TimeUnit units);
|
|||
bool lovrSourceIsSpatial(Source* source);
|
||||
void lovrSourceGetPose(Source* source, float position[4], float orientation[4]);
|
||||
void lovrSourceSetPose(Source* source, float position[4], float orientation[4]);
|
||||
bool lovrSourceIsAbsorptionEnabled(Source* source);
|
||||
void lovrSourceSetAbsorptionEnabled(Source* source, bool enabled);
|
||||
void lovrSourceGetDirectivity(Source* source, float* weight, float* power);
|
||||
void lovrSourceSetDirectivity(Source* source, float weight, float power);
|
||||
bool lovrSourceIsAbsorptionEnabled(Source* source);
|
||||
void lovrSourceSetAbsorptionEnabled(Source* source, bool enabled);
|
||||
bool lovrSourceIsFalloffEnabled(Source* source);
|
||||
void lovrSourceSetFalloffEnabled(Source* source, bool enabled);
|
||||
intptr_t* lovrSourceGetSpatializerMemoField(Source* source);
|
||||
|
|
Loading…
Reference in New Issue