Rockbox Technical Forums

Support and General Use => Recording => Topic started by: z-man on July 18, 2008, 06:31:31 PM

Title: inverted phases on iaudio x5
Post by: z-man on July 18, 2008, 06:31:31 PM
It sounds like for some strange reason the hardware of the X5 is inverting the phase of the recorded signal. Interestingly, changing

tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_I2S);
to
tlv320_write_reg(REG_DAIF, DAIF_IWL_16 | DAIF_FOR_I2S & 0x7e);

and this way switching to [MSB first, _right_ aligned] seems to compensate the inversion and gives me the feeling of being much closer to the original.
Title: Re: inverted phases on iaudio x5
Post by: soap on July 18, 2008, 06:58:01 PM
Not to knock your feelings, but should this not be easy to conclusively test?
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 18, 2008, 07:02:41 PM
What do you mean that it "sounds" like it's inverting the phase?  A phase inversion should not produce any audible difference.
Title: Re: inverted phases on iaudio x5
Post by: petur on July 19, 2008, 07:16:22 AM
What do you mean that it "sounds" like it's inverting the phase?  A phase inversion should not produce any audible difference.

unless only done on one of the two channels....

imho, this can/should be tested by feeding it a sine and checking the result
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 19, 2008, 07:59:15 PM
petur: that's fair. But this should be easy to check.  Set the output in Rockbox to a mono setting.  Then put two speakers facing each other and if cancel each other out then they're phase inverted from each other.  If the sound adds then they're in phase.  Or put the signals on an oscilloscope.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 20, 2008, 12:01:12 AM
petur: that's fair. But this should be easy to check.  Set the output in Rockbox to a mono setting.  Then put two speakers facing each other and if cancel each other out

They'll still cancel each other out if they're phase inverted or not, only the location of the regions where constructive and destructive adding occurs will change.

Just record the same tone in both channels and look at it in an audio editor.  Should be pretty obvious if the phase is inverted in only one channel. 
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 20, 2008, 12:39:07 AM
Have you carried out this experiment?  There's a stark difference between two in-phase sources and two sources with a phase difference of pi.  For two speakers that are close to each other the superposed waves will exhibit constructive interference almost everywhere for in-phase waves.  If you switch the polarity on one speaker then the situation changes and you will get destructive interference almost everywhere.  This works well enough that everyone in an auditorium will hear the expected change in volume when you switch the polarity of one speaker.

Good point about using an audio editor to compare the two channels.  That seems like the best approach -- and makes the above paragraph of only academic interest.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 20, 2008, 02:49:04 AM
Have you carried out this experiment?

Every day.  I build interferometers as my day job.

(far field diffraction pattern of two sources is the inverse fourier transform of a pair of delta functions, and thus cosine if they're in phase and a sin if they're out of phase.)

For two speakers that are close to each other the superposed waves will exhibit constructive interference almost everywhere for in-phase waves.  If you switch the polarity on one speaker then the situation changes and you will get destructive interference almost everywhere.  This works well enough that everyone in an auditorium will hear the expected change in volume when you switch the polarity of one speaker.

This would work much better then putting them facing each other.  in this case all you have to do is step onto the optical axis (e.g. the origin) and see if its quiet (sin) or not (cos).  I agree that its still easier to do it digitally though, you'd probably have a lot of trouble with reflections off the walls of your room unless you've got a very large space to try this in.
Title: Re: inverted phases on iaudio x5
Post by: z-man on July 20, 2008, 06:52:04 AM
Just record the same tone in both channels and look at it in an audio editor.  Should be pretty obvious if the phase is inverted in only one channel. 

Did it. _BOTH_ channels appear to be inverted.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 20, 2008, 07:58:21 PM
Just record the same tone in both channels and look at it in an audio editor.  Should be pretty obvious if the phase is inverted in only one channel. 

Did it. _BOTH_ channels appear to be inverted.

And you're certain they're not both non-inverted?  I guess you checked a less symmetric signal then a sin wave.
Title: Re: inverted phases on iaudio x5
Post by: soap on July 20, 2008, 08:11:44 PM
Wouldn't creating a DC offset sine wave for this test be easy enough?
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 20, 2008, 08:43:40 PM
Assuming it records the DC level that would work.  It might filter out the DC via coupling capacitor or similar though.
Title: Re: inverted phases on iaudio x5
Post by: z-man on July 21, 2008, 08:44:28 AM

And you're certain they're not both non-inverted?  I guess you checked a less symmetric signal then a sin wave.

Yes, I'm sure. And please: Normally, I would be able to identify my wife not just because she has something that I don't have. Thus, looking at the signal with audacity and enough spreading enabled doesn't need a sin wave to tell whether it is inverted or not. But you're right, keeping things simple can't be a bad idea, and so I recorded an almost sin like wave from a keyboard onto my reel to reel tape. Next, I connected the analog output of the tape to the analog inputs of
- the Cowon X5
- a Sony Hi-Md walkman
- a Soundblaster Live soundcard
- a Steinberg Mi4 audio interface

Result: Compared to the other 3 devices the X5 signal is inverted.
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 21, 2008, 04:57:10 PM
Does the X5 use inverting op-amps in the amplification stage?  It seems that there are no real-world situations where this will be audible anyway, so I'm somewhat missing the point here.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 21, 2008, 05:35:33 PM
And please: Normally, I would be able to identify my wife not just because she has something that I don't have. Thus, looking at the signal with audacity and enough spreading enabled doesn't need a sin wave to tell whether it is inverted or not.

Well yes, thats the point, you can't tell if the signal is inverted with just a sin wave, hence the need to test something else.
Title: Re: inverted phases on iaudio x5
Post by: z-man on July 22, 2008, 08:55:26 AM
Does the X5 use inverting op-amps in the amplification stage?  It seems that there are no real-world situations where this will be audible anyway, so I'm somewhat missing the point here.
Well, it wasn't my intention to start a thread about who's the more real-world guy: the one who is able to notice a difference or the one who lives happy and in peace with his 128k mp3 collection. But to answer your question: Obviously yes. And (I did another test yesterday) there's a mimic that inverts the signal a second time on the line-out channel.
That is, with recording via line-in and playing back via line-out you'll be fine because the signal is inverted twice. While data transfered via USB to the X5 plays back inverted and data recorded via line-in and transferd off the X5 via USB will lead to an inverted CD.

So my question to the programmers: Why not invert the record buffer just before writing data to disk and doing the same before feeding the DAC with playback data? Or would that cause too much overload?
Title: Re: inverted phases on iaudio x5
Post by: Llorean on July 22, 2008, 09:30:44 AM
Pardon my ignorance. What exactly is one supposed to be hearing different with an inverted audio stream? My understanding of sound was that it was amplitude and frequency that matters, and these remain the same with an inverted signal.
Title: Re: inverted phases on iaudio x5
Post by: LuzifaHell on July 22, 2008, 12:01:05 PM
*knock-knock* Anybody out there capable of answering a question instead of, first and foremost, doubting the reasons for putting it? Please?

Thank you in advance.
Title: Re: inverted phases on iaudio x5
Post by: Llorean on July 22, 2008, 12:21:04 PM
Surely if he's asserting change need be made, it is reasonable for one who doesn't understand to ask why?

And remember, we can see the logs in the forum so it's pretty obvious to us when you create a second account z-man. If you don't have an answer, just say it.
Title: Re: inverted phases on iaudio x5
Post by: LuzifaHell on July 22, 2008, 02:34:42 PM
Surely if he's asserting change need be made, it is reasonable for one who doesn't understand to ask why?

Oh yes, of course it is, and you'll find the explanation in the very beginning of this thread, I think. I just wanted to know if there are any programmers around, whom the question is ringing a bell with, and if they've got an answer -- and if so, which one, of course. :-) ).

P.S. OMG... no, I'm not Z-man. I'll give you my XING-profile via mail if you want me to. Plus explanation. Tis-tis-tis.
Title: Re: inverted phases on iaudio x5
Post by: Llorean on July 22, 2008, 02:38:27 PM
At the beginning of the thread he noted it was inverted, which was confirmed. The question is "why is inversion a reason to change things." He has not answered that. I've admitted openly I'm ignorant on the subject. Surely if it's a valid reason there should be some explanation you can provide or link me to.

Edit: Removed the suggestion they are the same person. I've received evidence to the contrary that, while not conclusive, at least leaves the issue in question as much as it can be so they should be treated as individuals.
Title: Re: inverted phases on iaudio x5
Post by: petur on July 22, 2008, 06:04:54 PM
z-man: do create a bug tracker entry for it, maybe somebody might agree with you and invert the signals.

Did you check if the original firmware inverts them (playback and recording)?
Title: Re: inverted phases on iaudio x5
Post by: z-man on July 22, 2008, 06:45:54 PM
z-man: do create a bug tracker entry for it, maybe somebody might agree with you and invert the signals.

Did you check if the original firmware inverts them (playback and recording)?

Thanks for leading back to the constructive path. I'll do so. And yes, I got the same results with the original firmware. Actually, it seems to be a hardware, not a software problem.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 22, 2008, 07:04:20 PM
Its generally not accepted that polarity has any impact on audio quality whatsoever, so I'm not sure a bug report really makes sense.  It appears to just an artifact of how the ADC works, and I don't see any reason to prefer one polarity over the other.
Title: Re: inverted phases on iaudio x5
Post by: Zardoz on July 22, 2008, 09:46:01 PM
is signal inversion a manifestation of or a cause/consequence of the problems of crosstalk, inherent in loudspeaker rendering?
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 22, 2008, 11:53:35 PM
 ???
Title: Re: inverted phases on iaudio x5
Post by: Llorean on July 23, 2008, 12:19:09 AM
Signal inversion is most likely simply an effect of the amp they chose to use.

Because different hardware has different sound quality, my best guess is the audible difference he's hearing are just aspects of the X5, and if he put an inverted file on it, so that it was not inverted when played back, and performed the same tests he would get identical results to his initial tests.

The only really useful test would be an ABX or other similar blind test.

Correlation doesn't imply causation: "It sounds different" and "The signal is inverted" are two separate things, and a link to them needs to be established first.
Title: Re: inverted phases on iaudio x5
Post by: Chronon on July 23, 2008, 03:44:20 PM
I also suspect that they simply used a different kind of amplifier (inverting vs. non-inverting). 

I'm pretty sure that no such link can be established between polarity inversion and sound quality.  The human ear is not a phase sensitive detector.  It detects amplitude at certain frequencies.  As such, you can only hear how the phase changes (frequency) not what the value of it is. 

I tend to agree with Llorean that z-man has other issues with sound quality on the X5 and that polarity inversion is a red herring.  I strongly doubt that inverting the polarity will resolve the sound quality issues that z-man is experiencing.
Title: Re: inverted phases on iaudio x5
Post by: pabouk on July 25, 2008, 10:47:08 AM
...this way switching to [MSB first, _right_ aligned] seems to compensate the inversion and gives me the feeling of being much closer to the original.
z-man, I think that you probably experienced the placebo effect. Using either one or the other polarity when playing audio should have no impact on the perceived sound unless there is something (strongly asymmetrically in the polarity view) wrong with the analogue signal path which would affect the both polarities anyway. The best way how to more or less reliably tell the difference in perceiving the sound with one or the other polarity is to use the blind ABX test (http://en.wikipedia.org/wiki/ABX_test).
Title: Re: inverted phases on iaudio x5
Post by: petur on July 25, 2008, 04:46:58 PM
I consulted a friend who is a true audiophile and freak (very expensive and special gear and cables, selected after lots of testing, and a special designed room in his house (even has a tilted ceiling) for listening. He uses special CD players with controlled phase jitter, has special audio-cd copy equipment,... A true freak. He's also a scientist, so not some idiot paying loads of money because somebody says B is better than A.

His reaction was: yes, there is discussion on whether you can hear this inversion or not. Personally, he doesn't hear any difference, so he doesn't care. He did tell me that some expensive equipment has switches for inversion because you never know if the signal didn't get inverted somewhere between the mic and the CD.

And here comes my point: if it is possible that a CD may already contain an inverted signal, you can't really tell if what you hear is the real stuff or is inverted.

I listened to both and didn't hear a difference. I used a bit of a 16bit/44KHz WAV file of a recording I did, just to make sure I got the inversions right ;)

I haven't done a blind test yet
Title: Re: inverted phases on iaudio x5
Post by: mlind on July 28, 2008, 06:04:50 AM
In big loudspeakers playing loud you might be able to FEEL the difference if the sound of a beating bass drum is inverted or not.
Otherwise probably not.
Title: Re: inverted phases on iaudio x5
Post by: saratoga on July 28, 2008, 11:16:29 AM
In big loudspeakers playing loud you might be able to FEEL the difference if the sound of a beating bass drum is inverted or not.
Otherwise probably not.


That really makes no sense.  Your sense of touch is no more phase sensitive then your ears, low frequency or otherwise.
Title: Re: inverted phases on iaudio x5
Post by: z-man on July 28, 2008, 11:30:38 AM
Yeah! I'm happy there's at least one other guy in this forum who's got the idea. Basically, I wouldn't even want to claim I could tell an "inversed" bass from a non-inversed one. But your hint goes in the right direction: strong pulses. A strong positive low frequency pulse, immediately followed by high frequencies of low energy simply draws a different picture in my head than the same sequence started with a negative pulse. There's no right or wrong, it's just different. The explanation is that within a certain range your ear is converting mechanical energy "symmetrically", that is you can't identify a constant sine wave of being started negative or positive. Even more, with listening long enough - and long is meant to be in the range of microseconds - your ear will sum up any a-symmetric influences to just one let's name it average hearing experience. Things become different, though, when your ears are reaching a range they can't cope with, when there are no (or no close) signals of the same amplitude but opposite polarity to compute an average value from. If you ever have the chance to lift yourself up a 100 floors in a fast elevator - mouth and nose shut - and then back down again you might understand what I'm talking about: It even HURTS different.
Title: Re: inverted phases on iaudio x5
Post by: Llorean on July 28, 2008, 11:34:52 AM
Look, come back with ABX test results, but stop with the hypothesizing. If anyone posts one more theory in this thread, in favour of EITHER SIDE without a test result, I'm deleting the post or even the whole thread. Not even locking. Thread gone, period.

Do some testing. It's not that hard, and it provides meaningful results.