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

cellAudio: Fix audio channel order #11066

Merged
merged 1 commit into from Oct 27, 2021
Merged

cellAudio: Fix audio channel order #11066

merged 1 commit into from Oct 27, 2021

Conversation

capriots
Copy link
Contributor

Documentation says samples have the order Front L, Front R, Center, LFE, Surround L, Surround R, Rear L, Rear R

Fixes #5818

Documentation says the order is Front L, Front R, Center, LFE, Surround L, Surround R, Rear L, Rear R
@Nekotekina Nekotekina merged commit ac300c7 into RPCS3:master Oct 27, 2021
@Megamouse
Copy link
Contributor

This pull request seems incomplete.
The buffers apply to all audio backends, but i haven't seen any adjustments there.

@Megamouse
Copy link
Contributor

The following code might be correct.
Just seems weird to swap the buffer positions like that.

@capriots
Copy link
Contributor Author

capriots commented Oct 27, 2021

The PCM samples games put into the buffer definitely have the order I specified above, so the names should stay like this. out_buffer names should be swapped too if you don't like my solution.
Swapping the channels universally in cellAudio seemed like the best solution since pretty much everywhere else the rear channels come first.

Xaudio2's default channel order is L, R, C, LFE, RL, RR, SL, SR (https://docs.microsoft.com/en-us/windows/win32/xaudio2/xaudio2-default-channel-mapping)

Same with OpenAL (page 141: https://www.openal.org/documentation/OpenAL_Programmers_Guide.pdf)

For PulseAudio the same order is manually specified

pa_channel_map channel_map;
if (m_channels == 2)
{
channel_map.channels = 2;
channel_map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
channel_map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
}
else if (m_channels == 6)
{
channel_map.channels = 6;
channel_map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
channel_map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
channel_map.map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
channel_map.map[3] = PA_CHANNEL_POSITION_LFE;
channel_map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT;
channel_map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT;
}
else
{
channel_map.channels = 8;
channel_map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT;
channel_map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT;
channel_map.map[2] = PA_CHANNEL_POSITION_FRONT_CENTER;
channel_map.map[3] = PA_CHANNEL_POSITION_LFE;
channel_map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT;
channel_map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT;
channel_map.map[6] = PA_CHANNEL_POSITION_SIDE_LEFT;
channel_map.map[7] = PA_CHANNEL_POSITION_SIDE_RIGHT;
}
ss.channels = channel_map.channels;

No clue about ALSA but the output was wrong there too.

I guess you could do the swapping in the backends instead, there seems to be manual channel mapping support in all of them.

@Megamouse
Copy link
Contributor

The thing is, I wrote some of that code and I couldn't believe that the channels were swapped.
But i remember now that rear channels usually come first.
I also remember that the PS3 does it differently.
I could've sworn I had them ordered properly back then.
Maybe I didn't want to change them unless proven wrong.

Anyway, good job finding the issue (maybe they were typos).
I'll take a look later and confirm again just to be sure.
Haven't had time to look at the code so far.

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

Successfully merging this pull request may close these issues.

Swapped 7.1 Surround Speakers in Wipeout HD (Maybe other Games too)
3 participants