Thanks Josh,
I have actually been trying with the PV_FreqBuffer, but I can't seem to get it to work with the getn approach. I think its the way I'm structuring the code, but am uncertain as to what I'm doing wrong.
Its throwing an error when I try and attach the rtf file so apologies for the excess of code on the screen.
/*
This is the example from FFT overview.
It plots the magnitude increases accross the bins.
It is also possible to post the data.
Sample Rate/ Window Size * Bin Number determinse the frequency range of each bin. With a large window size this would make it possible to get a high frequency resolution. If I then ran all the bins through a mathmatical function to determine there frequency I would have a list of all the frequencies and there magnitude.
*/
b = Buffer.alloc(s,1024);
a = { FFT(b, LFSaw.ar(4000)); 0.0 }.play;
(
b.getn(0, 1024, { arg buf;
var z, x;
z = buf.clump(2).flop;
z = [Signal.newFrom(z[0]), Signal.newFrom(z[1])];
x = Complex(z[0], z[1]);
{x.magnitude.plot}.defer //x.magnitude.post
})
)
a.free; b.free;
/*
In this example I have tried to use the same approach to give a read out of the frequencies determined by the PV_FreqBuffer as to by pass trying to determine this myself. However This doesn't seem to work as it is still trying to determine a magnitude and I'm not sure how to alter the code to display frequency data
*/
b = Buffer.alloc(s,1024);
a = { FFT(b, LFSaw.ar(4000)); 0.0 }.play;
c = { PV_FreqBuffer(a, 512) }.play;
(
c.getn(0, 512, { arg buf;
var z, x;
z = buf.clump(2).flop;
z = [Signal.newFrom(z[0]), Signal.newFrom(z[1])];
x = Complex(z[0], z[1]);
{x.magnitude.plot}.defer
})
)
a.free; b.free;
/*
In this attempt I have tired to exclusively use the getn argument without the signal and complex numbers as I thought that they related to determining the magnitude of frequencies when I was attempting to get the frequencies allready determined and stored in the PV_FreqBuffer. Yet it is still returning the same results and will not plot a graph now, but throws an error.
*/
b = Buffer.alloc(s,1024);
a = { FFT(b, LFSaw.ar(4000)); 0.0 }.play;
c = { PV_FreqBuffer(a, 512) }.play;
(
c.getn(0, 512, { |msg| msg.post })
)
a.free; b.free;
/*
Allocating a buffer for PV_FreqBuffer
*/
b = Buffer.alloc(s,1024);
c = Buffer.alloc(s, 512);
a = { FFT(b, LFSaw.ar(4000)); 0.0 }.play;
d = { PV_FreqBuffer(a, c) }.play;
(
c.getn(0, 512, { |msg| msg.post })
)
a.free; b.free;
/*
Trying with original argument but with allocated PV_FreqBuffer. Just returns values of 0.
*/
b = Buffer.alloc(s,2048);
c = Buffer.alloc(s, 1024);
a = { FFT(b, LFSaw.ar(4000)); 0.0 }.play;
d = { PV_FreqBuffer(a, c) }.play;
(
c.getn(0, 1024, { arg buf;
var z, x;
z = buf.clump(2).flop;
z = [Signal.newFrom(z[0]), Signal.newFrom(z[1])];
x = Complex(z[0], z[1]);
{x.post}.defer
})
)
a.free; b.free;
Thanks again

- Luke