Printable Version of Topic

Click here to view this topic in its original format

OESF Portables Forum _ Gemini PDA - Hardware _ speakers out of phase?

Posted by: speculatrix Jun 20 2018, 02:29 AM

i was watching a youtube video and I was enjoying the stereo sound when I realised the sound seemed odd, there was no central stereo image. I think it's because the speakers are mis-wired and thus out of phase.

Just me?

Or is it some sort of audio processing that's meant to give a faux wide field effect?

I'm wondering if there's an audio player for android which allows reversing the phase of one channel so I can do a test to try and prove I am right.

Posted by: drand Jun 20 2018, 04:33 AM

I know there are apps such as Polarity Checker that allows you to check a speaker for this by playing a series of test audio files. Perhaps if you have another android device you could use it to check the Gemini. I might give it a go later if I can.

I know that my ears can't detect phase difference but I do think the Gemini's sound quality is poor having watched a few vidoes.

Posted by: speculatrix Jun 20 2018, 08:57 AM

I tried this app and it reported nine out of ten times, if not more, that my speakers are out of phase.
https://play.google.com/store/apps/details?id=com.dwa_ict.polaritychecker

Posted by: speculatrix Jun 20 2018, 09:25 AM

I installed a tone generator and playing a tone give me a central image using bluetooth or wired headphones but not with speakers.

https://play.google.com/store/apps/details?id=com.xyz.signal

warning: turn volume right down before turning on the sound, and raise volume slowly, then lower it before switching to headphones!

Posted by: speculatrix Jun 20 2018, 01:14 PM

QUOTE(drand @ Jun 20 2018, 01:33 PM) *
I know that my ears can't detect phase difference but I do think the Gemini's sound quality is poor having watched a few vidoes.


human ears are relatively insensitive to phase, but when the signal from stereo speakers is totally out of phase you'll know.

Posted by: iusethis Jun 20 2018, 02:18 PM

Planet have mentioned that the speakers are currently mono only, but this will be fixed in a future firmware update. That said, it sounds like the polarity on one of the speakers is inverted or else something funky is going on there, so not sure if that can be fixed in software.

Posted by: TallTim Jun 20 2018, 03:15 PM

QUOTE(iusethis @ Jun 20 2018, 06:18 PM) *
Planet have mentioned that the speakers are currently mono only, but this will be fixed in a future firmware update. That said, it sounds like the polarity on one of the speakers is inverted or else something funky is going on there, so not sure if that can be fixed in software.


I wonder if anyone has noticed lower volume through headphones? I don't get the warning like you would in other devices in Android for raising the volume through settings -- but I do wonder if there is some kind of limiter on the top-end volume level.

This is going through some pretty high-quality headphones too, so it wasn't a factor of crap connection or gear.

Posted by: speculatrix Jun 20 2018, 11:05 PM

ah, I didn't realise the speakers were mono.
in that case, the sound should appear to come from the centre all the time with no sound stage.

Posted by: zevv Jun 21 2018, 07:53 AM

I noticed the same thing, it's quite annoying really. I made some measurements the other day, here's a recording of a 440Hz sine wave with two
mics on each speaker:



I really do hope planet will fix this on the short term, it makes playing any kind of audio a nuisance.


----
edited by admin, re-uploaded image to imgur so that it can have an https URL and thus show correctly in the forum. ~speculatrix

Posted by: zevv Jul 17 2018, 08:20 AM

After some hacking in the audio drivers I am now able to fix the speaker phase with a rather nasty but functional kernel hack that simply inverts the polarity of one channel of the audio data before it is sent to the codec. It is rather incredible how much better the sound is with the phase fixed, not only does the sound not originate from behind your eyes anymore, but there sound is much fuller with more low in it.

The problem I now run in to is that the phase is reversed with using headphones, as the same codec path is used for both headphones and speakers, so I will need to find some kind of detect if the headphones are active and only reverse phase if this is not the case.

I might also be able to fix the crackle-when-nothing-is-playing issue while I'm at it by not powering down the I2S path when audio playing is paused, but that might have implications on power usage, of course.

For the brave of heart, here is my android kernel boot image with the phase fixed: http://zevv.nl/div/linux_boot-phasefix.img. (No, I take no responsibility for any bricking or other harm done to your device!)

Posted by: jakfish Jul 17 2018, 08:58 AM

Well, hats off to you. Amazing! Have you explored your work with Planet? You seem to be on to something and they should know about it.

Jake

Posted by: speculatrix Jul 17 2018, 11:53 AM

wow, zevv, that's awesome
I had been thinking of trying to pop open the G's case and swapping the wires round on one of the speakers.

Posted by: Kiriririn Jul 17 2018, 03:49 PM

QUOTE(zevv @ Jul 17 2018, 05:20 PM) *
After some hacking in the audio drivers I am now able to fix the speaker phase with a rather nasty but functional kernel hack that simply inverts the polarity of one channel of the audio data before it is sent to the codec. It is rather incredible how much better the sound is with the phase fixed, not only does the sound not originate from behind your eyes anymore, but there sound is much fuller with more low in it.

The problem I now run in to is that the phase is reversed with using headphones, as the same codec path is used for both headphones and speakers, so I will need to find some kind of detect if the headphones are active and only reverse phase if this is not the case.

I might also be able to fix the crackle-when-nothing-is-playing issue while I'm at it by not powering down the I2S path when audio playing is paused, but that might have implications on power usage, of course.

For the brave of heart, here is my android kernel boot image with the phase fixed: http://zevv.nl/div/linux_boot-phasefix.img. (No, I take no responsibility for any bricking or other harm done to your device!)


Awesome find! Can you share the source code of your change?

Posted by: zevv Jul 17 2018, 11:47 PM

QUOTE(Kiriririn @ Jul 18 2018, 12:49 AM) *
Awesome find! Can you share the source code of your change?


https://github.com/zevv/gemini-android-kernel-3.18/commit/b8e88b5aa0fb5442cec1a5dc37a00d2dfb7af32c

Posted by: Anonymous_ Jul 19 2018, 12:48 AM

zevv: does this mean L and R channels get separated with your fix? As before L channel has been played in both speakers as well as R channel.

Posted by: zevv Jul 19 2018, 06:16 AM

QUOTE(Anonymous_ @ Jul 19 2018, 09:48 AM) *
zevv: does this mean L and R channels get separated with your fix? As before L channel has been played in both speakers as well as R channel.


No, it merely corrects the phase of the speakers.

I must admit that I was not aware that only the left channel was played. The fact that I'm able to flip the phase of one output indicates that the hardware is actually able to play stereo, so if only one channel ends up in the driver there must be a software issue somewhere down the line. I'll see if I can find some time to investigate.

Posted by: zevv Jul 19 2018, 11:32 AM

No, still mono. It seems that at the driver and alsa level the device is perfectly capable of playing stereo sound. Both left and right channels are mixed to mono.

In logcat there are some messages coming up when switching from headphones to speaker indicating this is a deliberate action:

07-19 20:27:16.946 482 838 D AudioFlinger_Threads: SetStereoToMonoFlag, mSteroToMono 1

This is a likely leftover from the original design the Gemini is based on which probably had a single speaker, in which case mixing to mono makes sense.

(Note the typo in there, it says 'Stero' instead of 'Stereo', likely this happens somewhere in propriatary MT code)

There is nothing I can do about this on the kernel level I'm afraid. I found some audio configuration in /system/etc/audio_policy_configuration.xml where the various audio channels are configured, but everything seems to be setup ok here. I'm not sure where to go from here, I have no experience at all going deeper into Android...

Posted by: speculatrix Jul 19 2018, 12:48 PM

Thanks zevv for the analysis, very useful.

I was just pondering why we get crackling on headphones but not the speakers.
Surely Planet tested the headphone jack? Did they change the analogue design very late?
I'm sure they must have contemplated stereo speakers, did they switch to mono so you can use the G either way round?

This is when having a schematic circuit diagram would really help.

Posted by: speculatrix Aug 23 2018, 01:34 PM

given it's possible to build, and indeed people have, kernels for Debian, do you think we can at least have sound fixed when running linux and not using the Planet-built kernel?

Posted by: zevv Aug 26 2018, 02:47 AM

QUOTE(speculatrix @ Aug 23 2018, 10:34 PM) *
given it's possible to build, and indeed people have, kernels for Debian, do you think we can at least have sound fixed when running linux and not using the Planet-built kernel?


Here is an Android kernel: https://github.com/zevv/gemini-android-kernel-3.18/releases/download/1/linux_boot-v1.img

This is a build of the stock Gemini kernel from Planet with two fixes: audio phase and keyboard ghosting. You could ask the Gemini maintainers if they are willing to pull in the speaker fix patch into the Debian kernel as well?

I've been running this for about a month without problems.

Posted by: speculatrix Aug 26 2018, 03:14 AM

QUOTE(zevv @ Aug 26 2018, 11:47 AM) *
QUOTE(speculatrix @ Aug 23 2018, 10:34 PM) *
given it's possible to build, and indeed people have, kernels for Debian, do you think we can at least have sound fixed when running linux and not using the Planet-built kernel?


Here is an Android kernel: https://github.com/zevv/gemini-android-kernel-3.18/releases/download/1/linux_boot-v1.img

This is a build of the stock Gemini kernel from Planet with two fixes: audio phase and keyboard ghosting. You could ask the Gemini maintainers if they are willing to pull in the speaker fix patch into the Debian kernel as well?

I've been running this for about a month without problems.



cool! does it flip the phase only on speaker?

Posted by: zevv Aug 27 2018, 04:45 AM

QUOTE(speculatrix @ Aug 26 2018, 12:14 PM) *
cool! does it flip the phase only on speaker?


Yes, it peeks into the accessory state and only fixes the phase when no headset is attached.

Posted by: speculatrix Sep 18 2018, 11:34 PM

Is it possible to produce a similarly patched kernel for android?

Thanks!

Posted by: mithrandir Sep 21 2018, 12:29 PM

@zevv: Thanks for the fix. Would you mind to create a pull request for this fix like you did for the keyboard ghosting? For a short moment I have been thinking about creating the request myself, but then I have been unsure if this were "politically correct". I think it would be nice to see the fix upstream (debian+android). Or do you have any doubts why it should not get merged?

mith

Posted by: gymbo Oct 5 2018, 09:39 AM

QUOTE(zevv @ Aug 27 2018, 02:45 PM) *
QUOTE(speculatrix @ Aug 26 2018, 12:14 PM) *
cool! does it flip the phase only on speaker?


Yes, it peeks into the accessory state and only fixes the phase when no headset is attached.

Don't know if it could be any help (and I must admit I haven't figured out how to configure it either, don't really use the speakers on the Gemini a lot...), but apparently Neutron (a music player) has a gotten a setting for phase switching...

So could be possible to get the music to play "correctly"? But you would have to change it every time going from headphones to speaker-mode... (and vice-versa).

Posted by: covex Oct 13 2018, 12:22 PM

QUOTE(gymbo @ Oct 5 2018, 07:39 PM) *
QUOTE(zevv @ Aug 27 2018, 02:45 PM) *
QUOTE(speculatrix @ Aug 26 2018, 12:14 PM) *
cool! does it flip the phase only on speaker?


Yes, it peeks into the accessory state and only fixes the phase when no headset is attached.

Don't know if it could be any help (and I must admit I haven't figured out how to configure it either, don't really use the speakers on the Gemini a lot...), but apparently Neutron (a music player) has a gotten a setting for phase switching...

So could be possible to get the music to play "correctly"? But you would have to change it every time going from headphones to speaker-mode... (and vice-versa).


I am new to gemini having a unit build cca 05/2018 with latest android and the sound is for sure stereo - tested with some stereo test videos on youtube. Not sure about the phase.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)