devkitPro / libogc

C Library for Wii and Gamecube homebrew
https://devkitpro.org/viewforum.php?f=40
Other
283 stars 69 forks source link

Stereo audio output plays with swapped channels #169

Closed Wohlstand closed 5 months ago

Wohlstand commented 5 months ago

Bug Report

What's the issue you encountered?

Sound stream running via OGC Audio plays with a swapped stereo on Dolphin as well as on real hardware. First time I was though I wrongly plugged my component cables, but all was plugged correctly. After some investigations, I found it's a bug of the OGC itself.

How can the issue be reproduced?

Just run this example (I replaced the sample.ogg with my file): oggplayer-stereo-test.tar.gz

The example file sample.ogg plays long Beep in every ear. It should play first Beep in left ear. But it plays it at right ear. And second Beep should be played at Right ear, but actually plays at left ear.

Environment?

Linux.

Trivia

Long time I did ran my hardware just by TV speakers, but once upon I decited to use hearphones to don't make hard noise and listen in-game stuff accurately. And, once I ran one of my testing stuff, I found the problem of the swapped stereo.

DacoTaco commented 5 months ago

Hey @Wohlstand !

thanks for the fix! sorry it took a while to merge. been a bit busy and was wondering where the content that is put into the regs came from. however, it looks ok so i merged it :)

thanks again!

Wohlstand commented 5 months ago

thanks for the fix! sorry it took a while to merge. been a bit busy and was wondering where the content that is put into the regs came from. however, it looks ok so i merged it :)

No problem :)

Typically, the order of samples in the stream is always Left-Right-Left-Right-...

But I see the libaesnd has correct stereo layout at the same time.

DacoTaco commented 5 months ago

if libaesnd is loading it in the right order then ye, this would have been the correct fix :) good job!

Wohlstand commented 5 months ago

Actually, I found the problem when I ran my own game, and I found that positioned sound effects sounds swapped (when source of noice appears at left side, the sound appears at right ear, and oppositely. Then I checked trice on various hardware and on Dolphin, I though that was MY bug in my SDL2 fork, and at final, I figured bug is here, at libogc, because even simple demos plays the stereo swapped).

(Off topic: About that fork of SDL2 I did, that was my independent attempt to make Wii port of SDL2, but then I found you did that unexpectedly and much faster than me! That's super! My idea was making the contribution to the mainstream SDL2, but, if you don't object, I could take your changes into my thing and then submit).

DacoTaco commented 5 months ago

@Wohlstand : @mardy is indeed currently porting SDL2 and we are trying to make it work perfectly with the other platforms/api's we support at the same time and adjust those when we change platform api's. its easier for us to manage at this moment because of that too hehe so no, at time moment there is no plans (yet?) to upstream any of our port changes, unless they actually fix any SDL bugs or if SDL changes are needed :)

Pokechu22 commented 5 months ago

Note that the very first version of libaesnd (from 2010) also had swapped stereo channels, but this was fixed in 2012 (see 8f188e12b6a3d8b5a0d49a109fe6a3e4e1702aab). While implementing libasnd and libaesnd in dolphin, I noticed and handled the libaesnd change, but I guess I never noticed it for libasnd since the sample MP3 file there is mono. I'll look into implementing the new version of the ucode in Dolphin and also make sure all of the old versions match this weekend.

DacoTaco commented 5 months ago

@Pokechu22 : oh, that would be great! thanks!

Wohlstand commented 5 months ago

I never noticed it for libasnd since the sample MP3 file there is mono

And me, who ran the stuff on TV without hearphones. I found this bug once I began to use hearphones with my TV (to don't make loud noice that affects neighbours, and just listen in-game sounds more accurate).