Cabbage Logo
Back to Cabbage Site

Pre Compute FFT Analysis

Hey again!

I am working on a program that requires several components performing phase vocoder processes simultaneously. I understand the csound opcodes are built to run in realtime, but I am using audio files as my input so I do not need pvsanal to run constantly.

To optimize the program, I would like to perform the analysis once, store the values and then stop pvsanal to free up computing power.

Is this possibly/any recommendations on how to go about this?

Best,
Mitch

The pvs opcodes are can do FFT analysis/resynthesis in real time. But before these there was the pvanal way of doing things. You basically do an FFT analysis of a sound file using the pvanal tool, and then use pvoc or some of the other pv opcodes, to read that data and synthesise back to audio.

To be honest, you should be able to get pretty good performance using the PVS opcodes these days. But it depends on your target system.

They are running just fine, but worried as I start to expand.

Shortly after posting this I found a solution!

Using pvswrite to generate pvx files in advance – any other suggestions or methods would be helpful though!

Thanks! :slight_smile:

As yes, pvswrite, I had forgotten about that one :roll_eyes: :rofl:

Rory already mentioned it but, besides that is using pvswrite from Csound, is to use the pvanal utility program to generate a PVOC-EX (a pvx file). This is usually called the “pre-analysis pass” in the biz. Yes, before the real-time streaming opcodes became a thing, pre-analysis was the only way I guess. Here’s how you do it

csound -U pvanal [flags] infilename outfilename

alternatively:

pvanal [flags] infilename outfilename

example:

pvanal -c 2 -n 1024 guitar.wav guitar.pvx (this analyzes channel 2, FFT size of 1024)

then when you are composing or performing Csound simply reads from that pvx file using pvoc, vpvoc, pvadd or one of those opcodes that read “pvoc files” (which is what the manual calls pvx or PVOC-EX files). In the example you might do this in your csd file:

ares pvadd kpoint, semitone(3), "guitar.pvx", -1, 120 (resynthesizes the first 120 bins from the FFT analysis stored in the pvx file, transposed up a minor third)

I’ve been looking into this method myself because pvanal has a powerful set of flags that let you fine-tune the analysis and do “spectral extraction”.

1 Like