[PD] Re: Some VASP questions

Thomas Grill t.grill at gmx.net
Mon Nov 10 02:36:25 CET 2003


Hi Larry,


> First, How should I use the "detach" message, assuming that i want my
scope to
> run always in a seperate thread (so that there's no issues in switching it
> back and forth)? Should I send the "detach" message first, before starting
> processing?

It's good to use "detached" processing for all operations that are
considered to take some time. Launching the thread takes some time, so don't
use it for operations that are sure to be compatible with real-time
operation. (btw, i just realized that vasp.! should not be detached, which
would be useful for making larger temporary buffers... there's a bug causing
it to crash eventually).
You can either send a "detach 1" message before the first operation, or even
better, set the "detach" attribute at creation time by specifying e.g.
[vasp.window @detach 1]. If you have newer vasp and pd versions, you will
notice that the "@detach 1" disappears, but you can use the properties
dialog in the context menu (right mouse click) to display the attributes of
vasps objects (or rather all attribute-enabled flext objects)

>
> Next, "vasp.window" apparently doesn't handle the "to" message, so how do
I
> deal with that? I thought the approach would be to chain all the objects
to
> gether and send the first one a "to" message to set the source and
> destination arrays, and everything would be well.

vasp.window fills a buffer with a window curve, so a separate destination
won't make much sense.
There's vasp.*window to multiply half of a window with some data, or
vasp.*xwindow for a symmetric version (these two have a @to attribute)

> Now about the fft stuff - I am not sure what vasp.rfft does actually. It
seems
> like that's what I want to use, becuase I'm dealing with an audio signal.
But
> what does it output, and how does that map into a PD array? Is it
generating
> the full complex FFT, including the redundant conjugates? And are only the
> real compenents of this making it to the arrary, or is there a mag
operation
> done before writing to the array? And if so, is there a way that I can
write
> only the magnitudes of the first half of the output to my array?

the vasp.rfft operation produces the following output
bin 0 .... frequency 0 component
bin 1... windowsize/2-1 ... real part of the spectrum (only positive
frequencies)
bin windowsize/2 ... Nyquist freqency component
bin windowsize/2+1... windowsize-1 ... complex part of the spectrum (only
positive frequencies)

There's no redundancy of data as expected for a real FFT.
A magnitude operation has to be performed separately afterwards.


> IOW basically, for an FFT of a real signal, I only want the first half, so
my
> output array should be half the length of the input array. And for simple
> energy plot, each point in the array should be the magnitude vector of the
> corresponding point in the FFT.
>
> Is this somehow what is already done, or do I need to do something else to
> accomplish this?

See the attached patch... it probably does what you want to do....

best greetings,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fftscope.pd
Type: application/octet-stream
Size: 2924 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20031110/3fe43707/attachment.obj>


More information about the Pd-list mailing list