Csound Csound-dev Csound-tekno Search About

[Csnd] Re: Re: fft utility

Date2009-02-26 09:22
Fromvictor
Subject[Csnd] Re: Re: fft utility
What kind of search algorithm do you use?
----- Original Message ----- 
From: "Oeyvind Brandtsegg" 
To: 
Sent: Thursday, February 26, 2009 9:10 AM
Subject: [Csnd] Re: fft utility


I do this in the feedback instrument in ImproSculpt4. I use Python to
sort the list of frequencies by amplitude. The code is in the files:
/comp/feedbackInstrument.py
/inc/instr_feedback.inc
/inc/adaptivefilter_pvs.inc

I know this is not a complete and ready version of what you need
(sorry), but it might provide a model if you want to build something.
To outline the process:
- pvs opcodes in Csound write freq and amp data to ftables
- Python reads the tables
- Python search the tables (as lists) to find the frequencies with
strongest amplitudes (see the method
FeedbackInstrument.getFreqAndAmpsForDisplay in feedbackInstrument.py).

best
Oeyvind


2009/2/25 joachim heintz :
> I'm looking for a utility which gives me from a sample (or .pvx analysis
> file) the N most prominent frequencies and their amplitudes.
> Does anyone have a tip for this? (I'm on OSX)
> Or can this be done in Csound?
> Thanks -
>
> joachim
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>


Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe 
csound"= 


Date2009-02-26 22:47
FromOeyvind Brandtsegg
Subject[Csnd] Re: Re: Re: fft utility
Here's the relevant code (from ImproSculpt/comp/feedbackInstrument.py).
- ampList a python list created from csound ftable of amplitudes
(written by pvsftw)
- sortList is the ampList sorted in ascending order
- partial is the current strongest amplitude (changing with each
iteration until we've processed as many partials as we want)
- by using ampList.index(partial), we can find the index of the
current strongest partial
- the index into the ampList correspond to the index into the csound
ftable of amplitudes (written by pvsftw)
- this index can be used to retreive the frequency of the partial
(same index into the frequency table written by pvsftw)
- strongList contains n number of strongest partials, each partial
represented as a (sub)list in the format [index, relative amplitude]
* I hope the indentation of the python code is represented fairly well
when copied into an email like this

best
Oeyvind

    def findStrongest(self, ampList, howMany):
        """
        Find the n strongest amplitudes.

        @param self: The object pointer.
        @param ampList: A list of amplitudes.
        @param howMany: The number n, e.g. How many amplitude values to return.
        @return: strongList, A list lists, indices into ampList where
the highest values can be found, with the amplitude value relative to
the current strongest amp.
        """
        sortList = copy.copy(ampList)
        sortList.sort()
        i = 0
        strongest = sortList[-1]
        strongList = [] #
        while i < howMany:
            partial = sortList.pop(-1)
            if strongest == 0 :
                strongest = 1.0
                print 'feedbackInstrument: strongest partial has amp zero'
            strongList.append([ampList.index(partial), partial/strongest])
            i += 1
        return strongList


2009/2/26 victor :
> What kind of search algorithm do you use?
> ----- Original Message ----- From: "Oeyvind Brandtsegg" 
> To: 
> Sent: Thursday, February 26, 2009 9:10 AM
> Subject: [Csnd] Re: fft utility
>
>
> I do this in the feedback instrument in ImproSculpt4. I use Python to
> sort the list of frequencies by amplitude. The code is in the files:
> /comp/feedbackInstrument.py
> /inc/instr_feedback.inc
> /inc/adaptivefilter_pvs.inc
>
> I know this is not a complete and ready version of what you need
> (sorry), but it might provide a model if you want to build something.
> To outline the process:
> - pvs opcodes in Csound write freq and amp data to ftables
> - Python reads the tables
> - Python search the tables (as lists) to find the frequencies with
> strongest amplitudes (see the method
> FeedbackInstrument.getFreqAndAmpsForDisplay in feedbackInstrument.py).
>
> best
> Oeyvind
>
>
> 2009/2/25 joachim heintz :
>>
>> I'm looking for a utility which gives me from a sample (or .pvx analysis
>> file) the N most prominent frequencies and their amplitudes.
>> Does anyone have a tip for this? (I'm on OSX)
>> Or can this be done in Csound?
>> Thanks -
>>
>> joachim
>>
>>
>> Send bugs reports to this list.
>> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
>> csound"
>>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"=
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>