mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Add SoundData:getSampleCount() function
Adds SoundData:getSampleCount(), calculates how many samples there are in this particular SoundData. resolves #578 --HG-- branch : sounddata-samplecount
This commit is contained in:
@@ -147,6 +147,11 @@ int SoundData::getSampleRate() const
|
|||||||
return sampleRate;
|
return sampleRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int SoundData::getSampleCount() const
|
||||||
|
{
|
||||||
|
return (size/channels)/(bits/8);
|
||||||
|
}
|
||||||
|
|
||||||
int SoundData::getDuration() const
|
int SoundData::getDuration() const
|
||||||
{
|
{
|
||||||
return size/(channels*sampleRate*bits/8);
|
return size/(channels*sampleRate*bits/8);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
virtual int getChannels() const;
|
virtual int getChannels() const;
|
||||||
virtual int getBits() const;
|
virtual int getBits() const;
|
||||||
virtual int getSampleRate() const;
|
virtual int getSampleRate() const;
|
||||||
|
virtual int getSampleCount() const;
|
||||||
|
|
||||||
virtual int getDuration() const;
|
virtual int getDuration() const;
|
||||||
|
|
||||||
|
|||||||
@@ -53,6 +53,13 @@ int w_SoundData_getSampleRate(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int w_SoundData_getSampleCount(lua_State *L)
|
||||||
|
{
|
||||||
|
SoundData *t = luax_checksounddata(L, 1);
|
||||||
|
lua_pushinteger(L, t->getSampleCount());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int w_SoundData_getDuration(lua_State *L)
|
int w_SoundData_getDuration(lua_State *L)
|
||||||
{
|
{
|
||||||
SoundData *t = luax_checksounddata(L, 1);
|
SoundData *t = luax_checksounddata(L, 1);
|
||||||
@@ -87,6 +94,7 @@ static const luaL_Reg functions[] =
|
|||||||
{ "getChannels", w_SoundData_getChannels },
|
{ "getChannels", w_SoundData_getChannels },
|
||||||
{ "getBits", w_SoundData_getBits },
|
{ "getBits", w_SoundData_getBits },
|
||||||
{ "getSampleRate", w_SoundData_getSampleRate },
|
{ "getSampleRate", w_SoundData_getSampleRate },
|
||||||
|
{ "getSampleCount", w_SoundData_getSampleCount },
|
||||||
{ "getDuration", w_SoundData_getDuration },
|
{ "getDuration", w_SoundData_getDuration },
|
||||||
{ "setSample", w_SoundData_setSample },
|
{ "setSample", w_SoundData_setSample },
|
||||||
{ "getSample", w_SoundData_getSample },
|
{ "getSample", w_SoundData_getSample },
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ int w_getSize(lua_State *L);
|
|||||||
int w_getChannels(lua_State *L);
|
int w_getChannels(lua_State *L);
|
||||||
int w_getBits(lua_State *L);
|
int w_getBits(lua_State *L);
|
||||||
int w_getSampleRate(lua_State *L);
|
int w_getSampleRate(lua_State *L);
|
||||||
|
int w_getSampleCount(lua_State *L);
|
||||||
int w_getDuration(lua_State *L);
|
int w_getDuration(lua_State *L);
|
||||||
int w_setSample(lua_State *L);
|
int w_setSample(lua_State *L);
|
||||||
int w_getSample(lua_State *L);
|
int w_getSample(lua_State *L);
|
||||||
|
|||||||
Reference in New Issue
Block a user