FBA The Creator
http://www.fbacreator.com/fbaforum/

sound issues...
http://www.fbacreator.com/fbaforum/viewtopic.php?f=5&t=130
Page 1 of 1

Author:  freeko55 [ Thu Dec 04, 2008 1:59 am ]
Post subject:  sound issues...

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...

Author:  evilmaio [ Thu Dec 04, 2008 8:45 am ]
Post subject:  Re: sound issues...

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.

Author:  freeko55 [ Thu Dec 04, 2008 9:46 pm ]
Post subject:  Re: sound issues...

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...

Author:  evilmaio [ Thu Dec 04, 2008 10:59 pm ]
Post subject:  Re: sound issues...

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 :)

Author:  freeko55 [ Fri Dec 05, 2008 7:51 pm ]
Post subject:  Re: sound issues...

ill have to try...

Author:  freeko55 [ Fri Dec 05, 2008 7:53 pm ]
Post subject:  Re: sound issues...

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

Author:  evilmaio [ Sun Dec 07, 2008 6:22 pm ]
Post subject:  Re: sound issues...

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

Author:  freeko55 [ Sun Dec 07, 2008 11:26 pm ]
Post subject:  Re: sound issues...

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

Author:  evilmaio [ Mon Dec 08, 2008 8:09 pm ]
Post subject:  Re: sound issues...

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
:)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/