Hello!
I want to continuesly send FFT data to file (or to some data structure like list or array to then move to file), to process later.
My Idea is combine FFT Ugens with SendReply to send data from server to language, but I have problems with data consistency.
(
OSCdef(\listener, {|msg|
var data = msg[3..];
data.do(_.postln);
}, '/fft');
)
f = {
var tRate = 200;
var fftSize = 512;
var f = 220;
var n = 8;
var fDiv = {rrand(0.9, 0.1)}!n;
var sig = Mix(SinOsc.ar(f * fDiv));
var chain = FFT(LocalBuf(fftSize), sig);
chain.pvcalc(fftSize, {
| mags, phases |
SendTrig.kr(Impulse.kr(tRate), '/fft', [mags, phases]);
[mags, phases];
}, frombin: 0, tobin: 5, zeroothers: 0);
0;
}.play;
And it is actually looks like phases and magnitudes, but any structure is totally lost.
I think that my problem is that SendReply using a trigger as first argument and it should be somehow in sync with pvcalc.
Do you have any ideas how to do it or, maybe, tatally different solution?
yep! that’s what it’s made for. You allocate the buffer ahead of time and just write in to it, then save it at the end. I’ve done 25 minutes of this in the past and it was fine… though keep in mind if you are saving the raw audio as well, you can write that out then just do the FFT on it later (no need for double duty - the analysis will be the same either way)
Or allocate two buffers and write their contents alternately (when recording reaches the end of one buffer, switch recording to the other buffer and write the one that just finished). Then RAM wouldn’t limit total recording time.
(Btw use “float” sample format for PV data – values are not guaranteed to be constrained to -1 … +1 as is usually the case for audio… mentioning just in case.)
SoundFile in the language can read the values directly from an audio file. Then you can write to whatever text format you need. PV_RecordBuf buffers are in this format (btw I was looking at this only last week, I don’t always keep this info handy ) –