POV-Ray : Newsgroups : povray.off-topic : Filtering - don't bank on it... Server Time
14 Oct 2026 10:25:33 EDT (-0400)
  Filtering - don't bank on it... (Message 1 to 24 of 24)  
From: Invisible
Subject: Filtering - don't bank on it...
Date: 4 Nov 2008 10:42:48
Message: <49106d78$1@news.povray.org>
And so, I have spent an entire day constructing a filter bank.

Actually constructing a bank of filters that split a signal into several 
signals is pretty easy. Getting it so that adding those signals together 
actually yields the original signal has taken me *an entire day* to day 
right.

For the longest time, the wave kept coming out somewhat out-of-phase 
with the original. Eventually I figured out that that's because I need 
to shift the input signal in relation to the filter kernel (thus making 
it technically non-causal).

And then the signal still doesn't "quite" match the original, especially 
at low frequencies. A added another channel for very low frequencies, 
and now the signals match in shape, but not quite in amplitude.

Another hour spent fiddling with scaling factors, and I discover that if 
the 1x and 2x channels are set to half the amplitude of all the other 
channels, I get a crisp, perfect signal match. Yay, me!! :-D



...Further testing reveals that while the filter bank does split the 
signal into different parts, and adding them back together exactly 
reproduces the original signal, each channel actually contains a fairly 
wide collection of frequencies. For example, the 64x channel still 
contains entirely too many high frequencies.

Damnit! >_<

I hypothesize that this is due to spectural leakage caused by the 
rectangular window over the filter kernels. Maybe with a Blackman window 
or something I can get channels that actually contain only certain 
frequencies.

Hmm, and how much do you want to bet that as soon as I change the 
details of my filter bank, the signal reconstruction will stop working 
again?

I can't help feeling that somebody somewhere has already figured all 
this stuff out, and if I could just get my hands on that information, 
all of this stuff would suddenly seem a whole lot easier... :-(


Post a reply to this message

From: Darren New
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 11:38:20
Message: <49107a7c$1@news.povray.org>
Remember when "don't bank on it" actually meant something? :-)

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

From: Warp
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 12:04:02
Message: <49108082@news.povray.org>
Invisible <voi### [at] devnull> wrote:
> And so, I have spent an entire day constructing a filter bank.

> Actually constructing a bank of filters that split a signal into several 
> signals is pretty easy. Getting it so that adding those signals together 
> actually yields the original signal has taken me *an entire day* to day 
> right.

> For the longest time, the wave kept coming out somewhat out-of-phase 
> with the original. Eventually I figured out that that's because I need 
> to shift the input signal in relation to the filter kernel (thus making 
> it technically non-causal).

> And then the signal still doesn't "quite" match the original, especially 
> at low frequencies. A added another channel for very low frequencies, 
> and now the signals match in shape, but not quite in amplitude.

> Another hour spent fiddling with scaling factors, and I discover that if 
> the 1x and 2x channels are set to half the amplitude of all the other 
> channels, I get a crisp, perfect signal match. Yay, me!! :-D



> ...Further testing reveals that while the filter bank does split the 
> signal into different parts, and adding them back together exactly 
> reproduces the original signal, each channel actually contains a fairly 
> wide collection of frequencies. For example, the 64x channel still 
> contains entirely too many high frequencies.

> Damnit! >_<

> I hypothesize that this is due to spectural leakage caused by the 
> rectangular window over the filter kernels. Maybe with a Blackman window 
> or something I can get channels that actually contain only certain 
> frequencies.

> Hmm, and how much do you want to bet that as soon as I change the 
> details of my filter bank, the signal reconstruction will stop working 
> again?

> I can't help feeling that somebody somewhere has already figured all 
> this stuff out, and if I could just get my hands on that information, 
> all of this stuff would suddenly seem a whole lot easier... :-(

  Sorry for quoting the entire long post, but I find it rather amusing
that this amount of text doesn't really tell exactly *what* you are doing.

  The only thing the text refers to is some completely unspecified "signal",
as well as a completely unspecified "wave".

  What "signal"? Radio signal? TV signal? Sound signal? Video signal?
Something completely different? What is the source of this signal? What
is it that you are trying to do with this "filter" you are applying to this
"signal"? What is the point of your post anyways?

-- 
                                                          - Warp


Post a reply to this message

From: Stephen
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 12:35:01
Message: <web.491086eff3d32ffd6117f2130@news.povray.org>
Warp <war### [at] tagpovrayorg> wrote:
> Invisible <voi### [at] devnull> wrote:
> > And so,

>   What "signal"? Radio signal? TV signal? Sound signal? Video signal?
> Something completely different? What is the source of this signal? What
> is it that you are trying to do with this "filter" you are applying to this
> "signal"? What is the point of your post anyways?
>

Why are we here? What is the meaning of 42?

Stephen


Post a reply to this message

From: Stephen
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 12:35:01
Message: <web.49108721f3d32ffd6117f2130@news.povray.org>
Darren New <dne### [at] sanrrcom> wrote:
> Remember when "don't bank on it" actually meant something? :-)
>

LOL

Stephen


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 14:13:57
Message: <49109ef5$1@news.povray.org>
Warp wrote:

>   Sorry for quoting the entire long post, but I find it rather amusing
> that this amount of text doesn't really tell exactly *what* you are doing.

I want to split a sound signal into several frequency bands.

Actually, technically I *have* split a sound signal into several 
frequency bands... but not in a very useful way. In particular, the 
lowest frequency band still contains large amounts of high frequencies.

It's really frustrating to have worked this long on something and not 
got very far. I should probably go read a book or something...

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 14:17:51
Message: <49109fdf@news.povray.org>
Stephen wrote:

> Why are we here?

We're bored?

> What is the meaning of 42?

Would it be wrong to reply "4 * 10^2 + 2 * 10^2"? ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 14:18:19
Message: <49109ffb@news.povray.org>
>> What is the meaning of 42?
> 
> Would it be wrong to reply "4 * 10^2 + 2 * 10^2"? ;-)

Yes... yes it would... PWN3D! >_<

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Warp
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 14:31:01
Message: <4910a2f4@news.povray.org>
Orchid XP v8 <voi### [at] devnull> wrote:
> Warp wrote:

> >   Sorry for quoting the entire long post, but I find it rather amusing
> > that this amount of text doesn't really tell exactly *what* you are doing.

> I want to split a sound signal into several frequency bands.

  Why?

  (Btw, did you know that even if a sound signal has only one single
frequency, a discrete fourier transform is usually completely unable
to find that single frequency, and instead will find a large (potentially
infinite) amount of frequencies around that real frequency?)

-- 
                                                          - Warp


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 14:50:30
Message: <4910a786$1@news.povray.org>
>> I want to split a sound signal into several frequency bands.
> 
>   Why?
> 
>   (Btw, did you know that even if a sound signal has only one single
> frequency, a discrete fourier transform is usually completely unable
> to find that single frequency, and instead will find a large (potentially
> infinite) amount of frequencies around that real frequency?)

I think you just answered the question, right there. :-)

No, in seriousness... I'm playing around with designing an audio codec. 
Most of the ones I've seen are based on chopping the signal into bits, 
taking some kind of Fourier-related transform, selectively removing some 
of the data, and then trying to hide the discontinuities between 
segments. My plan is to seperate a signal into several continuous 
signals, and process those.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: andrel
Subject: Re: Filtering - don't bank on it...
Date: 4 Nov 2008 15:25:18
Message: <4910B003.5020407@hotmail.com>
On 04-Nov-08 20:14, Orchid XP v8 wrote:
> I should probably go read a book or something...

Why?

Remember Westheimer's Discovery: A couple of months in the laboratory 
can frequently save a couple of hours in the library


Post a reply to this message

From: scott
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 02:51:38
Message: <4911508a@news.povray.org>
Would help if I actually wrote something before posting... ;-)

> I want to split a sound signal

Don't worry about the phase of the signals then, your ears don't care.  In 
hardware filters the phase is rarely preserved, and actually often varies as 
a function of frequency.  Just make sure the phase shift is the same for the 
Left and Right channels, otherwise you might mess up some stereo effect.


Post a reply to this message

From: scott
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 02:56:55
Message: <491151c7$1@news.povray.org>
>  (Btw, did you know that even if a sound signal has only one single
> frequency, a discrete fourier transform is usually completely unable
> to find that single frequency, and instead will find a large (potentially
> infinite) amount of frequencies around that real frequency?)

It just depends how many samples you use for your fourier transform, the 
more samples you take, the more accurately you can divide up the frequency 
spectrum.  If you have a couple of seconds of normal audio recording (so 
like 100k samples), you should be able to find a single frequency pretty 
accurately, certainly to within 1 Hz.


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 04:16:11
Message: <4911645b$1@news.povray.org>
scott wrote:
> Would help if I actually wrote something before posting... ;-)
> 
>> I want to split a sound signal
> 
> Don't worry about the phase of the signals then, your ears don't care.  
> In hardware filters the phase is rarely preserved, and actually often 
> varies as a function of frequency.  Just make sure the phase shift is 
> the same for the Left and Right channels, otherwise you might mess up 
> some stereo effect.

More significantly, if the same frequency is present in more than one 
channel, phase will matter. (I still need to add the channels back 
together again and end up with the same signal as before, which won't 
happen if phase differences cause spurious boosting/cutting.)

Besides, in a digital FIR filter, it's trivial to make the filter 
zero-phase.

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Warp
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 12:23:53
Message: <4911d6a8@news.povray.org>
scott <sco### [at] scottcom> wrote:
> >  (Btw, did you know that even if a sound signal has only one single
> > frequency, a discrete fourier transform is usually completely unable
> > to find that single frequency, and instead will find a large (potentially
> > infinite) amount of frequencies around that real frequency?)

> It just depends how many samples you use for your fourier transform, the 
> more samples you take, the more accurately you can divide up the frequency 
> spectrum.  If you have a couple of seconds of normal audio recording (so 
> like 100k samples), you should be able to find a single frequency pretty 
> accurately, certainly to within 1 Hz.

  If the actual frequency falls in between two frequencies of the DFT,
there's no way for the DFT to produce just one or a few lines. Only if
the frequency happens to be exactly on one of the frequencies sampled
by the DFT, it will generate one single line.

-- 
                                                          - Warp


Post a reply to this message

From: Darren New
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 14:39:01
Message: <4911f655$1@news.povray.org>
Orchid XP v8 wrote:
> More significantly, if the same frequency is present in more than one 
> channel, phase will matter.

I think phase matters for mentally positioning the source of a sound, 
too. I'm pretty sure that's one of the ways they make those "surround 
sound headphones" and those "sounds like you're there" recordings.

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

From: Orchid XP v8
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 14:43:27
Message: <4911f75f@news.povray.org>
Darren New wrote:
> Orchid XP v8 wrote:
>> More significantly, if the same frequency is present in more than one 
>> channel, phase will matter.
> 
> I think phase matters for mentally positioning the source of a sound, 
> too. I'm pretty sure that's one of the ways they make those "surround 
> sound headphones" and those "sounds like you're there" recordings.

Oh, sure. But if you want that level of sound clarity, you're using 
lossy audio compression...why? ;-)

-- 
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*


Post a reply to this message

From: Darren New
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 14:56:16
Message: <4911fa60$1@news.povray.org>
Orchid XP v8 wrote:
> Oh, sure. But if you want that level of sound clarity, you're using 
> lossy audio compression...why? ;-)

Just saying....

-- 
Darren New / San Diego, CA, USA (PST)


Post a reply to this message

From: Jim Henderson
Subject: Re: Filtering - don't bank on it...
Date: 5 Nov 2008 23:56:49
Message: <49127911$1@news.povray.org>
On Tue, 04 Nov 2008 19:17:50 +0000, Orchid XP v8 wrote:

> Stephen wrote:
> 
>> Why are we here?
> 
> We're bored?
> 
>> What is the meaning of 42?
> 
> Would it be wrong to reply "4 * 10^2 + 2 * 10^2"? ;-)

Yes, because you've just described the number 600. ;-)

Jim


Post a reply to this message

From: scott
Subject: Re: Filtering - don't bank on it...
Date: 6 Nov 2008 03:34:13
Message: <4912ac05@news.povray.org>
>  If the actual frequency falls in between two frequencies of the DFT,
> there's no way for the DFT to produce just one or a few lines.

Of course there is, try it.  If you create a frequency that is half-way 
between two frequencies in the DFT, your DFT histogram will still look the 
same shape, the peak will just be shared between the two frequencies.

And of course if you analyse the DFT properly (ie not just look at a picture 
of the magnitude of each result) you will be able to determine the exact 
frequency.  I mean in the worst case you can just do an inverse DFT to get 
back the exact same signal!


Post a reply to this message

From: Invisible
Subject: Re: Filtering - don't bank on it...
Date: 6 Nov 2008 07:32:49
Message: <4912e3f1@news.povray.org>
scott wrote:
>>  (Btw, did you know that even if a sound signal has only one single
>> frequency, a discrete fourier transform is usually completely unable
>> to find that single frequency, and instead will find a large (potentially
>> infinite) amount of frequencies around that real frequency?)
> 
> It just depends how many samples you use for your fourier transform, the 
> more samples you take, the more accurately you can divide up the 
> frequency spectrum.  If you have a couple of seconds of normal audio 
> recording (so like 100k samples), you should be able to find a single 
> frequency pretty accurately, certainly to within 1 Hz.

IIRC, there's a version of the Fourier transform from a discrete time 
domain to a continuous frequency domain. Anybody know details?


Post a reply to this message

From: Warp
Subject: Re: Filtering - don't bank on it...
Date: 6 Nov 2008 09:15:36
Message: <4912fc08@news.povray.org>
scott <sco### [at] scottcom> wrote:
> Of course there is, try it.  If you create a frequency that is half-way 
> between two frequencies in the DFT, your DFT histogram will still look the 
> same shape, the peak will just be shared between the two frequencies.

  The same shape as what?

  Basically you are saying that you can recreate a sine wave (which is one
single frequency) with the sum of two sine waves (the two frequencies in
the discrete frequency spectrum)? Not only that, but the two sine waves
in question are adjacent to each other in the discrete frequency spectrum?

  I would be interested in seeing some simple math about this.

-- 
                                                          - Warp


Post a reply to this message

From: scott
Subject: Re: Filtering - don't bank on it...
Date: 6 Nov 2008 09:19:02
Message: <4912fcd6$1@news.povray.org>
>> Of course there is, try it.  If you create a frequency that is half-way
>> between two frequencies in the DFT, your DFT histogram will still look 
>> the
>> same shape, the peak will just be shared between the two frequencies.
>
>  The same shape as what?

As a frequency that is exactly lined up with one of the bands of the DFT.

>  Basically you are saying that you can recreate a sine wave (which is one
> single frequency) with the sum of two sine waves (the two frequencies in
> the discrete frequency spectrum)?

No, I am saying that given a finite DFT transform result with more than one 
non-zero entry, if you perform the inverse DFT you will recreate a single 
frequency sine wave.


Post a reply to this message

From: Invisible
Subject: Re: Filtering - don't bank on it...
Date: 6 Nov 2008 09:20:25
Message: <4912fd29$1@news.povray.org>
Warp wrote:

>   Basically you are saying that you can recreate a sine wave (which is one
> single frequency) with the sum of two sine waves (the two frequencies in
> the discrete frequency spectrum)? Not only that, but the two sine waves
> in question are adjacent to each other in the discrete frequency spectrum?
> 
>   I would be interested in seeing some simple math about this.

   sin x + sin y = 2 cos (x-y)/2 sin (x+y)/2

If we replace x and y with jt and kt, we have

   sin jt + sin kt = 2 cos t(j-k)/2 sin t(j+k)/2

If j and k are very close, (j-k)/2 would be nearly zero, so the cos term 
would be nearly unity. Then we would have just

   sin jt + sin kt = 2 sin t(j+k)/2

In other words, a sine wave who's frequency is the arithmetic mean of 
the frequences of the two waves being added. QED.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.