![]() |
![]() ![]() ![]() ![]() ![]()
|
next newest topic | next oldest topic |
Author | Topic: Uses for Allpass Filters | |
David McClain Member |
![]() ![]() ![]()
Attached is a SoundFile that demonstrates what I'm about to say. Turns out that Broadcasters utilize a Phase Rotator as the first element in their audio processing chain ahead of equalization, compression, and pre-emphasis. A "Phase Rotator" is a (typically 4-pole) AllPass filter tuned to 200 Hz. I don't know what their Q's are. The purpose of this APF is to convert asymmetric waveforms into something more symmteric about the DC level. That's what this Sound demonstrates. Human voices are such that the waveforms they generate often have high degrees of asymmetry relative to the DC level. Higher positive peaks than negative peaks. The reason this is a problem is that Compressors typically respond to peak levels, and with an asymmetric waveform the compressor will be activated to reduce the level of the human voice, based on the highest peak levels seen (the positive side of the asymmetric waveforms). By using a phase rotator, you shift the various harmonics relative to one another and so you can make the waveforms more symmetrical about the DC level, equalizing the excursions above and below the DC level. That allows more volume in the voice before compression kicks in. Recall that APF's are amplitude neutral. They don't attenuate nor amplify any portion of the input spectrum. So the "Loudness" of the voice before and after APF phase rotation ought to be the same. And by symmetrizing the waveform, you can apply more gain to the voice before compression kicks in. Now I wrote "Loudness" is the same -- the Power in the waveform is the same, because Power is independent of individual harmonic phases. That much is provably true. However, when I first created this Sound, I had it feeding only one output channel with a Direct/Phase toggle. And when I toggled that control I heard a definite pitch shift. (That's the second Sound in the SoundFile). How can that be? The APF is amplitude flat with zero relative gain to the direct path. You can verify that by using a spectrum analyzer and viewing the transfer function. It is absolutely amplitude flat over all frequencies regardless of Direct or Phase Rotated. So why is there a pitch shift when listening to the toggle between Direct and Rotated? Well, we know that human hearing suffers a pitch shift toward the flat side as sounds grow louder. That's why violinists have to fight the tendency to play sharp. So for some reason there is approximately a 1-2 dB difference in sound loudness levels between the direct and phase rotated oscillator signals. You can even see this difference on the level meters in Kyma and on the spectrum analyzer. [But those meters measure peak amplitudes!] Double checking that the APF really is flat by sending Pink noise to the right channel and through the same APF tuned to 200 Hz, 4 Poles, Q arbitrary, Level = 1, to the left channel, I can see the transfer function of the APF filter in the spectrum analyzer by looking at the ratio of left to right responses. Absolutely flat! Only a phase shift whose range of shifting occurs over narrower frequency ranges as the Q is increased. Absolutely flat... So this experiement shows that our hearing responds not only to RMS power levels in the sound, but also to the peak amplitudes in them. The Direct sound with its higher peak excursions to the upside sounds definitely flatter than the phase rotated waveform which has identical frequency content and power. Is that interesting!? or what?!!!! - DM [I have just gone through my audio chain to ensure that no effects are being applied. When I do that I still hear a pitch shift, but now it is in the opposite sense. The Direct sound appears sharper than the phase rotated sound at 250 Hz. But the Direct sound appears flatter than the phase rotated sound at 500 Hz, and the discrepancy disappears by 1 KHz. To be sure, some of this variability is due to the fact that the phase rotated signal at higher frequencies exhibits more and more asymmetry, becoming more like the direct signal. And so leaving the phase rotated signal running out you can vary the Q of the APF and see a change in the waveform, and also hear a slight change in the sound. It appears, however, that the correct explanation is a bit more involved than I first thought.] [This message has been edited by David McClain (edited 20 August 2005).] IP: Logged | |
pete Member |
![]() ![]() ![]()
I think that we are hearing another audio illusion. Imagine if the allpass you used was an 90 degs phase shift at all frequencies, then by slowly chainging form direct to non direct we would hear a pitch shift. Now to continue hearing a pitch shift we would have to keep on shifting the phase in the same direction. We would end up making a single side band ring modulator where the pitch shift could be huge. O.K. so this is not a single side band ring modulator and we are not continueing to rotate the phase but we are doing one bit of it and then stopping. So our ears hear an upward pitch shift for a split second when you press the toggle but because it hasn't heard the anything to suggest that the pitch has come back down again, so our brains conclude that the pitch must have risen and must still be staying there. Our brain concludes that if the pitch was the same as before, we would have had to have heard somthing to suggest a falling pitch to match the apparent rising pitch but we are actualy still hearing the same pitch but we just won't accept it. I've made an adjustment to your sound to add the ability to invert one of the signals so that the toggle will subtract phase instead of adding it. You may notice that the apparent pitch change goes in the other direction. I hope this makes sence ? Pete IP: Logged | |
pete Member |
![]() ![]() ![]()
On second thoughts I think I'm wrong I tried it replacing the allpass with Your 90deg allfreq phase shifer and the corisponding delay in the direct leg. I notice the pitch shifting effect only seems to happen with headphones and that the tonal quality also changes with changing toggle settings. I now think that it's the non linearity of my headphones that is changing the harmonic content and as hearing uses filter frequency bands to determine pitch , I think that the assumed pitch is being ever so slightly moved. This is because the relative levels in near by frequency bands are being adjusted by the near by harmonics. Hence our brains must conclude that the actual pitch must lay slightly closer to the higher frequency band of the two bands either side of the actual frequency, as the higher band is receiving a slightly higher level than it was before. p IP: Logged | |
David McClain Member |
![]() ![]() ![]() Hiya Pete! Well I did some investigating here and found a reference in the book, "Music, Cognition, and Computerized Sound", edited by Perry Cook. On pages 46-47 he shows an example of altering the phase of the harmonics of a sound and indicates that, with headphones, all three of the resulting waveforms sound different at 27.5 Hz. At 220 Hz they sound scarcely different with headphones, and by 880 Hz there is no difference. He indicates further that since we tend to listen to speakers, not headphones (except me!), and that most of the notes are above 27.5 Hz, and that reverberant chambers completely wash out the minor differences even at 27.5 Hz, that for all practical purposes we cannot hear any difference between sounds with different phase relationships among the harmonics. Indeed, if we could then your favorite stereo system would sound awful unless you sat in exactly the right spot -- if you could even find such a spot -- because all the waves emanating from the speakers are undergoing phase shifts that are all different from each other. Indeed the group delay from the speaker to your ear is L/c where L is the distance and c is the speed of sound. But that is a group delay, and so the phase shift will be f times as great, where f is the frequency of the sound. Hence all the phases of all the sounds get completely scrambled on their way to your ear. Thank goodness we are largely deaf to phase variations. Going back to Perry Cook's comments... I can lay claim to the fact that indeed the sound shift is frequency dependent, diminishing toward higher frequencies, but that I can clearly hear the effects at 250 Hz and even 500 Hz. By 1 KHz it is scarcely audible and at 2 KHz there is no discernable effect. So apparently this is a known phenomenon... just not known until now by me! Cheers, - DM [This message has been edited by David McClain (edited 20 August 2005).] IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David This brings up something we spoke about a long time ago (The Linearity of human hearing). I can't refer to books as I never read them but only to what I believe from my own experiments. "we cannot hear any difference between sounds with different phase relationships among the harmonics." I think that this is one of the most important points about hearing. But I would like to add a second point. If two signals with identical frequency content but with different harmonic phase relationships, are put throught two identical non linear devices the two outputs will have two different frequency contents in 99.99% of cases. Therefore if our hearing had bad linearity in our hearing then the first statment could not be true. We would almost always be able to tell the difference between similar but phase adjusted signals as the frequency content would always be adjusted. Hense our ears must have good linearity. So with good lineary speakers and out good linear ears we don't hear the effect but when the headphones in intruduce nonlinearity, thats when we do start to hear oddities. I know that the probe tone test tend to point out non linearity in our hearing but I believe that that is showing up something else. "Thank goodness we are largely deaf to phase variations." well actualy we are not that deaf to them as we do have the ability to detect phase differences between our left and right ears very well. This tells me that the brain is not just being sent spectum levels but also getting some additional info. I'm a bit confused as to what Mr.Cook is saying here, what is the criteria that makes the pitch tend to rise and what is it that makes it go low again ? Pete IP: Logged | |
David McClain Member |
![]() ![]() ![]() Hi Pete, Perry Cook didn't actually say that the pitches varied, just that listeners could hear a difference. He didn't specify what that difference is. I said you could hear a pitch shift, and I attributed that to a general shift in presented amplitude levels. We know that as sounds grow more intense they become more flat sounding. So I surmised that the pitch shift at low frequencies had to do with the amplitude difference between the two different phasings. In general we know that the ear responds to an average power level in the sound, acting a bit like a spring whose stiffness grows as the power level increases. That protects us against enormous amplitude swings of the basilar membrane at very loud levels.* But in light of this new finding (new for me!) I surmise further that this power level is sensed over very brief intervals of time. Hence at high frequencies, with periods much shorter than this measurement interval, there is no difference to be found between various phasings because all of them have the same exact power levels. But at lower frequencies, longer than the measurement interval, the measured power levels will vary with time in a sinusoidal manner. But the ear recovery time is very long compared to this measurement interval, and so once the low frequency power measurement is at its peak level, the ear will tend to respond as though the sound were at that intensity level. The net result is that for low frequencies, the ear behaves a bit more like a peak detector and less like an RMS power detector. -------------------- ------------------------------------- My own findings indicate that regardless, the effect is much like a spring whose stiffness grows with increasing sound intensity. Whether it really grows stiffer, or the amplification of the OHC diminishes, the effect is much the same. The inner hair cells (IHC) act as the power sensors telling the brain about the sound intensity, and the brain sends signals back to the OHC to help moderate the amplitude swings of the BM.] - DM [This message has been edited by David McClain (edited 22 August 2005).] IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David "But I find it interesting that you believe that nonlinearities affect different phasings differently. Can you cite some examples of this behavior? There ought not be different frequency content, but it is possible that the phase relationships might tend to cancel out some of the presented additional tones." Well the first simple example would be the tones you've just been playing with being clipped at near the the peek. One would reach clipping and cause hugh amounts of added harmonics and the other might not even get clipped at all and would add no additional harmonics. The actual look of any wave form with the same harmonic content yet different phases, is entierly different so the shape of the distortion deveations created will look entierly different and there is no reason why the harmonic content of these different wave forms should bear any relationship at all. A square wave being clipped or put through a simple wave shaper will only ever make another square wave (maybe at different level) but a square wave shifted by 90 degs has a very rippley shape, It should be easy to see that this wave form will not look unchanged when it is clipped or put through a wave shaper. Also considering all the different wave shaping coordinates that this ripply wave could be put through will not amount to the same sounding waveform (just attenuated) as the square wave would. Even just phase shifting one harmonic of a square wave will make it look entierly different. I can't believe that a square wave is a special case and that other waveforms will have matched distortion when they are phase shifted. Hope this makes sence. Pete. IP: Logged | |
David McClain Member |
![]() ![]() ![]() Ahh yes! Of course -- clipping! Yes indeed, if one clipped and the other didn't then of course you would have different frequency content. Silly me! Thanks for that example, Pete. - DM IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David now it's my turn Can you cite an example that wouldn't exibit this behavior? i.e nonlinearity that will change the harmonic content of both a phase relation shifted and a non phase relation shifted signal in exactly the same way. Pete IP: Logged | |
pete Member |
![]() ![]() ![]() I think I've found one. If we take a waveform and reverse it in time. Then this reversed waveform would be like the first waveform but with the harmonic phase relationships adjusted. When putting these two signals through identical wave shapers, the two destorted outputs will have identical spectrol content, as long as the wave shapers have no time shifting elements in them. I think that this is the exception to the rule but that in general the rule still holds true in almost all cases. have I convinced you yet ? Pete IP: Logged | |
David McClain Member |
![]() ![]() ![]() Hi Pete, Well, the examples I had been thinking of before you suggested the ultimate nonlinearity (clipping), were all such that they raised the signal samples to some power, like squaring or cubing. Those are typical of tube distortions. When you do this, it makes no difference what the initial phase relationship between the initial partials is... For example with squaring of a wave with 2 partials at arbitrary phase between them, you get the same collection of frequencies (sum and difference), no matter what that phase relationship is. The phases of those heterodyne components will depend on that initial phase relationship, but not their amplitudes. So now I have to think hard about why clipping ought to depend on the phase... Ahh! Unlike simple squaring or any other power, which are continuous operations - meaning that they affect all waves regardless of amplitude, it is clear that clipping may or may not affect waves, depending on their peak amplitudes in relation to the clipping threshold. So in that sense, one cannot model a clipper by any continuous function. But among nonlinear operations, many of them are continuous in nature (like squaring or cubing), and then there are many more that are not. So there is a kind of "degree of nonlinearity" that places things that act abruptly above certain thresholds in a more severe class than the continuous functions.... - DM
Still, this has to be considered some kind of nonlinearity, because it effectively flips the sign of the complex exponentials. And I don't know any math operation that can do that on a continuous basis. So here is yet another bizarre class of nonlinearity that is even unlike the abrupt thresholded operations. You are really good at coming up with devilish examples! ] [This message has been edited by David McClain (edited 29 August 2005).] IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David Do you think it would be far to classify a type of nonliniarity as Wave shaping. Clipping would be a sub set of this. In this class no samples would have any effect on nagbouring samples and each sample could be calculated in isolation. The rule would be that the output could only contain the sums and the differences AND the original frequencies. The levels of these would be dependant on phase relationship. The square of the signal would also be a sub set of this type of nonliniearity and would only contain the sums and the differencies but the levels of the original frequencies will be equal to zero. By the way when I discribed the reversing of the wave form, it was only a way of discribing a set of phase shifts rather than having to state every frequency, level and phase shift that I would need to achieve this kind of effect. I was only considering repeating waveforms so the infinite time bit didn't come into it. Another thought I had on your frequency shift : Distort : anti Frequency shift idea was to shift it so hi that the whole of the audio spectrum fell into 12.5% frequency range. This way the sums and the differences would both end up outside this range and fit nicly into there own 25% ranges. These could the be filtered out compleately leaving only the original frequencies. Then we could bring the the frequency back down and end up with a clean signal. There was another technic I found for shifting frequency and returning it back to its original pitch without the latency intorduced by the hibert transforms. What you do is split the signal into two paths A and B and you multiply path A with a sine wave and you multiply path B with a matching cos wave. This does mean that you get both the sum and the difference shifted at this point but this gets canceled out later. You then do two identical treatments to both the A signal and the B signal. Then we multiply A by the same sinewave as before and we multiply B by the same cos wave as before and add the two signals together to get back the original signal, or at least it would be the original if the treatments in the middle did nothing. I'm not sure if it would lend it's self to this requirement, but I have used it to make lopass filters act as pitch variable band pass filters by varying the pitch of the sine and cos waves . Pete. [This message has been edited by pete (edited 29 August 2005).] IP: Logged | |
David McClain Member |
![]() ![]() ![]() Hi Pete, You are correct about the algorithm for shifting without using Hilbert transforms. Indeed the Hilbert transform exhibits some attenuation in the bass region. I did a version just like you proposed immediately after submitting the one above. There are several issues. First of all we are limited on Capy to a maximum sample rate of 100 KHz. All real spectra are actually 2-sided. We normally only work with the positive frequency components, realizing that the negative frequency components are an exact mirror image of these positive components. When you shift up in frequency by multiplying the real signal by a cosine in one path, and a sine in the other path, you are actually also shift the negative frequency components into the positive frequency zone. [this technique also requires two applications of your modifications -- one in the cosine arm, and another in the sine arm.] Realizing this now, means that in order to avoid harmonic generation from the lower sideband falling into the upper sideband, means that the entire spectrum now has to be shifted by the full span of the original (positive frequency) spectrum, plus another equal amount since only odd harmonics are generated by clipping. That means that if you value the frequency range from 0 to 24 KHz, then you must shift by at least 48 KHz in order to prevent the lower sideband harmonics from landing in the upper sideband. The spectrum now extends from 24 KHz to 72 KHz (remember it was 48 KHz wide when you include both upper and lower sidebands). But at 100 KHz sample rate, our Nyquist limit is only 50 KHz, so we have overrun our limits. Massive aliasing will ensue. This is why it is desirable to run at something like 480 KHz sample rate. Also, the higher the working sample rate, the more room you leave for the harmonics to dissipate before hitting the Nyquist wall. Filtering at this point is useless for preventing aliased harmonic components that reflect back and land in your signal spectrum. But the more distance you have for the harmonic series to run before hitting the Nyquist wall the smaller those artifacts will become, since they decay as 1/N for harmonic N. The distance a harmonic has before it aliases into your spectrum is twice the distance from your upper band edge to the Nyquist frequency. That's great at 480 KHz sample rate, but useless for us here because we have already overrun our limit with the original spectrum itself. Assuming you solve the problem of the limited sample rate, filtering is certainly necessary to discard what harmonics you can, above the upper sideband (and lower sideband too, since aliasing works in both directions...). But the already aliased harmonics falling in the shifted original spectrum are there and cannot be readily removed. Okay, so there are some potential problems with this approach because we just don't have enough room at practical sample rates. The Hilbert transform produces a single-sideband spectrum and occupies only half the spectral range when you shift it. That means that if you want all harmonics from clipping to land above the upper sideband, then you need to shift by at least half the width of the signal spectrum, or in this case only 12 KHz. The upper sideband is only 24 KHz wide, so after shifting by 12 KHz we extend to a high of 36 KHz. With a sample rate of 100 KHz. we now have 14 KHz of spectrum between our upper frequency limit and the Nyquist frequency, and so effectively 28 KHz before aliased harmonics will land in our signal spectrum. That isn't very much, considering that we will possibly have harmonics generated from 12-36 KHz signals, and so again, a much higher sample rate is called for. But on a real Capy with its 100 KHz limit, you just have to accept some aliased harmonics, and in the case of the sine/cosine translation you can't shift far enough to avoid having lower sideband harmonics landing in the upper sideband. Just facts of life... - DM
[This message has been edited by David McClain (edited 30 August 2005).] IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David Not ideal but a way to test the workings is to verispeed down the signal (to avoid the sample rate) then do the stuff and then verispeed it up again . But of cause this means non real time operation only. I'll have a think about the sine/cos technique again to see if there is a way to avoid the doubling up of the band width, but I don't hold out much hope. Pete IP: Logged | |
pete Member |
![]() ![]() ![]() Hi David I've been having a think. Considering that most of the higher frequencies in an audio signal are much lower in level than lo frequencies, it seems probable that the higher frequencies wouldn't hit the clipping at all and only the lower frequencies would need to be attenuated. With this in mind maybe you could split the input signal into two frequency band (maybe split at 5 Khz) ,process only the lower band and the remix them back together at the end (with the apropreate matching delay on the higher frequencies). This way the band width of the prossesed signal will be smaller and the sample rate wouldn't have to be so high. Another thought was what happends to the aliasing when frequenies do hit the half sample rate(this is when we are pitch shifting and clipping). I think that the aliased frequencies produced, are equile to the frequency difference between the original frequency and the half sample rate. Please correct me if I'm wrong here. Therfore if we frequency shifted our signal such that the half sample rate sat between the clean signal range and the upper destortion range (i.e. the upper distortion frequencies were above the half sample rate) then these frequencies would get aliased into frequencies that only covered the same aria as the lower destortion range and would skip entierly over the clean signal range and leave it uneffected. This way we would only need to filter out the lower desorted junk range to recover our nice and clean signal. This lo cut filter would get remove both the lower destorted junk and the aliased higher destorted junk at the same time. hope I've got it right Pete IP: Logged |
All times are CT (US) | next newest topic | next oldest topic |
![]() ![]() |
This forum is provided solely for the support and edification of the customers of Symbolic Sound Corporation.