Plug-ins, Hosts, Apps,
Hardware, Soundware
Developers
(Brands)
Videos Groups
Whats's in?
Banks & Patches
Download & Upload
Music Search
KVR
   
KVR Forum » DSP and Plug-in Development
Thread Read
Using high pass filter to hide aliasing
Goto page Previous  1, 2, 3  Next
AdmiralQuality
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Tue Apr 17, 2012 6:29 pm reply with quote
This question gets asked so much, I initially just ignored it. Then I got thinking, what if it wasn't a lowpass or highpass filter, but instead a bunch of band reject filters that you target at the loudest alias harmonics. And then I thought, what if you calculate the alias frequencies and determine the phase you expect them to be in, then just produce the same frequency in inverted phase and add it to your signal. Should cancel the aliases, right?

Not sure if the math of calculating and subtracting the alias frequencies is more efficient than any of the more common techniques. And of course, under heavy modulation it's going to become harder to predict where the aliases actually are as well as track them as they shift. Still, I'd be curious to see what could be done with a method like this.
^ Joined: 10 Oct 2005  Member: #83902  Location: Toronto, Canada
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Tue Apr 17, 2012 6:55 pm reply with quote
AdmiralQuality wrote:
This question gets asked so much, I initially just ignored it. Then I got thinking, what if it wasn't a lowpass or highpass filter, but instead a bunch of band reject filters that you target at the loudest alias harmonics. And then I thought, what if you calculate the alias frequencies and determine the phase you expect them to be in, then just produce the same frequency in inverted phase and add it to your signal. Should cancel the aliases, right?


Yeah, well, that's essentially how BLEPs work, except by taking advantage of the fact that the series sums close to zero "far away" from discontinuities (for piece-wise polynomial waveshapes at least), you can just pick the neighborhood of the discontinuity and treat it as a simple continuous spectra, then design a filter that removes everything below Nyquist (ie the stuff you want to keep) and mix it suitably offset and scaled at the discontinuity points only. Periodicity then takes care of turning it into a comb-response (giving you only the actual harmonics).

But sure, you could just sum the known series manually too (at least ignoring practical feasibility).

Quote:

Not sure if the math of calculating and subtracting the alias frequencies is more efficient than any of the more common techniques. And of course, under heavy modulation it's going to become harder to predict where the aliases actually are as well as track them as they shift. Still, I'd be curious to see what could be done with a method like this.


Oh, I see, you mean like actually take modulations in account? That's going to be problematic; even calculating the spectra that results from simple constant FM for example is not exactly fun, let alone if you cascade a few operators and mix in some other modulation. For simple stuff (eg env-sweep sync or vibratos etc) existing methods (eg BLEP) give decent results anyway; it's not until the actual modulation itself starts to have significant effects on the spectra that the stuff starts to fall apart.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Z1202
KVRist
- profile
- pm
PostPosted: Wed Apr 18, 2012 1:01 am reply with quote
[quote="mystran"]
AdmiralQuality wrote:
Oh, I see, you mean like actually take modulations in account? That's going to be problematic; even calculating the spectra that results from simple constant FM for example is not exactly fun, let alone if you cascade a few operators and mix in some other modulation.
If we are working with saw, pulse and triangle waveforms, the FM and RM results are going to be polynomial shaped, which can be considered bandlimited. So, we simply need to add BLEPs for the transitions, the same as we do in basic waveforms. With sine and more complicated shapes it can get tricky, yes Smile

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Wed Apr 18, 2012 4:52 am reply with quote
Z1202 wrote:
AdmiralQuality wrote:
Oh, I see, you mean like actually take modulations in account? That's going to be problematic; even calculating the spectra that results from simple constant FM for example is not exactly fun, let alone if you cascade a few operators and mix in some other modulation.
If we are working with saw, pulse and triangle waveforms, the FM and RM results are going to be polynomial shaped, which can be considered bandlimited. So, we simply need to add BLEPs for the transitions, the same as we do in basic waveforms. With sine and more complicated shapes it can get tricky, yes Smile


OTOH you can approximate sines quite well with piece-wise polynomials of fairly low order. If I'm not mistaken the spectra goes down an additional 6dB per order, so 3th order is 18dB/oct and 4th order is 24dB/oct. With two segments per period, we can have symmetry for odd-order harmonics only, so 4th order "BLEP sine" would have 3rd order distortion around 35-40dB or so? It's not that bad actually.

What I'm personally a bit worried about is whether the "BLEP theory" actually holds for high-order polynomials properly in practice; in theory there is no spectral expansion when you repeatedly integrate DC, but if you actually take a very higher order taylor expansion of a sine and play back the middle part, you'll probably hear a tone because the waveform has a frequency in the short-term time-window even if in the long-term it's not periodic. Now if such frequencies get past Nyquist, the BLEPs won't try to attenuate them, because from the BLEP point of view the polynomials themselves are assumed band-limited, right?
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Z1202
KVRist
- profile
- pm
PostPosted: Wed Apr 18, 2012 11:13 am reply with quote
mystran wrote:
What I'm personally a bit worried about is whether the "BLEP theory" actually holds for high-order polynomials properly in practice; in theory there is no spectral expansion when you repeatedly integrate DC, but if you actually take a very higher order taylor expansion of a sine and play back the middle part, you'll probably hear a tone because the waveform has a frequency in the short-term time-window even if in the long-term it's not periodic. Now if such frequencies get past Nyquist, the BLEPs won't try to attenuate them, because from the BLEP point of view the polynomials themselves are assumed band-limited, right?
Off the top of my head I'd guess the following. When you glue together such polynomials you get discontinuities in the derivatives which need to be "smoothed" by BLEPs of the 1st and higher orders (I'd refer to the standard BLEP as a zero-order BLEP). Now the BLEP amplitudes for the derivatives grow with frequency (because the derivatives do). So I'd guess the BLEPs will try to attenuate them. I would further guess that as the BLEP window grows, such over-the-Nyquist signal will get attenuated to zero by the respective BLEPs. A numeric experiment could probably shed more light on this Smile

Regards,
{Z}
^ Joined: 11 Apr 2002  Member: #2472  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Wed Apr 18, 2012 2:44 pm reply with quote
Z1202 wrote:
mystran wrote:
What I'm personally a bit worried about is whether the "BLEP theory" actually holds for high-order polynomials properly in practice; in theory there is no spectral expansion when you repeatedly integrate DC, but if you actually take a very higher order taylor expansion of a sine and play back the middle part, you'll probably hear a tone because the waveform has a frequency in the short-term time-window even if in the long-term it's not periodic. Now if such frequencies get past Nyquist, the BLEPs won't try to attenuate them, because from the BLEP point of view the polynomials themselves are assumed band-limited, right?
Off the top of my head I'd guess the following. When you glue together such polynomials you get discontinuities in the derivatives which need to be "smoothed" by BLEPs of the 1st and higher orders (I'd refer to the standard BLEP as a zero-order BLEP). Now the BLEP amplitudes for the derivatives grow with frequency (because the derivatives do).


Good point, though even if it would work we hit some practical problems with FM: constant frequency phase accumulator is linear, so roots are easy to solve (which we need for accurate "blep-times"). For ramp-modulation we have quadratic accumulator, and for parabolic modulator we have cubic accumulator. No problems there, even quartics can be solved. Unfortunately if the phase accumulator needs to be 5th or higher degree, it's time for a numeric solver. Even proving that there is no root in a given sample interval gets progressively harder as order increases (compare with linear where phase+delta<threshold is sufficient).
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Z1202
KVRist
- profile
- pm
PostPosted: Wed Apr 18, 2012 10:50 pm reply with quote
mystran wrote:
Good point, though even if it would work we hit some practical problems with FM: constant frequency phase accumulator is linear, so roots are easy to solve (which we need for accurate "blep-times"). For ramp-modulation we have quadratic accumulator, and for parabolic modulator we have cubic accumulator. No problems there, even quartics can be solved. Unfortunately if the phase accumulator needs to be 5th or higher degree, it's time for a numeric solver. Even proving that there is no root in a given sample interval gets progressively harder as order increases (compare with linear where phase+delta<threshold is sufficient).
I was more thinking about just one classical analog oscillator modulating another, in which case the problem occurs only with the sine Smile
^ Joined: 11 Apr 2002  Member: #2472  
V@dim
KVRist
- profile
- pm
PostPosted: Fri Apr 20, 2012 11:51 am reply with quote
Quote:
Notes: FM/RM etc can generate harmonics below fundamentals of the involved oscillators so high-pass just doesn't work. In case of RM it's enough to oversample by a factor 2 (or actually 1.5, but 2 is kinda easier) since it's just a multiply so the resulting bandwidth is the sum of the source bandwidths.


Just to add: here is "bandlimited" version of RM without oversampling:


It's from Digital sound generation by Frei. There is also version for FM:


Throught I haven't tried them yet, the theory seems to be convincing (at least for RM).
^ Joined: 18 Jun 2011  Member: #259027  Location: Ukraine
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Fri Apr 20, 2012 12:30 pm reply with quote
What the RM version does is to "low-pass" filter the two inputs with a zero at Nyquist, then multiply and finally boost the high-freqs back up with a pole. That doesn't actually band-limit anything, but it does shape the spectra such that aliasing to low-freqs (eg the most obvious stuff) has lower amplitude.

Certainly better than nothing at all, but I wouldn't expect results that you could call "high-quality" with a straight face. If you're working on a modern system, it's easy enough to oversample by 2x which will give you results as good as your oversampling filters (and you can beat the above trick with pretty cheap filters really).

The FM version on the other hand just applies a simple 1st-order low-pass on the modulation signal. I don't really understand how that would help much, since if you turn the modulation high enough, then even a low-freq sine modulator (which will pass unharmed through the filter) will cause plenty of aliasing.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Z1202
KVRist
- profile
- pm
PostPosted: Sat Apr 21, 2012 10:26 pm reply with quote
mystran wrote:
What I'm personally a bit worried about is whether the "BLEP theory" actually holds for high-order polynomials properly in practice;
Having discussed polynomials (occuring in analog FM), I now wonder whether an exponent (occuring in analog self-FM) can be considered bandlimited Smile

Had an idea to use Taylor expansion for the theoretical analysis. Probably what has to be analysed is whether the amplitudes of the BLEP residuals at the discontinuities of a "periodic exponential" signal decrease as we increase the number of terms. If they decrease fast enough, their sum will converge to some function... Don't know...
^ Joined: 11 Apr 2002  Member: #2472  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Sun Apr 22, 2012 6:57 am reply with quote
Well, simply take a definite integral over t from -inf to inf for exp(t)*exp(i*w*t). If the result is zero for any w != 0, then all the energy is at DC and any other spectral components must be a result of windowing. Right? Wink

Expo-BLEPs (or something similar) would be rather useful for other purposes as well. As I posted a while back, one can easily band-limit any periodic wave and then extract the BLEP from the results (eg using FFT) and you could use that to build a BLEP for an exponential directly. Say, if we have exp(-t) in a buffer (and mix in a ramp to cancel the step-discontinuity on wrap-around if desired) then if one extracted a single period with Heavisides, the ending discontinuity would be simply a scale version of the first one:

exp(-(t+1)) = exp(-t) * exp(-1)

The multiplier is a constant so can be divided out. If you have the sum:

exp(-t) - exp(-(t+1))
= exp(-t) - exp(-t)*exp(-1)
= (1 - exp(-1))*exp(-t)

So we can generate BLEPs for exponentials with a given time constant directly. If we change the time-constant, we'd have exp(-a*t) which as far as I can see comes down to resampling the BLEP, at which point one could just as well generate a new one. That's bit of a problem.

Anyway, this raises an interesting question whether one could generate individual BLEP branches efficiently without generating them all. If one could do that it might become feasible to do it "on-demand" which would mean that having to mix a large number of BLEPs together wouldn't be necessary anymore.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
Borogove
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Sun Apr 22, 2012 9:56 am reply with quote
davidguda wrote:
I know this is how Roland implemented the classical super saw.


My intuition is that in the complex spectrum of the supersaw, the high-end alias partials aren't particularly objectionable -- the fundamental and first few harmonics make the pitch of the sound clear, the rest is heard as a general "richness", and the highpass keeps the fundamental unambiguous.

In the case of a pure saw or other classic subtractive waveform, that analysis doesn't apply. Is a highpass useful for suppressing alias partials under the fundamental? Sure. Does it do anything about the other objectionable aliasing? No.
----

Don't do it my way.
^ Joined: 03 Oct 2002  Member: #3996  Location: SF CA USA NA Earth
davidguda
KVRist
- profile
- pm
- e-mail
PostPosted: Sun Apr 22, 2012 11:15 am reply with quote
Borogove: You might be right that if wont work as good with simpler forms than super saws where the reflected partials are more easily spotted and of course high pass filtering will only get rid of partials reflected back so far that it is under the fundamental note. The idea of using high pass was never thought as a remedy in itself rather just part solution in combination with oversampling. There are more problems as noted in previous posts with FM and RM where partials occur below the fundamental.
I probably wont use it and just to stick to more of some 'ol oversampling and/or try some other tricks.
----
David Guda gudaaudio.com
^ Joined: 28 Feb 2011  Member: #251491  
Z1202
KVRist
- profile
- pm
PostPosted: Mon Apr 23, 2012 11:33 pm reply with quote
mystran wrote:
Well, simply take a definite integral over t from -inf to inf for exp(t)*exp(i*w*t). If the result is zero for any w != 0, then all the energy is at DC and any other spectral components must be a result of windowing. Right? Wink
I'm not sure what that smile icon refers to. I assume you're kidding, right?

mystran wrote:
Expo-BLEPs (or something similar) would be rather useful for other purposes as well. As I posted a while back, one can easily band-limit any periodic wave and then extract the BLEP from the results (eg using FFT) and you could use that to build a BLEP for an exponential directly. Say, if we have exp(-t) in a buffer (and mix in a ramp to cancel the step-discontinuity on wrap-around if desired) then if one extracted a single period with Heavisides, the ending discontinuity would be simply a scale version of the first one:

exp(-(t+1)) = exp(-t) * exp(-1)

The multiplier is a constant so can be divided out. If you have the sum:

exp(-t) - exp(-(t+1))
= exp(-t) - exp(-t)*exp(-1)
= (1 - exp(-1))*exp(-t)

So we can generate BLEPs for exponentials with a given time constant directly. If we change the time-constant, we'd have exp(-a*t) which as far as I can see comes down to resampling the BLEP, at which point one could just as well generate a new one. That's bit of a problem.
I think that is the problem. You might as well simply store a bandlimited exponent in a wavetable. BTW I'm not sure what are you referring to when speaking about extracting BLEPs. Do you suggest to sample a naive discrete-time waveform at a very high rate and then use the Fourier transform to bandlimit it?

I was more thinking in the direction of generating multiple-order BLEPs, like for a synced sine, for each derivative separately. If the exponent itself, like the sine, is bandlimited, then this approach could work quite nicely.
^ Joined: 11 Apr 2002  Member: #2472  
mystran
KVRAF
- profile
- pm
- e-mail
- www
PostPosted: Tue Apr 24, 2012 8:08 am reply with quote
Z1202 wrote:
mystran wrote:
Well, simply take a definite integral over t from -inf to inf for exp(t)*exp(i*w*t). If the result is zero for any w != 0, then all the energy is at DC and any other spectral components must be a result of windowing. Right? Wink
I'm not sure what that smile icon refers to. I assume you're kidding, right?


The smile refers to the fact that if a given wave doesn't correlate with any complex sinusoid other than DC, then it's Fourier transform must obviously be zero, but I was too lazy to properly show that this is the case here. It also refers to the fact that the resulting "BLEP" is not necessarily time-limited, which for practical reasons would be necessary.

Quote:
I think that is the problem. You might as well simply store a bandlimited exponent in a wavetable.


Wait, exponential is not time-limited, so your wavetable would have to be infinite. So it's still useful if you can separate it into a time-limited BLEP + naive exponential (which can be generated recursively).

Note that ignoring the question of practicality (at least for a moment) there isn't necessarily any reason why the band-limited exponential should be real. If you band-limit (using the "BLEP" + naive) approach a complex conjugate pair of complex decaying exponential, then implement the naive approach as impulse invariant transformed all-pole (which is exact copy of the analog, with aliased spectra) and then stick one branch of the "BLEP" (assuming it's approximately time-limited) as a FIR into a parallel path, you should get a filter that (approximately) matches an analog filters response to a band-limited impulse. Don't know if this actually works, but if it does, it would be interesting to compare with the method by Särkkä & Huovilainen.

Quote:

BTW I'm not sure what are you referring to when speaking about extracting BLEPs. Do you suggest to sample a naive discrete-time waveform at a very high rate and then use the Fourier transform to bandlimit it?


Yeah, that works as long as the spectra eventually decays close enough to zero that it can be ignored. I use the method for my BLEP oscillators and the resulting quality is by far the best of all the methods I've tried. Technically speaking I don't actually band-limit the FFT; rather I do the opposite and zero out the base-band to get just the aliasing.. but it doesn't really matter either way as you could subtract the naive after IFFT if you wanted.

Sample results (warning: loud high frequencies; mute monitors/phones and feed to analyzer only; note it's 32-bit float): triangle using 32-tap FFT-built BLEP with 4096 branches (using more doesn't make much difference), Blackman window. The oscillators runs at 44.1kHz directly. For saw the aliasing (in the transition band) is a bit more obvious (in an analyzer) but other methods I've tried had noise problems with triangles. If you'd oversample by 2 (like I normally do; avoids resampling before a non-linear filter) you could get much better quality even with half the BLEP-length.

However... you could also sample the continuous-time waveform directly in Fourier domain (without starting from a naive time-domain wave) and if you can find a closed-form solution for the harmonic series sampled at regular intervals (ie wrap-around period of the finite FFT) then you could calculate all the harmonics. That might be computationally attractive (see below), but if the spectrum has sufficient decay (compared to how much you oversample) then it really doesn't matter much either way.

The above approach could be useful though: if you do the wrap-around directly in frequency domain, then you wouldn't need to calculate all the branches. You could just add the relevant phase-shift (for a particular branch) directly into the bins and do the IFFT at final rate to get a single BLEP branch. If there's closed-form expression for the whole series that hits a particular bin, one could try doing them on-demand as long as the hypothetical closed-form expression isn't too expensive; the 16-tap or 32-tap IFFT + windowing shouldn't be a huge deal in itself.

Quote:

I was more thinking in the direction of generating multiple-order BLEPs, like for a synced sine, for each derivative separately. If the exponent itself, like the sine, is bandlimited, then this approach could work quite nicely.


I think this runs into the same problem as exponentials: you could do it, but if you change the frequency (or phase) then you'd need a new BLEP.
----
<- my plugins | my music -> @Soundcloud
^ Joined: 11 Feb 2006  Member: #97939  Location: Helsinki, Finland
All times are GMT - 8 Hours

Printable version
Page 2 of 3
Goto page Previous  1, 2, 3  Next
Display posts from previous:   
ReplyNew TopicPrevious TopicNext Topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Username: Password:  
KVR Developer Challenge 2012