Hello I'm trying to implement a distortion effect (following http://music.calarts.edu/%7Eglmrboy/musicdsp/FAQs/guitar_distortion_FAQ.html ) with 48000 Hz sampling and minimum "useful" frequency = 20 Hz. My problem is with aliasing. To minimize its effect, I want to oversample, apply the distortion and then decimate it. The idea seens simple and straighforward, but what's the buffer size (and consequently, the delay) I must have? Since I don't want to distort 20 Hz frequency, I'm thinking about 48000/20 = 2400 words buffer Then I'd transform it on a 4800 words buffer (oversample), apply the distortion, run a lowpass filter with 24000 Hz cutoff frequency and decimate. The problem here is that this will be used as real-time distortion, and I introduced a 1/20 = 50ms delay. Is there some way to reduce this delay without causing problems with low frequencies? Thanks in advance, Luis Fernando

# Decimating

Started by ●July 8, 2004

Reply by ●July 8, 20042004-07-08

Luis Fernando wrote:> > Hello > > I'm trying to implement a distortion effect (following > http://music.calarts.edu/%7Eglmrboy/musicdsp/FAQs/guitar_distortion_FAQ.html > ) with 48000 Hz sampling and minimum "useful" frequency = 20 Hz. My > problem is with aliasing.This issue has been rasied here hundreds of times. See for instance this: http://groups.google.com/groups?&selm=401AF523.A2C504A8%40mega-nerd.com&rnum=1 Erik -- +-----------------------------------------------------------+ Erik de Castro Lopo nospam@mega-nerd.com (Yes it's valid) +-----------------------------------------------------------+ "I want to make sure (a user) can't get through ... an online experience without hitting a Microsoft ad." - Microsoft CEO, Steve Ballmer on the Microsoft search engine.

Reply by ●July 9, 20042004-07-09

And here: http://www.musicdsp.com --smb Erik de Castro Lopo <nospam@mega-nerd.com> wrote in message news:<40EDB05C.486C4C9C@mega-nerd.com>...> Luis Fernando wrote: > > > > Hello > > > > I'm trying to implement a distortion effect (following > > http://music.calarts.edu/%7Eglmrboy/musicdsp/FAQs/guitar_distortion_FAQ.html > > ) with 48000 Hz sampling and minimum "useful" frequency = 20 Hz. My > > problem is with aliasing. > > This issue has been rasied here hundreds of times. See for instance > this: > > http://groups.google.com/groups?&selm=401AF523.A2C504A8%40mega-nerd.com&rnum=1 > > Erik

Reply by ●July 9, 20042004-07-09

thanks! that's a very nice text, but I still have some doubts: 1) why is it necessary to run a filter when I upsample? I won't be generating any high frequency doing this, will I? 2) I tried to implement my distortion like: input -> interpolate -> "distortion" (cut amplitude) -> lowpass filter -> decimate -> output i'm using this simple "distortion" algorithm: --------- x = input / DISTORTION_LEVEL; if (x < -1) y = -2/3; else if (x > 1) y = 2/3; else y = x - (x*x*x)/3; y *= NIVEL_DISTORCAO; output = y; --------- i'm working on 48000 Hz sample ratio and interpolating four "0", so it would become 240000 Hz but, if I understand correct: "when I receive an input, for example '10000', I act like I had received 5 inputs: '10000', '0', '0', '0', '0', then I apply the distortion to them, run the lowpass filter, and return just the first one" the problem is that I end up in the same thing as if I hadn't upsampled/decimated: let's again suppose I received '10000', and suppose my "limit" amplitude (DISTORTION_LEVEL) is '5000' what will happen? input: 10000 interpolate: 10000 0 0 0 0 apply distortion: 5000 0 0 0 0 apply lowpass filter: 5000 0 0 0 0 decimate: 5000 output: 5000 it's the same output as: input: 10000 apply distortion: 5000 output: 5000 :( the problem is probably on "apply lowpass filter" is it right to interpolate putting "0" instead putting average values? won't the filter get "crazy" (instead receiving a sinusoid, it's receiving a weird thing that goes up and down every time)? BTW, i'm using a 5 bi-quad IIR filter with sample ratio of 240000 Hz. thanks in advance, Luis Fernando

Reply by ●July 9, 20042004-07-09

Luis Fernando wrote:> thanks! that's a very nice text, but I still have some doubts: > > 1) why is it necessary to run a filter when I upsample? I won't be > generating any high frequency doing this, will I?You will. When you insert extra samples, the new sequence rill represent a waveform with new frequencies unless you have a way to know what those samples would have been if they had been taken from the original source. (Whew! Long sentence sorry!) You don't have a way to know that, but you can calculate it. One way is do use a good interpolation formula. A better and often simpler way is to insert zeros and then to filter out the new artifacts. ... Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●July 9, 20042004-07-09

"Jerry Avins" <jya@ieee.org> wrote in message news:40eee85d$0$1169$61fed72c@news.rcn.com...> Luis Fernando wrote: > > > thanks! that's a very nice text, but I still have some doubts: > > > > 1) why is it necessary to run a filter when I upsample? I won't be > > generating any high frequency doing this, will I? > > One way is do use a good interpolation formula. A > better and often simpler way is to insert zeros and then to filter out > the new artifacts.The two methods are different ways of conceptualizing, but mathematically are the same process (i.e. your interpolation formula can be analyzed as a filter*, and your LP filter can be viewed as an interpolation formula). *assuming a linear interpolation formula

Reply by ●July 9, 20042004-07-09

Jon Harris wrote:> "Jerry Avins" <jya@ieee.org> wrote in message > news:40eee85d$0$1169$61fed72c@news.rcn.com... > >>Luis Fernando wrote: >> >> >>>thanks! that's a very nice text, but I still have some doubts: >>> >>>1) why is it necessary to run a filter when I upsample? I won't be >>>generating any high frequency doing this, will I? >> >>One way is do use a good interpolation formula. A >>better and often simpler way is to insert zeros and then to filter out >>the new artifacts. > > > The two methods are different ways of conceptualizing, but mathematically are > the same process (i.e. your interpolation formula can be analyzed as a filter*, > and your LP filter can be viewed as an interpolation formula). > > *assuming a linear interpolation formulaTrue enough, but the results of linear interpolation and of low-pass filtering are not the same. Linear interpolation can generate in-band distortion products that defy subsequent filtering. About "my" interpolation formula, I cited none in particular. The most appropriate method has to do with the system's specs and the resources available to meet them. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●July 9, 20042004-07-09

"Jerry Avins" <jya@ieee.org> wrote in message news:40ef164b$0$1169$61fed72c@news.rcn.com...> Jon Harris wrote: > > "Jerry Avins" <jya@ieee.org> wrote in message > > news:40eee85d$0$1169$61fed72c@news.rcn.com... > > > >>One way is do use a good interpolation formula. A > >>better and often simpler way is to insert zeros and then to filter out > >>the new artifacts. > > > > > > The two methods are different ways of conceptualizing, but mathematicallyare> > the same process (i.e. your interpolation formula can be analyzed as afilter*,> > and your LP filter can be viewed as an interpolation formula). > > > > *assuming a linear interpolation formula > > True enough, but the results of linear interpolation and of low-pass > filtering are not the same. Linear interpolation can generate in-band > distortion products that defy subsequent filtering. About "my" > interpolation formula, I cited none in particular. The most appropriate > method has to do with the system's specs and the resources available to > meet them.My point here is that linear interpolation _is_ low pass filtering. It's not very good LP filtering, but it is indeed LP filtering. In fact, you can design a FIR LP filter that does give you the _exact_ same result as a LP filter (it has a triangular impulse response). Or conversely, you can find the impulse of any linear interpolation method and implement it as a filter. You can also measure the response of a linear interpolator and observe the LP characteristic (complete with some really nasty sidelobes, the main source of the aliasing you are speaking of). I'm arguing here for a unified filtering-centric treatment of interpolation. I've found this to be the most useful way of analyzing and comparing various interpolation methods.

Reply by ●July 9, 20042004-07-09

Jon Harris wrote:> I'm arguing here for a unified filtering-centric treatment of interpolation. > I've found this to be the most useful way of analyzing and comparing various > interpolation methods.You certainly don't need to argue that with me: I agree. We're trying to give the OP a feel for what he's doing. (I'm sure he knows by now that filtering of a sort is in fact needed.) As a matter of practical implementation, the way it's done is the whole point. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●July 12, 20042004-07-12

"Jerry Avins" <jya@ieee.org> wrote in message news:40ef446b$0$1178$61fed72c@news.rcn.com...> Jon Harris wrote: > > I'm arguing here for a unified filtering-centric treatment of interpolation. > > I've found this to be the most useful way of analyzing and comparing various > > interpolation methods. > > You certainly don't need to argue that with me: I agree. We're trying to > give the OP a feel for what he's doing. (I'm sure he knows by now that > filtering of a sort is in fact needed.) As a matter of practical > implementation, the way it's done is the whole point.Glad to hear you agree with this. From some of your past comments, it sounded to me like you were considering interpolation and filtering to be different animals. To wit: "One way is do use a good interpolation formula. A better and often simpler way is to insert zeros and then to filter out the new artifacts." and "True enough, but the results of linear interpolation and of low-pass filtering are not the same. Linear interpolation can generate in-band distortion products that defy subsequent filtering." IMHO, realizing that interpolation formulas and zero-stuffing/filtering are just different implementations of LP filtering is an important step in understanding the big picture of sample rate converting.