From fa799227a241e2e60a518374f2b944615bbc6661 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Tue, 26 Mar 2013 19:45:32 -0300 Subject: [PATCH] Fixed SoundData:getDuration --- src/modules/sound/SoundData.cpp | 4 ++-- src/modules/sound/SoundData.h | 2 +- src/modules/sound/wrap_SoundData.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/modules/sound/SoundData.cpp b/src/modules/sound/SoundData.cpp index f0646f67f..7fb5b4476 100644 --- a/src/modules/sound/SoundData.cpp +++ b/src/modules/sound/SoundData.cpp @@ -147,9 +147,9 @@ int SoundData::getSampleRate() const return sampleRate; } -int SoundData::getDuration() const +float SoundData::getDuration() const { - return size/(channels*sampleRate*bits/8); + return float(size) / (channels*sampleRate*bits/8); } void SoundData::setSample(int i, float sample) diff --git a/src/modules/sound/SoundData.h b/src/modules/sound/SoundData.h index 09a40c60a..aea05e3a1 100644 --- a/src/modules/sound/SoundData.h +++ b/src/modules/sound/SoundData.h @@ -49,7 +49,7 @@ public: virtual int getBits() const; virtual int getSampleRate() const; - virtual int getDuration() const; + virtual float getDuration() const; void setSample(int i, float sample); float getSample(int i) const; diff --git a/src/modules/sound/wrap_SoundData.cpp b/src/modules/sound/wrap_SoundData.cpp index 86693b003..19f65ed8a 100644 --- a/src/modules/sound/wrap_SoundData.cpp +++ b/src/modules/sound/wrap_SoundData.cpp @@ -56,7 +56,7 @@ int w_SoundData_getSampleRate(lua_State *L) int w_SoundData_getDuration(lua_State *L) { SoundData *t = luax_checksounddata(L, 1); - lua_pushinteger(L, t->getDuration()); + lua_pushnumber(L, t->getDuration()); return 1; }