Posted: 17th Nov 2023 15:38
The quack repeats, and when I press the mouse again, another repeating duck joins in. Hooray, I made a duck choir sim. But really, why?

+ Code Snippet
SetErrorMode(2)
SetWindowTitle( "Fun" )
SetWindowSize( 640, 640, 0 )
SetWindowAllowResize( 0 )
SetSyncRate( 60, 0 )
UseNewDefaultFonts( 1 )

REM Load resources
Ducksnd = LoadSound("ANIMAL_Duck_10_mono.wav")

do
    if GetRawMouseLeftPressed() = 1
		PlaySound(Ducksnd,100,1,0)
		print("played")
	endif
    Sync()
loop
Posted: 17th Nov 2023 15:53
How many times does it repeat.

Does the sound wave genuinely have 1 quack in the file.

Edit

Please try

GetRawMouseLeftReleased

Instead
Posted: 17th Nov 2023 16:04
Yep, one single geniue quack. No clue why it repeats.

Edit: GetRawMouseLeftReleased didn't help any
Posted: 17th Nov 2023 16:05
Please try

GetRawMouseLeftReleased

Instead

Returns 1 when released

Edit

On your playsound you have a 1 on your loop argument

+ Code Snippet
Playsound ( duvksound, 100, 0, 0)
Posted: 17th Nov 2023 16:12
Thanks, nicely spotted! I guess I got the parameters messed up.
Posted: 17th Nov 2023 23:36
Why does the quack sound repeat


Because you told it to repeat lol
Posted: 18th Nov 2023 15:13
Duck choir lol too funny

In the most simple terms you can use this:
+ Code Snippet
if (GetSoundsPlaying(Ducksnd ) = 0)  then  PlaySound(Ducksnd , 0)



What you may want to look at here is using the instance of the sound. Every time you run PlaySound() it is making an instance of that sound and is returning a reference that instance with a unique ID.
+ Code Snippet
SetErrorMode(2)
SetWindowTitle( "Fun" )
SetWindowSize( 640, 640, 0 )
SetWindowAllowResize( 0 )
SetSyncRate( 60, 0 )
UseNewDefaultFonts( 1 )
 
REM Load resources

Ducksnd = LoadSound("ANIMAL_Duck_10_mono.wav")
 
do
    if GetRawMouseLeftPressed() = 1
        if (GetSountInstancePlaying(DuckInstance) = 0)
           DuckInstance = PlaySound(Ducksnd,100,1,0)
            print("played")
        endif
    endif
    Sync()
loop


With a reference to the sound instance you can now set all kinds of fun things like SetSoundInstanceBalance(DuckInstance, -1.0) to put it in the left channel or SetSoundInstanceBalance(DuckInstance, 1.0) for the right channel. Set that particular instance's volume with SetSoundInstanceVolume(). And for even more fun try playing with SetSoundInstanceRate() to change the pitch and add your own doppler affect if the duck is flying by you.