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

General volume is lower than on the default libGDX implementation. #18

Open
metaphore opened this issue Jan 8, 2023 · 4 comments
Open
Assignees

Comments

@metaphore
Copy link

I noticed that if I disable Oboe in my project (comment createAudio() method in the AndroidApplication class) the overall audio volume gets much louder (feels like twice as loud).

I couldn't find any master volume parameter in Oboe classes. Is it possible that the master volume is locked to 0.5 by default somewhere down deep in the native code?

@barsoosayque barsoosayque self-assigned this Jan 9, 2023
@barsoosayque
Copy link
Owner

I tested this on music example and on my device there is no difference (or possibly I don't hear very well 😢). AFAIR there is nothing in Oboe itself that would create such effect, although there is an option that can indirectly cause that. On some android APIs there are different settings of audio volume per "usage group", and in libgdx-oboe, the usage group is Game (oboe_engine.cpp:52). Perhaps in the default implementation it's different and that is what causing the volume to be different as well, though, I'm really not sure about that.

As a workaround, I can implement a master volume just for OboeAudio, it's a rather easy thing to do, definitely much easier than going into the android audio stack rabbit hole once more.

@metaphore
Copy link
Author

metaphore commented Jan 9, 2023

A good point about the audio attributes!
But I can see that the default Android audio implementation uses USAGE_GAME either.

Audio attributes for the sound pool (all game sounds use it):

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
	AudioAttributes audioAttrib = new AudioAttributes.Builder()
		.setUsage(AudioAttributes.USAGE_GAME)
		.setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION)
		.build();
	soundPool = new SoundPool.Builder()
		.setAudioAttributes(audioAttrib)
		.setMaxStreams(config.maxSimultaneousSounds)
		.build();
} else {
	soundPool = new SoundPool(config.maxSimultaneousSounds, AudioManager.STREAM_MUSIC, 0); // srcQuality: the sample-rate
											       // converter quality. Currently
											       // has no effect. Use 0 for the
											       // default.
}
manager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
if (context instanceof Activity) {
	((Activity)context).setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

Music instance creation:

protected MediaPlayer createMediaPlayer () {
    MediaPlayer mediaPlayer = new MediaPlayer();
    if (Build.VERSION.SDK_INT <= 21) {
	mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
    } else {
	mediaPlayer.setAudioAttributes(new AudioAttributes.Builder()
		.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
		.setUsage(AudioAttributes.USAGE_GAME).build());
    }
    return mediaPlayer;
}

I checked again the game with and without Oboe on my Pixel 3 (Android 12). I can't spot any difference in the sound slider or in the sound settings menu. It always changes the volume under the "Media volume" slider. And the perceived output volume is dramatically different under the same system's "Media volume" value for both sound effects and music.

@barsoosayque
Copy link
Owner

Oh. My thoughts on that is because I don't hear any difference on my device, it must be device specific, hence this issue is something with google/oboe (either AAudio implementation or oboe wrapper itself). I didn't test extensively though, so I hope I can test a little bit more and actually find a repro and fix this, though, I haven't worked with neither android nor audio in a while, it will take some time. If you have time and dedication to test this further (I know I don't, but I'll try when I can), there is OboeTester app (part of google/oboe repo), it supposed to tell you if your device has audio glitches; you might want to try that to see if there any anomalies like the audio volume in this particular issue.

@metaphore
Copy link
Author

I think you're right about the device-specific nature of the case. I couldn't find any similar reports about Oboe anywhere and it doesn't seem like any of the emulators share the same problem.

However, I have two Pixel 3 phones and they both have lower output volume with libgdx-oboe.

Anyway, it's not nearly a critical bug and it doesn't worth any more time spent investigating it. I'd suggest just keeping this issue open till there are more details available. Hopefully, someone else will notice the same behavior sometime soon.

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