It looks like you're new here. If you want to get involved, click one of these buttons!
function showFPS() local frame = 0 local timer = os.timer() local qFloor = math.floor local fps = TextField.new(nil, "") fps:setPosition(40, 20) fps:setTextColor(0xFF0000) fps:setScale(1.2) local function displayFps(event) frame = frame + 1 if frame == 60 then local currentTimer = os.timer() fps:setText("fps: "..qFloor(60 / (currentTimer - timer)) .. " MemUsage: " .. math.ceil(collectgarbage("count")) .. " Kb " .. " TextureUsage: " .. math.ceil(application:getTextureMemoryUsage()) .. " Kb") frame = 0 timer = currentTimer end end stage:addChild(fps) stage:addEventListener(Event.ENTER_FRAME, displayFps) end local sound = Sound.new("wing.wav") local handler = function() sound:play(0, false, false) end local timer = Timer.new(200, 0) timer:addEventListener(Event.TIMER, handler) timer:start() showFPS() |
Comments
Likes: Yan, MoKaLux
https://github.com/gideros/gideros/blob/5978063083e46218eaad83c7f04332ca4311b6aa/luabinding/audiobinder.cpp#L576
Object is created, but never destroyed.
If you call "collectgarbage()" right after "sound:play" there is no leaks
Likes: MoKaLux, Yan
But you don't need to call collectgarbage at all yourself, lua will do it internally. But if you query the memory usage, you should call collectgarbage before to avoid being misled by not yet collected data.
Likes: Yan
Likes: MoKaLux
As Gideros uses OpenAL
Most hardware based OpenAL drivers only support as many sources as the hardware has channels. Modernly that is at least 16, probably 32 or more but can be as much as 256. There are probably sound cards that support more but 256 is the largest I've ever looked at.
Likes: hito9
From reference:
Regarding the performance, you should use .wav files for sound effects and .mp3 for background music. Here are the advantages and disadvantages of these:
WAV files: Entire sound is loaded into memory. Consumes little CPU while playing. Suitable for simultaneously played sound effects.
MP3 files: Sound is played by reading small chunks, therefore, consumes little memory. Consumes more CPU compared to WAV files. Suitable for background music/speech.
Likes: hito9
Likes: hito9