Skip to content

Allow PlaySound to play on its own thread to avoid sound-stutter #26

@Psy-Labs

Description

@Psy-Labs

If you export to Android, any sounds played with PlaySound() cause stuttering, frame drops and broken sounds.

If I export the following code to Android OR broadcast it to my phone, the app stutters as soon as the sound is played.
The faster I tap the screen, the more it stutters. At some point, the sound even breaks.
This is only the case for Android, not for Windows.
I tried different phones, different sounds, different .wav formats and .ogg files...makes no difference.
I also tried Studio and Classic.

CODE:

SetErrorMode				( 0 )
SetWindowSize			( 1024, 768, 0 )
SetOrientationAllowed	( 0, 0, 1, 1 )
SetSyncRate				( 60, 0 )
UseNewDefaultFonts		( 1 )
SetPrintSize 			( 20 )
SetImmersiveMode ( 1 )
sound 	= LoadSound ( "sound.wav" )
gfx 	= Loadimage ( "agk.png" )
sprite 	= CreateSprite ( gfx )
SetSpriteSize ( sprite, 10, -1 )

local x as float
local y as float
local angle as float

repeat
    Print( trunc ( ScreenFPS() ) )
    angle = fmod ( angle + 1.0, 360.0 )
	x = 50.0 + cos ( angle ) * 20.0
	y = 50.0 + sin ( angle ) * 20.0
	SetSpritePositionByOffset ( sprite, x, y )
    if GetPointerPressed() then PlaySound ( sound, 100, 0, 1 )
    Sync()
until GetRawKeyPressed ( 27 )
END

A ZIP file including code and media is attached.
_soundbug.zip

PSY

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions