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

PCM Audio not properly stereo with LWJGL3 backend #6526

Closed
5 tasks
hujasonx opened this issue May 8, 2021 · 1 comment
Closed
5 tasks

PCM Audio not properly stereo with LWJGL3 backend #6526

hujasonx opened this issue May 8, 2021 · 1 comment
Assignees

Comments

@hujasonx
Copy link

hujasonx commented May 8, 2021

Issue details

PCM audio played via Gdx.audio.newAudioDevice does not properly play stereo content with the LWJGL3 backend, but does with the default desktop backend. It's not fully mono but it isn't stereo to the correct extent either.

Reproduction steps/code

public class Test extends ApplicationAdapter {
	AudioDevice audioDevice;
	float deviceSamples[] = new float[1024];
	float x = 0;
	@Override
	public void create () {
		audioDevice = Gdx.audio.newAudioDevice(44100, false);
	}

	@Override
	public void render () {
		new Thread() {
			@Override
			public void run() {
				while (true) {
					try {
						for (int a = 0; a < 1024; a += 2) {
							float sample = .2f * (float) Math.sin(x);
							x += 0.0005;
							deviceSamples[a] = 0; // Left speaker should be silent.
							deviceSamples[a + 1] = sample; // Right speaker should make noise.
						}

						audioDevice.writeSamples(deviceSamples, 0, deviceSamples.length);
						int latency = audioDevice.getLatency();
						sleep(500 * latency / 44100);
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			}
		}.start();
	}
}

Expectation: Sound only comes out of the right speaker.
Reality: Sound comes mostly out of the right speaker, but also somewhat from the left. It works fine when using the default lwjgl2 backend, but not with the lwjgl3 backend.

Version of LibGDX and/or relevant dependencies

libgdx 1.10.0

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • [ X] Windows
  • Linux
  • MacOS
@mgsx-dev
Copy link
Contributor

mgsx-dev commented May 8, 2021

i can reproduce the issue, i'm working on a fix.

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

No branches or pull requests

2 participants