# A filter that decays proportionately to the wavelength of each freq? So for each wavelength at each freq, that freq's amplitude is attenuated by (*c)?

I am trying to design a filter that decays amplitude of signal passed through it proportional to the number of wavelengths that pass at that frequency in a given time.

In other words, where for every wavelength that passes at frequency $$f$$ (with time passed = $$1/f$$) the amplitude at this frequency has been reduced by $$c$$ (eg. reduced to $$0.5$$ from $$1$$ for example if $$c=0.5$$).

Thus at the same time at frequency $$f*2$$ (with time passed = $$1/f$$) there have now been two wavelengths passed, and this frequency should have been attenuated by $$c^2$$ (eg. reduced to $$0.25$$ from $$1$$).

This could be generally described by an equation like:

amplitude(f) = amplitude_init * c^(f/f_0)

$$A(f) = A_0 * c^{\frac{f}{f_0}}$$

Does such a filter exist or could one be conceptualized? What would the slope/design look like?

A 6db/octave slope in theory means the amplitude is attenuated by 0.5 for each octave up over a given time frame, right?

So at the same point in time, starting from 1 you get:

f = 0.5, f*2 = 0.25, f*4 = 0.125

Whereas what I'm describing would I believe be at the same time point:

f = 0.5, f*2 = 0.25, f*4 = 0.0625

Does such a thing exist? If so what would it represent? I have used for example the spectral tilt filter here which can be used to make arbitrary straight dB/oct slope filters if needed. But I think what I'm describing is not straight dB/oct slope.

Thanks for any thoughts.

EDIT It occurs to me that perhaps this could be accomplished by running multiple filters each 1 octave above the other. ie. so it would be an extra 6 dB down for each sequential filter each octave up? Or something like that.

The OP is correct that the desired response is not a straight dB/octave slope.

Given the desired magnitude response as:

$$|H(f)| = c^{f/f_o}$$

where $$c$$ is a real positive constant with $$c\le 1$$,

Expressed as a dB quantity this is:

$$20\log_{10}(c^{f/f_o}) = (f/f_o) 20\log_{10}(c)$$

If for example $$c=0.5$$, then $$20\log_{10}(0.5) = 6.02$$ and the attenuation would be given by $$-(f/f_o) 6.02$$ dB.

To express this as a slope quantity in dB/octave, substitute

$$f/f_o = 2^x$$

Where $$x$$ is the linear horizontal axis in units of octaves relative to $$f_o$$

Resulting in the following

$$-20\log_{10}(c)2^x \text{ dB/octave}$$

So for the case when $$c=0.5$$, $$-20\log_{10}(c) = -6.02$$ dB and we see that the result is clearly not linear on a log log scale (this is however linear on a dB per linear frequency scale):

$$x = 0$$, $$f/f_0 = 1$$, $$Atten = -6.02$$ dB
$$x = 1$$, $$f/f_0 = 2$$, $$Atten = -12.04$$ dB
$$x = 2$$, $$f/f_0 = 4$$, $$Atten = -24.08$$ dB
$$x = 3$$, $$f/f_0 = 8$$, $$Atten = -48.16$$ dB
$$x = 4$$, $$f/f_0 = 16$$, $$Atten = -96.32$$ dB

A simple and effective way to create such a filter as an FIR filter would be to use the Frequency Sampling FIR design method: populate the desired frequency response as the complex samples of a DFT (but in this case use the real values as a zero phase frequency response) - and in doing so be sure the second half the of the array mirrors the first half of the array excluding the first DC sample (for this reason using an odd number of samples is simplest), take the inverse DFT of that, use fftshift to move the second half of the result to the first half (this makes the zero-phase frequency response causal in the time domain), and multiply that result with a window to further reduce frequency ripple from the time domain truncation.

Below shows an example 83-tap FIR filter for $$c=0.5$$ with $$f_o = 0.03$$ cycles/sample ($$f=1$$ would be the sampling rate). The match at the lower frequencies is improved by increasing the number of taps.

# python code to generate filter coeff
N = 83
c = 0.5
fo = .03
f = np.arange(N)/N
hf = c**(f/fo)
hf[(N-1)//2+1:] = hf[(N-1)//2:0:-1]
idft = fft.fftshift(fft.ifft(hf))
coeff = idft * sig.kaiser(N, 12)


But I think what I'm describing is not straight dB/oct slope.

You are correct. It's natural to see straight lines in dB/octave -- or filter gains that approach straight lines -- with IIR filters. Specifically, it's natural for filter responses to asymptotically approach $$6n \mathrm{dB / oct}$$, where $$n$$ is an integer.

Does such a thing exist? If so what would it represent?

I don't know of any application for such a thing, or what it might represent. It's not something you'd get with ordinary differential equations, or even ordinary fractional differential equations (i.e., equations incorporating $$\frac{d^\alpha}{dt^\alpha}$$ where $$\alpha$$ is not an integer).

You could always approximate that amplitude response to whatever precision you wanted to with an FIR or IIR filter, but I don't know that you'll find any deep meaning to do so.

Note that the phase response may matter -- in general, if you're doing this for image processing or communications systems, it's important that the filter response be symmetrical around zero delay (or some constant delay). This is called a "linear phase" filter. On the other hand, if you're doing this for audio or control systems, it's usually best that the filter be minimum phase.

Dan Boschen's answer will get you a linear-phase filter, that has a response that's symmetrical around some integer delay. This is great for images and data because the center is important and "preringing" isn't. For audio, the preringing will sound just like the word sounds -- things like drum beats and cymbal strikes will "ring" before the main sound, and it'll be audible during rapidly-articulated passages. For control systems, the pure delay will just kill your phase response.

A minimum-phase filter will tend to respond to impulsive events with a large initial response and then a "tail" (ringing or not, depending on the amplitude profile). This will look crappy on images (bright dots will tend to bleed to the right and down, but not up or to the left), for communications systems or detection problems it'll tend to smear pulses out in ways that are hard to recover. On the other hand, that large initial impulse will give a control system its information as early as possible. For audio, the lack of ringing before a percussive event or during other rapid intonation will just sound much better.

So -- emulate your filter with a cascade of IIR filters (which aren't naturally minimum phase, but will be if you keep the zeros inside the stability region) or design a minimum phase FIR filter (which is a question in itself, and I encourage you to ask -- I did a search on "how do I make a minimum-phase FIR filter" and dsp.stackexchange lacks an answer, although there's information out there in other places).

• Thanks. If you're wondering it was for an artistic musical filter (eg. in waveguide synthesis). However, there are different synthesis methods that can accomplish this so it is likely not worth the pain. Dan gave a good FIR method that can do it as well.
– mike
Commented Jan 14 at 8:44
• You might want to edit your question with that bit about the artistic musical filter -- if human ears are involved, then the phase response of the filter matters, especially if human ears and aesthetics are involved. Commented Jan 14 at 17:29
• I edited my answer in anticipation of you editing your question. It would still be good if you'd do your edits :). Commented Jan 14 at 17:46