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:49 am

All times are UTC




Post new topic  Reply to topic  [ 9 posts ] 
Author Message
 Post subject: sound issues...
PostPosted: Thu Dec 04, 2008 1:59 am 
Offline

Joined: Mon Aug 25, 2008 2:17 am
Posts: 17
i have where it plays sound but i want to make it so that when i hold it down it keeps playing... this is what i have...



if numkeypress( 81 ) > 1 then playsound(0)
end
if numkeypress( 81 ) == 0 then stopsound(0)
end

but when i hold it down it sounds horrible and distorted...


Top
   
 Post subject: Re: sound issues...
PostPosted: Thu Dec 04, 2008 8:45 am 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
Quote:
Code:
if numkeypress( 81 ) > 1 then playsound(0)
end
if numkeypress( 81 ) == 0 then stopsound(0)
end


but when i hold it down it sounds horrible and distorted...


You should post more code in order to know what is going wrong, although I think your code is trying to play same sound a lot of time; try subst
if numkeypress( 81 ) > 1 then playsound(0)
with
if numkeypress( 81 ) == 1 then playsound(0)

Or anyway, be sure to play it just once :)

Regards.


Top
   
 Post subject: Re: sound issues...
PostPosted: Thu Dec 04, 2008 9:46 pm 
Offline

Joined: Mon Aug 25, 2008 2:17 am
Posts: 17
i want it to loop without heaving it start over (its an instrument sound), i want it so when i hold it down it loops but u cant hear the break in between each sound... and when i press it quick it should stop when i let up...


Top
   
 Post subject: Re: sound issues...
PostPosted: Thu Dec 04, 2008 10:59 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
I didn't understand...

can't you use the sound loop function provided by FBA?

playsound(0, true)

(true = play in loop)

The way you're building your code, won't work :)


Top
   
 Post subject: Re: sound issues...
PostPosted: Fri Dec 05, 2008 7:51 pm 
Offline

Joined: Mon Aug 25, 2008 2:17 am
Posts: 17
ill have to try...


Top
   
 Post subject: Re: sound issues...
PostPosted: Fri Dec 05, 2008 7:53 pm 
Offline

Joined: Mon Aug 25, 2008 2:17 am
Posts: 17
i just did it so that when i pressed the button it played the sound exp...


if numkeypress( 81 ) > 0 then playsound(0)
end

if numkeypress( 81 ) == 0 then stopsound(0)
end


Top
   
 Post subject: Re: sound issues...
PostPosted: Sun Dec 07, 2008 6:22 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
freeko55 wrote:
i just did it so that when i pressed the button it played the sound exp...


if numkeypress( 81 ) > 0 then playsound(0)
end

if numkeypress( 81 ) == 0 then stopsound(0)
end


I don't know the rest of your code, but if you put

Quote:
if numkeypress( 81 ) > 0 then playsound(0)
end


It will be continuosly played when you press the key..

Please post your full code


Top
   
 Post subject: Re: sound issues...
PostPosted: Sun Dec 07, 2008 11:26 pm 
Offline

Joined: Mon Aug 25, 2008 2:17 am
Posts: 17
loadsound(0, "1.wav")
loadsound(10, "2#.wav")
loadsound(9, "3.wav")
loadsound(11, "4.wav")
loadsound(1, "5#.wav")
loadsound(3, "6#.wav")
loadsound(2, "7.wav")
loadsound(4, "8.wav")
loadsound(6, "9#.wav")
loadsound(5, "10.wav")
loadsound(8, "11#.wav")
loadsound(7, "12.wav")
loadsound(12, "13.wav")

loadsound(22, "1.wav")
loadsound(23, "2.wav")
loadsound(24, "3.wav")
loadsound(25, "4.wav")
loadsound(26, "5.wav")
loadsound(27, "6.wav")

loadsound(13, "1.wav")
loadsound(14, "2.wav")
loadsound(15, "3.wav")
loadsound(16, "5.wav")
loadsound(17, "4.wav")
loadsound(18, "6.wav")
loadsound(19, "7.wav")

loadsound(20, "claps001.wav")
-- Drumloop --
loadsound(21, "breakbeat025.wav")
-- Now for background image --
loadimage(0,"background.jpg" )





local last_key = 0


function onmainloop()


clear(0,0,0)



drawimage(0,0,0)













if numkeypress( 81 ) > 0 then playsound(0, true)
end
if numkeypress( 81 ) < 1 then stopsound(0) playing = false
end

if numkeypress( 87 ) > 0 then playsound(1, true)
end
if numkeypress( 87 ) == 0 then stopsound(1)
end

if numkeypress( 69 ) > 0 then playsound(2, true)
end
if numkeypress( 69 ) == 0 then stopsound(2)
end

if numkeypress( 82 ) > 0 then playsound(3, true)
end
if numkeypress( 82 ) == 0 then stopsound(3)
end

if numkeypress( 84 ) > 0 then playsound(4, true)
end
if numkeypress( 84 ) == 0 then stopsound(4)
end

if numkeypress( 89 ) > 0 then playsound(5, true)
end
if numkeypress( 89 ) == 0 then stopsound(5)
end

if numkeypress( 85 ) > 0 then playsound(6, true)
end
if numkeypress( 85 ) == 0 then stopsound(6)
end

if numkeypress( 73 ) > 0 then playsound(7, true)
end
if numkeypress( 73 ) == 0 then stopsound(7)
end

if numkeypress( 79 ) > 0 then playsound(8, true)
end
if numkeypress( 79 ) == 0 then stopsound(8)
end

if numkeypress( 80 ) > 0 then playsound(9, true)
end
if numkeypress( 80 ) == 0 then stopsound(9)
end

if numkeypress( 65 ) > 0 then playsound(10, true)
end
if numkeypress( 65 ) == 0 then stopsound(10)
end

if numkeypress( 83 ) > 0 then playsound(11, true)
end
if numkeypress( 83 ) == 0 then stopsound(11)
end

if numkeypress( 68 ) > 0 then playsound(12, true)
end
if numkeypress( 68 ) == 0 then stopsound(12)
end




if numkeypress( 90 ) == 1 then
playsound(13)
end

if numkeypress( 88 ) == 1 then
playsound(14)
end

if numkeypress( 67 ) == 1 then
playsound(15)
end

if numkeypress( 86 ) == 1 then
playsound(16)
end

if numkeypress( 66 ) == 1 then
playsound(17)
end

if numkeypress( 78 ) == 1 then
playsound(18)
end

if numkeypress( 77 ) == 1 then
playsound(19)
end



if numkeypress( 32 ) == 1 then
playsound(20)
end



if numkeypress( 38 ) == 1 then
playsound(21)
end



if numkeypress( 70 ) == 1 then
playsound(22)
end

if numkeypress( 71 ) == 1 then
playsound(23)
end

if numkeypress( 72 ) == 1 then
playsound(24)
end

if numkeypress( 74 ) == 1 then
playsound(25)
end

if numkeypress( 75 ) == 1 then
playsound(26)
end

if numkeypress( 76 ) == 1 then
playsound(27)
end

if numkeypress( 13 ) == 1 then
playsound(28)
end



if numkeypress( 40 ) == 1 then
quit()
end





function onbuttondown(key)
last_key = key
end
end


Top
   
 Post subject: Re: sound issues...
PostPosted: Mon Dec 08, 2008 8:09 pm 
Offline
FBA Administrator
FBA Administrator
User avatar

Joined: Fri Mar 21, 2008 11:19 pm
Posts: 238
Location: Rome - Italy
Ok, as I thought..calling playsound in that way is not correct.
FBA will start a new sound playing at every game step (that's why you hear that horrible sound).
Be sure to play the sound just one time, eg:
if numkeypress(x) = 1 then playsound(etc etc
:)


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 0 guests


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