barsoosayque / libgdx-oboe

🎶 libGDX audio replacement for Android (API 16+) built on top of Oboe.
MIT License
54 stars 10 forks source link

Crackling popping #5

Open DunDun69 opened 4 years ago

DunDun69 commented 4 years ago

First, I would like to thank you for creating this library! The setup was smooth and documentation is great.

However, I'm experiencing constant crackling popping / noise in my game after switching to oboe. This becomes very noticeable when a sound effect starts or ends with a fade in/out effect while having another sound running on a loop in the background. The issue is not very noticeable when playing one sound from absolute silence.

I'm using a mix of mp3 and wav sounds on a OnePlus 5T Android version 9.0.11

Unfortunately I can't point out the source of the issue... I'm not even sure if this is an issue related to this library or oboe. My only suggestion is to upgrade oboe to the latest version? I've seen similar issues on their repo and maybe its fixed 🤷‍♂️ https://github.com/google/oboe/issues/286 https://github.com/google/oboe/issues/564

barsoosayque commented 4 years ago

Oh, thanks for the report.

Let's see: this shouldn't be a format problem, so you're right, it's either this library or oboe. There is one problematic spot in libgdx-oboe code base that I am aware of that can produce such crackling (and it's when you pause entire audio stream). So I hope that crackling was fixed in the upstream library and I just have to update it :smile: .

I have to setup android environment on my pc again, it might take awhile, hopefully I will be able to work on this issue later this week.

barsoosayque commented 3 years ago

Can you try 0.2.3 version and see if it works or nah ?

DunDun69 commented 3 years ago

Unfortunately it didn't work 😞 But I've made a quick audio recording for my game with and without libgdx-oboe, maybe that helps identifying the issue...

With libgdx-oboe (0.2.3): https://www.mboxdrive.com/with-oboe.mp3 Without libgdx-oboe (default libgdx android audio backend): https://www.mboxdrive.com/without-oboe.mp3 Note: The sound quality is not great, but you should still hear more background cracking noise on the oboe version compared to default android audio.

Appreciate your time looking into this though! If you need any information that might help you, please let me know!

barsoosayque commented 3 years ago

If you need any information that might help you, please let me know!

Quick thought, a common reason for cracking sound in my experience was a buffer underrun (when there is not enough demuxed data to feed the oboe audio stream), which should be logged. So that would be great if you can show me catlog at the moment when you have such audio errors.

But I doubt that, because crackling on the recording you've provided doesn't sound like a buffer underrun to me. Though, I'd be glad to be wrong here.

DunDun69 commented 3 years ago

Here is my full logcat output for both Oboe and default android backend (SoundPool). I ran through the same in game journey to try and avoid necessary logs and keep them as short as possible.

Logcat with Oboe: https://pastebin.com/jtPTHnmu Logcat with SoundPool (default): https://pastebin.com/gN6HGsQi

barsoosayque commented 3 years ago

Can you post ffmpeg -i %your_file% ? Or, at least, confirm that you are using 44100 Hz audio (in Audacity or anything else) ?

DunDun69 commented 3 years ago

I receive the game audio files from a friend who is also working with me on the game, so I am not sure if they share anything in common (e.g. frequency, software used.. etc).

But here are the ffmpeg -i results for some of the audio files used (specifically in this test)

Input #0, mp3, from 'grenade-throw.mp3': Duration: 00:00:00.47, start: 0.025057, bitrate: 158 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, fltp, 158 kb/s Metadata: encoder : LAME3.99r

Input #0, mp3, from 'grenade-count-down.mp3': Duration: 00:00:00.36, start: 0.034531, bitrate: 102 kb/s Stream #0:0: Audio: mp3, 32000 Hz, mono, fltp, 102 kb/s Metadata: encoder : LAME3.99r

Input #0, mp3, from 'grenade-detonation.mp3': Duration: 00:00:02.42, start: 0.023021, bitrate: 155 kb/s Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 155 kb/s Metadata: encoder : LAME3.99r

Input #0, wav, from 'mall-background.wav': Duration: 00:00:04.34, bitrate: 1024 kb/s Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 32000 Hz, stereo, s16, 1024 kb/s

Also, I've asked a friend to test my game with libgdx-oboe and it seems to be working fine... He's using a Samsun Galaxy Note 8 (Android 8). No idea whats causing this issue on my OnePlus 5T, but I don't think its the audio files if it works ok on another phone? 🤷‍♂️

barsoosayque commented 3 years ago

What Android are you running ? Because Oboe has different implementation based on the actual device API.

Also, can you try to normalize sample rate of your audio files to 44100 Hz ? You can use ffmpeg -i grenade-count-down.mp3 -ar 44100 grenade-count-down.mp3 for example.

DunDun69 commented 3 years ago

What Android are you running ? Because Oboe has different implementation based on the actual device API.

I'm running Android 9.0.11 (not rooted)

Also, can you try to normalize sample rate of your audio files to 44100 Hz ?

I've just normalized the files I sent before (and few more) to 44100 Hz, made sure that only these files are played during the game, but it did not make a difference. The crackling noise can still be heard with the frequency normalized.

barsoosayque commented 3 years ago

Alright, so the last thing worth trying is to test out oboe example apps to see if it's oboe or it's something within this library. I assume you have the tools to build them, if not, feel free to ask for apks !