It is really just the pixel-resolution of the graph. The graph size is 252, but the FFT size is 4096 ( giving 2049 points within the Nyquist frequency ). So you will see magnitude peaks between the pixels as lower amplitude because the screen doesn't display pixels between pixels. I hope this makes sense,
Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
----- Original Message ---- From: Jason Plumb jason@noisybox.net To: pd-list pd-list@iem.at Sent: Sunday, 21 October, 2007 6:06:53 AM Subject: [PD] Spectrum graphing amplitude problem
Hi.
I'm building a super simple but reconfigurable GOP spectrum graphing abstraction, but got some weird behavior early on. Please see my example:
http://noisybox.net/computers/pd/questions/freq_graph_work3.pd
The magnitude computation and dividing by the block size I got from one
of the help examples. It's almost doing the right thing -- if you drag
the slider around the single frequency peak moves around. The problem is that the peak amplitude, as graphed, changes based on the frequency.
It even seems to be periodic WRT frequency, which makes me think there's a kooky phase issue...
Any ideas?
Thanks,
-jason http://noisybox.net
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
___________________________________________________________
Want ideas for reducing your carbon footprint? Visit Yahoo! For Good http://uk.promotions.yahoo.com/forgood/environment.html
Ed Kelly wrote:
It is really just the pixel-resolution of the graph. The graph size is 252, but the FFT size is 4096 ( giving 2049 points within the Nyquist frequency ).
Hmmm....I think I follow...but if that reason holds, if I expand the graph to 256 and use a block size of 512, it should be pixel perfect eh? I tried that earlier today, but saw the same behavior...
So you will see magnitude peaks between the pixels as lower amplitude because the screen doesn't display pixels between pixels. I hope this makes sense,
That *does* make sense. It's for display reasons that I ultimately want to build a little scaling control into the abstraction...but I gotta get the basics going first.
Any other ideas?
I'm a bit new to FFT in the pd context, but I think I grok Nyquist -- Sampling at S can, at best, yield the S/2 frequency (where S is the sampling rate). But how does this relate to block size in the DFT? Your original statement sounds like the max frequency out of the fft is (block size)/2...but that can't be right, eh?
Thanks,
-jason
On Sun, 21 Oct 2007, Jason Plumb wrote:
I'm a bit new to FFT in the pd context, but I think I grok Nyquist -- Sampling at S can, at best, yield the S/2 frequency (where S is the sampling rate). But how does this relate to block size in the DFT? Your original statement sounds like the max frequency out of the fft is (block size)/2...but that can't be right, eh?
The most rapid change you can have in a signal is an alternance of two values: e.g. +1, -1, +1, -1, +1, -1, ... which has S/2 frequency.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
Mathieu Bouchard wrote:
The most rapid change you can have in a signal is an alternance of two values: e.g. +1, -1, +1, -1, +1, -1, ... which has S/2 frequency.
Woah, that's a *super* good way to remember that. Thanks. I love examples, and that's great!
Charles Henry wrote:
Any other ideas?
Another option is to use the 'plot as points' graph. You will get all the points that way, even if the size is too small.
I would do that, but the single points are just too hard to see IMO.
If you're using fft~, you will see the full spectrum from 0 to N-1, where the second half of the spectrum is the conjugate of the first half. For graphing purposes, you will probably just need the first half.
That's cool, makes sense. Since I now understand that I'm dealing with a graph/display issue, maybe I need to do some heavier lifting? That is, unless somebody can suggest a better way, I guess I'll try and do block-synchronized snapshots, somehow walk/traverse the fft results myself and look for local discretized maximums. Doesn't seem like much fun...
The real truth is that although I stand to learn a thing or two by going down this road, I'm probably just reinventing the wheel and could drop in an existing spectrum abstraction or external huh?
-jason
That's cool, makes sense. Since I now understand that I'm dealing with a graph/display issue, maybe I need to do some heavier lifting? That is, unless somebody can suggest a better way, I guess I'll try and do block-synchronized snapshots, somehow walk/traverse the fft results myself and look for local discretized maximums. Doesn't seem like much fun...
The real truth is that although I stand to learn a thing or two by going down this road, I'm probably just reinventing the wheel and could drop in an existing spectrum abstraction or external huh?
If you're looking for locations and values of peaks in a signal block, you can use pique~ to do that. When I started out, I wrote an external called maxval~ to do this, not realising there was one in front of my face :) I recommend writing an external as an exercise anyway. Chances are, you will eventually find yourself with some function you want. It's better to space out the heavy lifting than doing it all at once
On Sun, 21 Oct 2007, Jason Plumb wrote:
Mathieu Bouchard wrote:
The most rapid change you can have in a signal is an alternance of two values: e.g. +1, -1, +1, -1, +1, -1, ... which has S/2 frequency.
Woah, that's a *super* good way to remember that. Thanks. I love examples, and that's great!
I don't know why you would be taught that in any other way, as a first way of learning it. It's perfectly good to learn it in other ways, to consolidate your knowledge, but the first way to learn it ought to be the most obvious.
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That's cool, makes sense. Since I now understand that I'm dealing with a graph/display issue, maybe I need to do some heavier lifting? That is, unless somebody can suggest a better way, I guess I'll try and do block-synchronized snapshots, somehow walk/traverse the fft results myself and look for local discretized maximums. Doesn't seem like much fun...
When scaling down a graph, you often don't want to decimate it (ignore values). Instead you might want to know the minima and maxima, so you can plot two curves at once: if you reduce your graph by 10, you will replace every chunk of 10 values by the max of that chunk of 10 values in one graph, and by the min of that chunk in the other graph. (If you want to see the exact position of the peak then you can't use that method at all.)
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example. You need a flashing light source like a fluorescent tube. It's the Nyquist frequency of the light source that causes the aliasing, not of your eyes, unless you try it while blinking rapidly. The wagon wheels in western movies appear to turn backwards when the spokes are moving faster than the frame rate of the movie.
Martin
On 10/22/07, Martin Peach martin.peach@sympatico.ca wrote:
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example.
Haven't you ever seen it? (in sunlight that is)
You need a flashing light source like a fluorescent tube. It's the Nyquist frequency of the light source that causes the aliasing, not of your eyes, unless you try it while blinking rapidly. The wagon wheels in western movies appear to turn backwards when the spokes are moving faster than the frame rate of the movie.
Martin
Vision doesn't work exactly like a camera. There's no sampling that occurs--the visual signals are more/less continuous except for momentary "refresh" periods brought about by eye motion and nystagmus. I thought about it today, and I'm not entirely sure why it happens (perhaps there is a certain maximum speed which can be perceived--this is equivalent to saying there is a finite bandwidth of motion perception). I don't really know. I need to defer to *real* experts, here. but I agree, the description is more precise when talking about a camera effect...
Chuck
Charles Henry wrote:
On 10/22/07, Martin Peach martin.peach@sympatico.ca wrote:
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example.
Haven't you ever seen it? (in sunlight that is)
No. The spokes just look blurred. Have you? If you try it at night under a streetlamp then you get the effect. I'm sure I have analog eyes ;)
Martin
On Mon, 22 Oct 2007, Martin Peach wrote:
No. The spokes just look blurred. Have you? If you try it at night under a streetlamp then you get the effect. I'm sure I have analog eyes ;)
You have seen a lot of analog equipment and you know that it does time-wise sampling. analog vs digital is not what we are debating.
anyway, analog electronics are what one uses to construct digital electronics, thus analog electronics are very capable of discontinuity. If you are not satisfied with thinking of human vision as electric, you can extend the same reasoning to chemical processes that complement the electric processes in use by neurons.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
Mathieu Bouchard wrote:
On Mon, 22 Oct 2007, Martin Peach wrote:
No. The spokes just look blurred. Have you? If you try it at night under a streetlamp then you get the effect. I'm sure I have analog eyes ;)
You have seen a lot of analog equipment and you know that it does time-wise sampling. analog vs digital is not what we are debating.
Analog equipment works continuously in time. Digital is almost always clocked. If your eyes are clocked I'd like to see through them. If we are debating something here it involves a difference between continuous and discrete time systems, which constitutes part of the distinction between analog and digital in common parlance. Photons impinging on my eyes drive the illusion of vision. My eyes do not choose to sample incoming photons. The photons cause the nerve impulses. As long as the light source is continuous, something I am looking at will not spontaneously disappear because the rod or cone isn't sampling it at any given moment, rather the rod or cone is continually integrating the photon flux and outputting a stream of pulses in proportion to the incident intensity; the output is an analog of the input. In the brain the streams of pulses could be interpreted as digital but the streams from all the receptors are not synchronized by a central clock so the overall effect is of a continuous-time system.
anyway, analog electronics are what one uses to construct digital electronics, thus analog electronics are very capable of discontinuity. If you are not satisfied with thinking of human vision as electric, you can extend the same reasoning to chemical processes that complement the electric processes in use by neurons.
I never said any of that. I was responding to your implication that the aliasing effect seen in the spokes of a spinning bicycle wheel is caused by some sort of discrete-time sampling process in the eye, which is not the case. The aliasing is induced by illumination by a periodic light source which the mind interprets using a "most likely" scenario in which a spoke that reappears closest to one that was previously visible is probably the same spoke.
Martin
On Sat, 27 Oct 2007, Martin Peach wrote:
Mathieu Bouchard wrote:
You have seen a lot of analog equipment and you know that it does time-wise sampling. analog vs digital is not what we are debating.
Analog equipment works continuously in time. Digital is almost always clocked. If your eyes are clocked I'd like to see through them.
My point is that analog is also often clocked, so saying that eyes are analog doesn't actually say much on how they work.
If we are debating something here it involves a difference between continuous and discrete time systems, which constitutes part of the distinction between analog and digital in common parlance.
Yes, and it's only part of the distinction. You have to distinguish between continuous-time analog and discrete-time analog.
Photons impinging on my eyes drive the illusion of vision.
It's not an illusion. You are really seeing. Perhaps the knowledge of photons seems to you like you lost your childhood conception of vision, but it's still vision.
rather the rod or cone is continually integrating the photon flux and outputting a stream of pulses in proportion to the incident intensity;
Any camera is integrating the intensity of incoming photons. In case of video cameras it's a quite continuous process, as far as quantum phenomena can be continuous to you. it's at the output that it's discretised. Depending on the exact integration weighting in effect, it will look either more "sampled/choppy" or more "motion-blur".
the output is an analog of the input. In the brain the streams of pulses could be interpreted as digital but the streams from all the receptors are not synchronized by a central clock so the overall effect is of a continuous-time system.
do you know about asynchronous digital circuits?
that said, PWM is not digital, because it's not interpreted as digits, even though the signal may look like a digital signal on the surface. a digital interpretation of a PWM is in effect an ADC.
The aliasing is induced by illumination by a periodic light source which the mind interprets using a "most likely" scenario in which a spoke that reappears closest to one that was previously visible is probably the same spoke.
Yes, we agree on that, it was my mistake.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
On Mon, 2007-10-22 at 17:33 -0500, Charles Henry wrote:
On 10/22/07, Martin Peach martin.peach@sympatico.ca wrote:
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example.
Haven't you ever seen it? (in sunlight that is)
You need a flashing light source like a fluorescent tube. It's the Nyquist frequency of the light source that causes the aliasing, not of your eyes, unless you try it while blinking rapidly. The wagon wheels in western movies appear to turn backwards when the spokes are moving faster than the frame rate of the movie.
Martin
Vision doesn't work exactly like a camera.
i think, that is the point that martin is trying to make.
i am not an expert either, but when i encountered this effect (watching the frontwheel, while cycling at night, for instance), there was always artificial light involved. to be more precise, there was always kind of a fluorescence or any other kind of 'gas discharge lamp' (is that the correct expression?) involved. it doesn't seem to work with common light bulbs, since their 'afterglow time' is too long.
for me, it seems, that it is rather related to the light source and its frequency and not to a property of the eye.
roman
___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
On 10/22/07, Roman Haefeli reduzierer@yahoo.de wrote:
On Mon, 2007-10-22 at 17:33 -0500, Charles Henry wrote:
On 10/22/07, Martin Peach martin.peach@sympatico.ca wrote:
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example.
Haven't you ever seen it? (in sunlight that is)
As implied, I'm 99% positive I've seen it before. You might still be able to convince me that I haven't ;)
i think, that is the point that martin is trying to make.
i am not an expert either, but when i encountered this effect (watching the frontwheel, while cycling at night, for instance), there was always artificial light involved. to be more precise, there was always kind of a fluorescence or any other kind of 'gas discharge lamp' (is that the correct expression?) involved. it doesn't seem to work with common light bulbs, since their 'afterglow time' is too long.
for me, it seems, that it is rather related to the light source and its frequency and not to a property of the eye.
hey, what do you know, there's even a wiki page on it: http://en.wikipedia.org/wiki/Wagon-wheel_effect
Vision is in fact not purely analog. Although I don't necessarily think the "discrete frame" theory mentioned in the page is true, there is a counterexample. When your eyes make a saccade (fast movement), there is no blurring. There is an inhibition of the movement in between the two visual scenes. There is also nystagmus. Even when images appear perfectly clear, the eye moves in random oscillations. When researchers (I forget the citation/can't find it) used an eye camera to track random oscillations and corrected for the movement (creating a static retinotopic image), the perceived image disappears. There may be something involved in correcting for nystagmus that renders an image in a series of apparently still frames. I don't know for sure.
Chuck
On Mon, 22 Oct 2007 22:48:32 -0500 "Charles Henry" czhenry@gmail.com wrote:
That won't work in sunlight for example.
Haven't you ever seen it? (in sunlight that is)
As implied, I'm 99% positive I've seen it before. You might still be able to convince me that I haven't ;)
I think Martin is correct. It's one of those things we've seen so often in films as an artifact that we become convinced its a phenomena in reality. Thinking about it, I've never seen that in direct sunlight, the wheel just becomes blurred.
The optical (and other sensory) neurons are unlike a digital system. For a Nyquist effect it would require some other separate and internal timebase. The spiking neuron model behaves more like a switch debouncer. If two stimuli arrive too close together the persistance of the electrochemical mechanism make them seem like one slightly stronger stimulus.
There are some other interesting effects if watching a spinning wheel made of black and white spokes, some people see colour flashes at certain speeds where the cones are tricked into firing instead of the rods. But I've never seen the wheel spin backwards in natural light.
i think, that is the point that martin is trying to make.
i am not an expert either, but when i encountered this effect (watching the frontwheel, while cycling at night, for instance), there was always artificial light involved. to be more precise, there was always kind of a fluorescence or any other kind of 'gas discharge lamp' (is that the correct expression?) involved. it doesn't seem to work with common light bulbs, since their 'afterglow time' is too long.
for me, it seems, that it is rather related to the light source and its frequency and not to a property of the eye.
hey, what do you know, there's even a wiki page on it: http://en.wikipedia.org/wiki/Wagon-wheel_effect
Vision is in fact not purely analog. Although I don't necessarily think the "discrete frame" theory mentioned in the page is true, there is a counterexample. When your eyes make a saccade (fast movement), there is no blurring. There is an inhibition of the movement in between the two visual scenes. There is also nystagmus. Even when images appear perfectly clear, the eye moves in random oscillations. When researchers (I forget the citation/can't find it) used an eye camera to track random oscillations and corrected for the movement (creating a static retinotopic image), the perceived image disappears. There may be something involved in correcting for nystagmus that renders an image in a series of apparently still frames. I don't know for sure.
Chuck
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
On Tue, 23 Oct 2007, Andy Farnell wrote:
There are some other interesting effects if watching a spinning wheel made of black and white spokes, some people see colour flashes at certain speeds where the cones are tricked into firing instead of the rods. But I've never seen the wheel spin backwards in natural light.
rods are not used in bright light. They are using the yellow, green and violet cones together. the concept of brightness is a combination between the three, and the chroma is found by subtraction, resulting in something fairly equivalent to YUV.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
On Mon, 22 Oct 2007, Charles Henry wrote:
Vision doesn't work exactly like a camera.
Right. Somehow I confused two things. A maximum frequency is only called Nyquist if it involves sampling and aliasing. There are several maximum frequencies that can be computed for the eye for different circumstances, which are in the range of 10 Hz up to less than 100 Hz, but those are due to low-pass effects.
There's no sampling that occurs--the visual signals are more/less continuous except for momentary "refresh" periods brought about by eye motion and nystagmus. I thought about it today, and I'm not entirely sure why it happens (perhaps there is a certain maximum speed which can be perceived--this is equivalent to saying there is a finite bandwidth of motion perception).
Imho this is because we are trained to see "continuous" (slow enough) motion as continuous and sudden motion as sudden. If a change is sufficiently startling, it makes vision snappier. Sudden motion of the eye causes sudden motion of the scenery relative to vision, so it has an effect similar to sudden motion of physical objects themselves.
It would explain why fast-blinking lights are considered to be straining the eye: the eye (or vision system) makes extra effort as a response to high activity in eye cells due to blinking, even as one wants to ignore the blinking.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
On Mon, 22 Oct 2007, Martin Peach wrote:
Mathieu Bouchard wrote:
A very simple way to explain aliased frequencies would be: spin a bicycle wheel. When you accelerate it beyond a certain point, it will begin to look like it's going backwards instead. This is because the wheel speed, together with the repetitiveness of the wheel's appearance, have crossed the Nyquist frequency of your eye.
That won't work in sunlight for example. You need a flashing light source like a fluorescent tube. It's the Nyquist frequency of the light source that causes the aliasing, not of your eyes, unless you try it while blinking rapidly. The wagon wheels in western movies appear to turn backwards when the spokes are moving faster than the frame rate of the movie.
Ok, I'm sorry, that was a really bad example. I don't quite know how the eye works, but there is some amount of low-pass filtering at work, that tends to cancel the Nyquist effect most of the time.
Most other artificial lights flash too. Most tungsten lightbulbs and most infamously CRT light. It depends on whether the combination of all low-pass effects of all components turns out to be smoothing the light emission enough so that it looks more like the spokes are blurring rather than going backwards.
_ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada
Any other ideas?
Another option is to use the 'plot as points' graph. You will get all the points that way, even if the size is too small.
I'm a bit new to FFT in the pd context, but I think I grok Nyquist -- Sampling at S can, at best, yield the S/2 frequency (where S is the sampling rate). But how does this relate to block size in the DFT? Your original statement sounds like the max frequency out of the fft is (block size)/2...but that can't be right, eh?
exactly right. When you use rfft~ on a block-size of N, you will have N/2+1 points in the real part, indexed from 0 to N/2. You will have N/2-1 points in the imaginary part, indexed from 1 to N/2-1 (because the imaginary part of the fft of a real-valued signal is zero at the 0 frequency and at the Nyquist frequency).
If you're using fft~, you will see the full spectrum from 0 to N-1, where the second half of the spectrum is the conjugate of the first half. For graphing purposes, you will probably just need the first half.