Csound Csound-dev Csound-tekno Search About

[Csnd] Confusion over pvsftw

Date2014-01-05 17:30
FromRoger Kelly
Subject[Csnd] Confusion over pvsftw
I am wanting to get the fft distributions of a pvsanal stream and save it in a file.

I have the code to extract it from the manual example of pvsftw and that works.  

What I don't understand is how the windowing affects variations in the output.

If I change p3 around I get different values in the amplitude bins.

I think my conceptual mistake is not understanding over what time period pvsftw functions.

Basically I would like to get what dispfft gives you but save it tables with "iprd -- the period of display in seconds " = length of sample.

How could I do this with pvsftw?



Date2014-01-05 21:15
FromRichard Dobson
SubjectRe: [Csnd] Confusion over pvsftw
The pvsftw opcode is not designed for display, more for user-written 
spectral modifications. The analysis rate (set by the size of the 
overlap in pvsanal etc) is generally much faster (in the 100s per sec) 
than it is practical to display (e.g. the display frame rate is more 
like 30fps). The opcode pvsdisp is the streaming counterpart to dispfft 
and includes an equivalent optional argument to pace the display. It 
would be possible to construct a similar approach with pvsftw, setting a 
timer to signal at the desired rate, and then call pvsftw - probably no 
need in that case to wait for the output flag value from pvsftw to 
change. That flag is there becasue the Csound control rate is (and in 
this context has to be) >= the analysis rate; in most cases (where ksmps 
is 30 or so)  a new analysis frame will only become available every 8 or 
so kcycles.

What to do next will depend on how much data you want to capture, and in 
what form, etc - analysis streams are data-intensive and there is 
potentially a lot to write; as can be seen from the typical size of a 
.pvx file. Given that trigger, you can  call pvsdisp, write data to a 
table, and maybe also one way or another (ftsave?) to a  file somewhere.

Windowing is a subtle technical issue. It is simplest to think of the 
window as a kind of filter, making local peaks representing frequency 
components in the source more distinct, and reducing the spectral 
leakage arising from the analysis process. The Hann and Hamming windows 
are similar but not identical, and result in the spectrum looking 
different. Each has advantages and disadvantages for particular 
applications. In the end, comparing the results by ear is as good a way 
of making the choice as any. See the wikipedia article for examples: 
http://en.wikipedia.org/wiki/Window_function

Richard Dobson



On 05/01/2014 17:30, Roger Kelly wrote:
> I am wanting to get the fft distributions of a pvsanal stream and save
> it in a file.
>
> I have the code to extract it from the manual example of pvsftw and that
> works.
>
> What I don't understand is how the windowing affects variations in the
> output.
>
> If I change p3 around I get different values in the amplitude bins.
>
> I think my conceptual mistake is not understanding over what time period
> pvsftw functions.
>
> Basically I would like to get what dispfft gives you but save it tables
> with "/iprd/ -- the period of display in seconds " = length of sample.
>
> How could I do this with pvsftw?
>
>