mirror of https://github.com/bjornbytes/lovr.git
Source:setPosition; Source:getPosition;
This commit is contained in:
parent
952330d1c8
commit
b28d822797
|
@ -64,6 +64,10 @@ float lovrSourceGetPitch(Source* source) {
|
|||
return pitch;
|
||||
}
|
||||
|
||||
void lovrSourceGetPosition(Source* source, float* x, float* y, float* z) {
|
||||
alGetSource3f(source->id, AL_POSITION, x, y, z);
|
||||
}
|
||||
|
||||
int lovrSourceGetSampleRate(Source* source) {
|
||||
return source->soundData->sampleRate;
|
||||
}
|
||||
|
@ -146,6 +150,10 @@ void lovrSourceSetLooping(Source* source, int isLooping) {
|
|||
source->isLooping = isLooping;
|
||||
}
|
||||
|
||||
void lovrSourceSetPosition(Source* source, float x, float y, float z) {
|
||||
alSource3f(source->id, AL_POSITION, x, y, z);
|
||||
}
|
||||
|
||||
void lovrSourceSetVolume(Source* source, float volume) {
|
||||
alSourcef(source->id, AL_GAIN, volume);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@ int lovrSourceGetChannels(Source* source);
|
|||
int lovrSourceGetDuration(Source* source);
|
||||
ALenum lovrSourceGetFormat(Source* source);
|
||||
float lovrSourceGetPitch(Source* source);
|
||||
void lovrSourceGetPosition(Source* source, float* x, float* y, float* z);
|
||||
int lovrSourceGetSampleRate(Source* source);
|
||||
float lovrSourceGetVolume(Source* source);
|
||||
int lovrSourceIsLooping(Source* source);
|
||||
|
@ -52,6 +53,7 @@ void lovrSourceRewind(Source* source);
|
|||
void lovrSourceSeek(Source* source, int sample);
|
||||
void lovrSourceSetLooping(Source* source, int isLooping);
|
||||
void lovrSourceSetPitch(Source* source, float pitch);
|
||||
void lovrSourceSetPosition(Source* source, float x, float y, float z);
|
||||
void lovrSourceSetVolume(Source* source, float volume);
|
||||
void lovrSourceStop(Source* source);
|
||||
void lovrSourceStream(Source* source, ALuint* buffers, int count);
|
||||
|
|
|
@ -6,6 +6,7 @@ const luaL_Reg lovrSource[] = {
|
|||
{ "getChannels", l_lovrSourceGetChannels },
|
||||
{ "getDuration", l_lovrSourceGetDuration },
|
||||
{ "getPitch", l_lovrSourceGetPitch },
|
||||
{ "getPosition", l_lovrSourceGetPosition },
|
||||
{ "getSampleRate", l_lovrSourceGetSampleRate },
|
||||
{ "getVolume", l_lovrSourceGetVolume },
|
||||
{ "isLooping", l_lovrSourceIsLooping },
|
||||
|
@ -19,6 +20,7 @@ const luaL_Reg lovrSource[] = {
|
|||
{ "seek", l_lovrSourceSeek },
|
||||
{ "setLooping", l_lovrSourceSetLooping },
|
||||
{ "setPitch", l_lovrSourceSetPitch },
|
||||
{ "setPosition", l_lovrSourceSetPosition },
|
||||
{ "setVolume", l_lovrSourceSetVolume },
|
||||
{ "stop", l_lovrSourceStop },
|
||||
{ "tell", l_lovrSourceTell },
|
||||
|
@ -57,6 +59,15 @@ int l_lovrSourceGetPitch(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int l_lovrSourceGetPosition(lua_State* L) {
|
||||
float x, y, z;
|
||||
lovrSourceGetPosition(luax_checktype(L, 1, Source), &x, &y, &z);
|
||||
lua_pushnumber(L, x);
|
||||
lua_pushnumber(L, y);
|
||||
lua_pushnumber(L, z);
|
||||
return 3;
|
||||
}
|
||||
|
||||
int l_lovrSourceGetSampleRate(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
lua_pushinteger(L, lovrSourceGetSampleRate(source));
|
||||
|
@ -134,6 +145,15 @@ int l_lovrSourceSetPitch(lua_State* L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrSourceSetPosition(lua_State* L) {
|
||||
Source* source = luax_checktype(L, 1, Source);
|
||||
float x = luaL_checknumber(L, 2);
|
||||
float y = luaL_checknumber(L, 3);
|
||||
float z = luaL_checknumber(L, 4);
|
||||
lovrSourceSetPosition(source, x, y, z);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int l_lovrSourceSetVolume(lua_State* L) {
|
||||
lovrSourceSetVolume(luax_checktype(L, 1, Source), luaL_checknumber(L, 2));
|
||||
return 0;
|
||||
|
|
|
@ -8,6 +8,7 @@ int l_lovrSourceGetBitDepth(lua_State* L);
|
|||
int l_lovrSourceGetChannels(lua_State* L);
|
||||
int l_lovrSourceGetDuration(lua_State* L);
|
||||
int l_lovrSourceGetPitch(lua_State* L);
|
||||
int l_lovrSourceGetPosition(lua_State* L);
|
||||
int l_lovrSourceGetSampleRate(lua_State* L);
|
||||
int l_lovrSourceGetVolume(lua_State* L);
|
||||
int l_lovrSourceIsLooping(lua_State* L);
|
||||
|
@ -21,6 +22,7 @@ int l_lovrSourceRewind(lua_State* L);
|
|||
int l_lovrSourceSeek(lua_State* L);
|
||||
int l_lovrSourceSetLooping(lua_State* L);
|
||||
int l_lovrSourceSetPitch(lua_State* L);
|
||||
int l_lovrSourceSetPosition(lua_State* L);
|
||||
int l_lovrSourceSetVolume(lua_State* L);
|
||||
int l_lovrSourceStop(lua_State* L);
|
||||
int l_lovrSourceTell(lua_State* L);
|
||||
|
|
Loading…
Reference in New Issue