[Csnd] while do, pvsbin and python within csound
Date | 2014-09-04 15:22 |
From | "vallste@libero.it" |
Subject | [Csnd] while do, pvsbin and python within csound |
Attachments | pvsbinpy.csd |
Hello, I'm trying to manipulate pvs bin data with python within csound but I get strange results (more likely I'm missing something regarding pvs opcodes). In the attached csd a sine wave is analized with pvsanal then a while cycle put results of pvsbin(s) in a python list and print them in a txt file (for each line there is bin number, freqency and amplitude values provided by pvs bin). I'd expected to see the frequency of the sinewave oscillator and it's amplitude to appear somewere in the file but I do get complete unrelated numbers (with ifftsize of 1024 osillator at 50 or at 110 Hz I always get 0 or -86.13281 or +86.13281) and looks like that the same (wrong) frequency (and amplitude) is stored in all the bins. Increasing ifftsize lower the frequency value but not the overall behaviour. Maybe pvsbin could not be used within a while loop? Can someone please test the file and share the results? Csound 6.00.1 on an XP machine Thank you in advance |
Date | 2014-09-04 15:30 |
From | Justin Smith |
Subject | Re: [Csnd] while do, pvsbin and python within csound |
A dft will not tell you the precise canonical frequencies present in a sound. It finds some set of frequencies that are sufficient to reproduce the input, on a frame by frame basis. The frequencies it tracks are limited to an even linear spacing - if your input frequency is not exactly the same as one of the frequencies monitored, you will get excitations in all the other bins, spread around, sufficient to recreate your frequency. If you want frequency tracking, you need to do some other processing, but this technique *is* sufficient to reproduce the input sound, and to do programmatic modifications of that sound. On Thu, Sep 4, 2014 at 7:22 AM, vallste@libero.it <vallste@libero.it> wrote: Hello, |
Date | 2014-09-05 07:49 |
From | Richard Dobson |
Subject | Re: [Csnd] while do, pvsbin and python within csound |
Those frequencies (+-86.something Hz) are typical of the very first bin in an analysis frame. Corresponds to the "fundamental frequency of analysis", which will indeed be lower for larger FFT sizes. The frame nominally spans frequencies linearly from DC to Nyquist (with a negative frequency simple being in opposite phase, as computed by pvoc). The bin of interest will likely be further up the frame, and typically one needs to use some peak tracking algorithm to find the freuency/ies of interest. If your input is a single sinusoid, then the (adjacent) bins with the largest amplitudes will identify the frequency; but that is really the only case where that simple search is reliable. Richard Dobson On 04/09/2014 15:22, vallste@libero.it wrote: > Hello, > I'm trying to manipulate pvs bin data with python within csound but I > get strange results (more likely I'm missing something regarding pvs > opcodes). > In the attached csd a sine wave is analized with pvsanal then a while > cycle put results of pvsbin(s) in a python list and print them in a txt > file (for each line there is bin number, freqency and amplitude values > provided by pvs bin). > > I'd expected to see the frequency of the sinewave oscillator and it's > amplitude to appear somewere in the file but I do get complete unrelated > numbers (with ifftsize of 1024 osillator at 50 or at 110 Hz I always > get 0 or -86.13281 or +86.13281) and looks like that the same (wrong) > frequency (and amplitude) is stored in all the bins. Increasing ifftsize > lower the frequency value but not the overall behaviour. > > Maybe pvsbin could not be used within a while loop? > Can someone please test the file and share the results? > > Csound 6.00.1 on an XP machine > > Thank you in advance |