From 409d313bffaefeebe7f64667f68f7b456e959f78 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sun, 14 Jun 2015 18:58:11 -0300 Subject: [PATCH] Added FFI versions of SoundData:getBitDepth and SoundData:getDuration. --- src/modules/sound/wrap_SoundData.lua | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/modules/sound/wrap_SoundData.lua b/src/modules/sound/wrap_SoundData.lua index 8798f1524..5f7991504 100644 --- a/src/modules/sound/wrap_SoundData.lua +++ b/src/modules/sound/wrap_SoundData.lua @@ -44,6 +44,7 @@ local _getBitDepth = SoundData_mt.__index.getBitDepth local _getSampleCount = SoundData_mt.__index.getSampleCount local _getSampleRate = SoundData_mt.__index.getSampleRate local _getChannels = SoundData_mt.__index.getChannels +local _getDuration = SoundData_mt.__index.getDuration -- Table which holds SoundData objects as keys, and information about the objects -- as values. Uses weak keys so the SoundData objects can still be GC'd properly. @@ -61,6 +62,7 @@ local objectcache = setmetatable({}, { samplecount = _getSampleCount(sounddata), samplerate = _getSampleRate(sounddata), channels = _getChannels(sounddata), + duration = _getDuration(sounddata), } self[sounddata] = p @@ -97,19 +99,24 @@ function SoundData_mt.__index:setSample(i, sample) end end +function SoundData_mt.__index:getBitDepth() + return objectcache[self].bytedepth * 8 +end + function SoundData_mt.__index:getSampleCount() - local p = objectcache[self] - return p.samplecount + return objectcache[self].samplecount end function SoundData_mt.__index:getSampleRate() - local p = objectcache[self] - return p.samplerate + return objectcache[self].samplerate end function SoundData_mt.__index:getChannels() - local p = objectcache[self] - return p.channels + return objectcache[self].channels +end + +function SoundData_mt.__index:getDuration() + return objectcache[self].duration end -- DO NOT REMOVE THE NEXT LINE. It is used to load this file as a C++ string.