mirror of
https://github.com/bjornbytes/lovr.git
synced 2024-07-08 23:23:38 +00:00
- Ref struct only stores refcount now and is more general. - Proxy stores a hash of its type name instead of an enum. - Variants store additional information instead of using a vtable. - Remove the concept of superclasses from the API. - Clean up some miscellaneous includes.
66 lines
2 KiB
C
66 lines
2 KiB
C
#include "api.h"
|
|
#include "data/soundData.h"
|
|
|
|
static int l_lovrSoundDataGetBitDepth(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushinteger(L, soundData->bitDepth);
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetChannelCount(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushinteger(L, soundData->channelCount);
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetDuration(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushnumber(L, soundData->samples / (float) soundData->sampleRate);
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetSample(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
int index = luaL_checkinteger(L, 2);
|
|
lua_pushnumber(L, lovrSoundDataGetSample(soundData, index));
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetSampleCount(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushinteger(L, soundData->samples);
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetSampleRate(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushinteger(L, soundData->sampleRate);
|
|
return 1;
|
|
}
|
|
|
|
static int l_lovrSoundDataSetSample(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
int index = luaL_checkinteger(L, 2);
|
|
float value = luax_checkfloat(L, 3);
|
|
lovrSoundDataSetSample(soundData, index, value);
|
|
return 0;
|
|
}
|
|
|
|
static int l_lovrSoundDataGetPointer(lua_State* L) {
|
|
SoundData* soundData = luax_checktype(L, 1, SoundData);
|
|
lua_pushlightuserdata(L, soundData->blob.data);
|
|
return 1;
|
|
}
|
|
|
|
const luaL_Reg lovrSoundData[] = {
|
|
{ "getBitDepth", l_lovrSoundDataGetBitDepth },
|
|
{ "getChannelCount", l_lovrSoundDataGetChannelCount },
|
|
{ "getDuration", l_lovrSoundDataGetDuration },
|
|
{ "getSample", l_lovrSoundDataGetSample },
|
|
{ "getSampleCount", l_lovrSoundDataGetSampleCount },
|
|
{ "getSampleRate", l_lovrSoundDataGetSampleRate },
|
|
{ "setSample", l_lovrSoundDataSetSample },
|
|
{ "getPointer", l_lovrSoundDataGetPointer },
|
|
{ NULL, NULL }
|
|
};
|