Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repetitive sound not playing randomly #8

Closed
matejthetree opened this issue Apr 15, 2018 · 6 comments
Closed

repetitive sound not playing randomly #8

matejthetree opened this issue Apr 15, 2018 · 6 comments

Comments

@matejthetree
Copy link

Hello,

I have been using Audio file from flame to play sounds.

Now, the issue I get is that the file sometimes get played and sometimes it doesnt.

I even tried to create one instance of AudioPlayer, to see if the issue is in multiple creation of AudioPlayer or async checking of cache. Same problem.

Every 0.5 Second I play one .wav file, just a FX tick. Same error with .m4a
metronome.wav.zip

player.play(_audio.loadedFiles["metronome.m4a"].path, isLocal: true);

And on emulator first second and fourth tick stop working and later it works with ocasional skip.
On old android phone almost every second tick doesnt work.

When audio file gets skipped, I get no message in console, and when it does play I get
D/MediaPlayer(10220): setSubtitleAnchor in MediaPlayer

Can you point me in the direction where should I be looking for?

Thank you

@luanpotter
Copy link
Member

Hi, @matejthetree! Thanks for your feedback :)

This is an interesting problem, probably with the audioplayers lib.

What version of flame/audioplayers are you using? On version 0.5.0 of the latter, there was a big refactoring (theoretically improving performance); maybe check out versions 0.4.1 and 0.5.0 and see if the problem persists, or which one performs better?

Indeed I hadn't tested firing sounds that quickly. What I suspect is happening is that the audioplayer is failing to update in 500 ms. and the second call overwrites the first. One workaround might be to create a couple of instances and alternate then (fire one every second or so). If it works, it might give us more insight on what's the problem and how to fix it.

I will try to perform these tests myself soon, but right now I'm a bit overwhelmed with other activities.

@matejthetree
Copy link
Author

matejthetree commented Apr 18, 2018 via email

@matejthetree
Copy link
Author

I got some time, so I will try now.

As I remember, your lib was creating new instance of audio player when used directly from Flame, so we can rule that one out.

I will check now 0.4.1, and I will compare iOS and Android versions.

@matejthetree
Copy link
Author

Ok, I made a mistake :)

So creating new Audioplayer each time works.
The sound plays now every time.

Now just to sort out some performance issues. Sound playing is lagging, and I am making metronome. The first time it is played it lagging and then later now and then it lags again. I wonder why playing sounds perform so bad? It should be basic stuff to play audio :)

I think we can close this issue. I report back after I profile the app to see what exactly is clogging it.
I even tried to disable the UI completly, still the framerate drops.

@luanpotter
Copy link
Member

It works, but it's not ideal; it should work with the same instance. So I'll try to take a look at this on audioplayers to see if there is a performance hit or concurrence problem of some sort.

The first time it takes longer because it has to load the audio; you can pre-load the audios beforehand, as per instructed here. The others occasional lag spikes are a problem though, and it might be because of audioplayers being slow or because other stuff you might be doing in your game.

I will close this and then open an issue on audiplayers to see about the performance of using audioplayers (one or many instances) too quickly.

Thank you so much for your help!

@matejthetree
Copy link
Author

matejthetree commented Apr 27, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants