mirror of
https://github.com/love2d/love.git
synced 2026-08-16 08:11:02 +02:00
Add SoundData:slice
SoundData:slice(start, length = -1) When length = -1, it will slice until the end.
This commit is contained in:
@@ -134,6 +134,18 @@ int w_SoundData_copyFrom(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int w_SoundData_slice(lua_State *L)
|
||||
{
|
||||
SoundData *t = luax_checksounddata(L, 1), *c = nullptr;
|
||||
int start = (int) luaL_checkinteger(L, 2);
|
||||
int length = (int) luaL_optinteger(L, 3, -1);
|
||||
|
||||
luax_catchexcept(L, [&](){ c = t->slice(start, length); });
|
||||
luax_pushtype(L, c);
|
||||
c->release();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const luaL_Reg w_SoundData_functions[] =
|
||||
{
|
||||
{ "clone", w_SoundData_clone },
|
||||
@@ -145,6 +157,7 @@ static const luaL_Reg w_SoundData_functions[] =
|
||||
{ "setSample", w_SoundData_setSample },
|
||||
{ "getSample", w_SoundData_getSample },
|
||||
{ "copyFrom", w_SoundData_copyFrom },
|
||||
{ "slice", w_SoundData_slice },
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user