FBA The Creator

The True Multiplatform PC / PocketPC Opensource Development Tool - Read Only Mode - Kept only for historical purposes - Thank you all ;)
It is currently Thu Jun 04, 2026 3:50 am

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Aug 31, 2009 3:22 pm 
Offline

Joined: Mon Aug 31, 2009 2:59 pm
Posts: 2
This is my first post here, so I'd like to give a huge thanks to the FBA Team! :D

I've made a very simple drum kit for my HTC Touch Pro Pocket PC. My idea is to tap on the different drums on the screen to play the matching sounds. It works snappy on Windows XP Pro but the Pocket PC version has too much latency or delay between the tap and the sound. It is high enough that the application really is unusable.

I've used 8 bit mono WAV files. I've tried running the program after a restart with all extra running programs (e.g. Manila) closed but it doesn't make any noticeable difference. Does anyone have suggestions on how to tune and optimize this so that the application will respond very quickly? Here is the code:

Code:
local background = loadimage("Image.png")
local hat = loadsound("Hat_8b_mono.wav")
local kick = loadsound("Kick_8b_mono.wav")
local snare = loadsound("Snare_8b_mono.wav")

function onmainloop()
  if getnumiterations() < 1 then -- First loop
    drawimage(background, 0, 0) -- Draw background image, with drum pictures and close button
  end

  -- Handle mousedown
  if mousedown() == 1 then
    if mousex() >= screenwidth() - 30 and mousey() >= 0 and mousex() <= screenwidth() and mousey() <= 29 then -- Clicked close button area
      quit() -- Close application
    elseif mousex() >= 18 and mousey() >= 158 and mousex() <= 250 and mousey() <= 275 then -- Clicked hat area
      playsound(hat) -- Play hat sound clip
    elseif mousex() >= 227 and mousey() >= 295 and mousex() <= 427 and mousey() <= 464 then -- Clicked kick area
      playsound(kick) -- Play kick sound clip
    elseif mousex() >= 440 and mousey() >= 173 and mousex() <= 629 and mousey() <= 346 then -- Clicked snare area
      playsound(snare) -- Play snare sound clip
    end
  end
end


Top
   
PostPosted: Tue Sep 01, 2009 8:33 am 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
You could try moving your input logic inside mouse events instead of gameloop


Top
   
PostPosted: Fri Sep 04, 2009 1:50 pm 
Offline

Joined: Mon Aug 31, 2009 2:59 pm
Posts: 2
Thanks for the reply! Since my original post I've tried a couple variations. Is this what you meant?

Code:
local background = loadimage("Image.png")
local hat = loadsound("Hat_8b_mono.wav")
local kick = loadsound("Kick_8b_mono.wav")
local snare = loadsound("Snare_8b_mono.wav")

function onmainloop()
  if getnumiterations() < 1 then -- First loop
    drawimage(background, 0, 0) -- Draw background
  end
end

function onstylusdown(x, y)
  if x >= screenwidth() - 30 and y >= 0 and x <= screenwidth() and y <= 29 then -- Clicked in close button area
    quit() -- Close application
  elseif x >= 18 and y >= 158 and x <= 250 and y <= 275 then -- Clicked in hat area
    playsound(hat) -- Play hat sound clip
  elseif x >= 227 and y>= 295 and x <= 427 and y<= 464 then -- Clicked in kick area
    playsound(kick) -- Play kick sound clip
  elseif x >= 440 and y >= 173 and x <= 629 and y <= 346 then -- Clicked in snare area
    playsound(snare) -- Play snare sound clip
  end
end


This performs with the same delay between the tap and playback. I tried using print() to output which drum had been hit and it appears to update very quickly, without the delay that is apparent with playsound(). So I tend to think the delay is due to the sound, not the input. But I'd have to test further to confirm that.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Limited